summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/QTReaderApp.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp811
1 files changed, 694 insertions, 117 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 8726df7..2044b1d 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -23,3 +23,6 @@
23#include <qpe/qpemenubar.h> 23#include <qpe/qpemenubar.h>
24#include <qpe/qpetoolbar.h> 24//#include <qpe/qpetoolbar.h>
25#include <qmenubar.h>
26#include <qtoolbar.h>
27#include <qpe/menubutton.h>
25#include <qpe/fontdatabase.h> 28#include <qpe/fontdatabase.h>
@@ -44,2 +47,3 @@
44#include "QTReader.h" 47#include "QTReader.h"
48#include "GraphicWin.h"
45#include "Bkmks.h" 49#include "Bkmks.h"
@@ -57,2 +61,12 @@
57#include "CDrawBuffer.h" 61#include "CDrawBuffer.h"
62#include "Filedata.h"
63#include "opie.h"
64#include "name.h"
65#include "StateData.h"
66
67#ifdef OPIE
68#define PICDIR "opie-reader/"
69#else
70#define PICDIR
71#endif
58 72
@@ -70,5 +84,6 @@ void QTReaderApp::listBkmkFiles()
70 bkmkselector->clear(); 84 bkmkselector->clear();
85 bkmkselector->setText("Cancel");
71 int cnt = 0; 86 int cnt = 0;
72 DIR *d; 87 DIR *d;
73 d = opendir((const char *)Global::applicationFileName("uqtreader","")); 88 d = opendir((const char *)Global::applicationFileName(APPDIR,""));
74 89
@@ -81,3 +96,3 @@ void QTReaderApp::listBkmkFiles()
81 96
82 if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) 97 if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode))
83 { 98 {
@@ -95,4 +110,12 @@ void QTReaderApp::listBkmkFiles()
95 if (m_fontVisible) m_fontBar->hide(); 110 if (m_fontVisible) m_fontBar->hide();
96 if (regVisible) regBar->hide(); 111 if (regVisible)
97 if (searchVisible) searchBar->hide(); 112 {
113 Global::hideInputMethod();
114 regBar->hide();
115 }
116 if (searchVisible)
117 {
118 Global::hideInputMethod();
119 searchBar->hide();
120 }
98 m_nRegAction = cRmBkmkFile; 121 m_nRegAction = cRmBkmkFile;
@@ -101,3 +124,3 @@ void QTReaderApp::listBkmkFiles()
101 else 124 else
102 QMessageBox::information(this, "OpieReader", "No bookmark files"); 125 QMessageBox::information(this, PROGNAME, "No bookmark files");
103} 126}
@@ -111,3 +134,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
111 pBkmklist = NULL; 134 pBkmklist = NULL;
112 doc = 0; 135 pOpenlist = NULL;
136// doc = 0;
113 137
@@ -120,5 +144,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
120 144
121 setIcon( Resource::loadPixmap( "opie-reader/uqtreader" ) ); 145 setIcon( Resource::loadPixmap( "uqtreader" ) );
122 146
123 QPEToolBar *bar = new QPEToolBar( this ); 147// QPEToolBar *bar = new QPEToolBar( this );
148 QToolBar *bar = new QToolBar( this );
124 bar->setHorizontalStretchable( TRUE ); 149 bar->setHorizontalStretchable( TRUE );
@@ -128,2 +153,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
128 QPEMenuBar *mb = new QPEMenuBar( bar ); 153 QPEMenuBar *mb = new QPEMenuBar( bar );
154// QMenuBar *mb = new QMenuBar( bar );
129 QPopupMenu *file = new QPopupMenu( this ); 155 QPopupMenu *file = new QPopupMenu( this );
@@ -161,2 +187,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
161 187
188 m_graphicwin = new GraphicWin(editorStack);
189 editorStack->addWidget(m_graphicwin, get_unique_id());
190 connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) );
191
162// bkmkselector = new QListBox(editorStack, "Bookmarks"); 192// bkmkselector = new QListBox(editorStack, "Bookmarks");
@@ -177,2 +207,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
177*/ 207*/
208 qDebug("Reading file list");
209 readfilelist();
178 210
@@ -180,5 +212,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
180 212
213 reader->bDoUpdates = false;
214
181 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); 215 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
182 216
183 Config config( "uqtreader" ); 217 qDebug("Reading config");
218 Config config( APPDIR );
184 config.setGroup( "View" ); 219 config.setGroup( "View" );
@@ -191,2 +226,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
191 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); 226 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
227 reader->bonespace = config.readBoolEntry( "OneSpace", false );
192 reader->bunindent = config.readBoolEntry( "Unindent", false ); 228 reader->bunindent = config.readBoolEntry( "Unindent", false );
@@ -200,2 +236,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
200 reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); 236 reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
237 reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false );
201 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); 238 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
@@ -205,4 +242,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
205 reader->m_overlap = config.readNumEntry( "Overlap", 0 ); 242 reader->m_overlap = config.readNumEntry( "Overlap", 0 );
243#ifdef REPALM
244 reader->brepalm = config.readBoolEntry( "Repalm", true );
245#endif
206 reader->bremap = config.readBoolEntry( "Remap", true ); 246 reader->bremap = config.readBoolEntry( "Remap", true );
207 reader->bmakebold = config.readBoolEntry( "MakeBold", false ); 247 reader->bmakebold = config.readBoolEntry( "MakeBold", false );
248 reader->setContinuous(config.readBoolEntry( "Continuous", true ));
208 m_targetapp = config.readEntry( "TargetApp", QString::null ); 249 m_targetapp = config.readEntry( "TargetApp", QString::null );
@@ -217,2 +258,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
217 258
259 connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) );
260
218 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); 261 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
@@ -227,2 +270,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
227 270
271 a = new QAction( tr( "Close" ), Resource::loadPixmap( "fileclose" ), QString::null, 0, this, 0 );
272 connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) );
273// a->addTo( bar );
274 a->addTo( file );
275
228 /* 276 /*
@@ -252,2 +300,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
252 300
301 m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true );
302
253 ag->addTo(spacemenu); 303 ag->addTo(spacemenu);
@@ -256,10 +306,30 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
256 306
307 file->insertSeparator();
308
309 ag = new QActionGroup(this);
310 ag->setExclusive(false);
311 QPopupMenu *encoding = new QPopupMenu(this);
312 file->insertItem( tr( "Navigation" ), encoding );
313
314 a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true );
257 315
258 a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true );
259// connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) );
260 a->setOn(false); 316 a->setOn(false);
261 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); 317 connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
262 file->insertSeparator();
263 a->addTo( bar ); 318 a->addTo( bar );
264 a->addTo( file ); 319
320 a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL);
321 connect( a, SIGNAL( activated() ), this, SLOT( jump() ) );
322
323 a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true );
324 connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
325 a->setOn(reader->m_bpagemode);
326
327 a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL);
328 connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) );
329
330 a = new QAction( tr( "Use Cursor" ), QString::null, 0, ag, NULL, true );
331 connect( a, SIGNAL( toggled(bool) ), this, SLOT( navkeys(bool) ) );
332 a->setOn(reader->m_navkeys);
333
334 ag->addTo(encoding);
265 335
@@ -274,14 +344,2 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
274 */ 344 */
275 a = new QAction( tr( "Jump" ), QString::null, 0, this, NULL);
276 connect( a, SIGNAL( activated() ), this, SLOT( jump() ) );
277 a->addTo( file );
278
279 a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, this, NULL, true );
280 connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
281 a->setOn(reader->m_bpagemode);
282 a->addTo( file );
283
284 a = new QAction( tr( "Set Overlap" ), QString::null, 0, this, NULL);
285 connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) );
286 a->addTo( file );
287 345
@@ -300,3 +358,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
300 ag->setExclusive(false); 358 ag->setExclusive(false);
301 QPopupMenu *encoding = new QPopupMenu(this); 359 encoding = new QPopupMenu(this);
302 file->insertItem( tr( "Target" ), encoding ); 360 file->insertItem( tr( "Target" ), encoding );
@@ -347,2 +405,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
347 405
406 m_fullscreen = false;
407 a = m_actFullscreen = new QAction( tr( "Fullscreen" ), QString::null, 0, this, NULL, true );
408 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
409 a->setOn(m_fullscreen);
410 a->addTo( file );
411
412 a = new QAction( tr( "Continuous" ), QString::null, 0, ag, NULL, true );
413 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setcontinuous(bool) ) );
414 a->setOn(reader->m_continuousDocument);
415 a->addTo( file );
416
348 a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 417 a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
@@ -397,2 +466,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
397 466
467 a = new QAction( tr( "Single Space" ), QString::null, 0, ag, NULL, true );
468 a->setOn(reader->bonespace);
469 connect( a, SIGNAL( toggled(bool) ), this, SLOT( onespace(bool) ) );
470
398 a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); 471 a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true );
@@ -418,3 +491,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
418 connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); 491 connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) );
419 492#ifdef REPALM
493 a = new QAction( tr( "Repalm" ), QString::null, 0, ag, NULL, true );
494 a->setOn(reader->brepalm);
495 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repalm(bool) ) );
496#endif
420 a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); 497 a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true );
@@ -431,7 +508,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
431 // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 508 // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
432 a = new QAction( tr( "Zoom" ), QString::null, 0, this);
433 connect( a, SIGNAL( activated() ), this, SLOT( TBDzoom() ) );
434 format->insertSeparator(); 509 format->insertSeparator();
510 a = new QAction( tr( "Zoom In" ), QString::null, 0, this);
511 connect( a, SIGNAL( activated() ), this, SLOT( zoomin() ) );
512 a->addTo( format );
513 a = new QAction( tr( "Zoom Out" ), QString::null, 0, this);
514 connect( a, SIGNAL( activated() ), this, SLOT( zoomout() ) );
435 a->addTo( format ); 515 a->addTo( format );
436 // a->addTo( editBar ); 516 // a->addTo( editBar );
517 format->insertSeparator();
437 518
@@ -441,3 +522,2 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
441 a->setOn(reader->m_bMonoSpaced); 522 a->setOn(reader->m_bMonoSpaced);
442 format->insertSeparator();
443 a->addTo( format ); 523 a->addTo( format );
@@ -581,2 +661,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
581 661
662 qDebug("Font selector");
582 m_fontSelector = new QComboBox(false, m_fontBar); 663 m_fontSelector = new QComboBox(false, m_fontBar);
@@ -594,4 +675,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
594 realfont = true; 675 realfont = true;
595 break;
596 } 676 }
677 if (*nm == "courier") reader->m_fontControl.hasCourier(true);
597 } 678 }
@@ -609,13 +690,61 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
609 690
610 691 qDebug("Initing");
611 reader->init(); 692 reader->init();
693 qDebug("Inited");
694 m_EncodingAction[reader->m_encd]->setOn(true);
695 m_buttonAction[m_spaceTarget]->setOn(true);
696 qDebug("fonting");
697 do_setfont(reader->m_fontname);
612 if (!reader->m_lastfile.isEmpty()) 698 if (!reader->m_lastfile.isEmpty())
613 { 699 {
700 qDebug("doclnk");
701 //doc = new DocLnk(reader->m_lastfile);
702 qDebug("doclnk done");
703 if (pOpenlist != NULL)
704 {
705
706/*
707 int ind = 0;
708 Bkmk* p = (*pOpenlist)[ind];
709 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
710 {
711 p = (*pOpenlist)[++ind];
712 }
713*/
714 Bkmk* p = NULL;
715 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
716 {
717 p = iter.pContent();
718 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
719 {
720 break;
721 }
722 qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name()));
723 p = NULL;
724 }
725 if (p != NULL)
726 {
727 qDebug("openfrombkmk");
728 openfrombkmk(p);
729 }
730 else
731 {
732 qDebug("openfile");
614 openFile( reader->m_lastfile ); 733 openFile( reader->m_lastfile );
615 doc = new DocLnk(reader->m_lastfile);
616 } 734 }
617 m_EncodingAction[reader->m_encd]->setOn(true);
618 m_buttonAction[m_spaceTarget]->setOn(true);
619 do_setfont(reader->m_fontname);
620} 735}
736 else
737 {
738 qDebug("Openfile 2");
739 if (!reader->m_lastfile.isNull())
740 openFile( reader->m_lastfile );
741 }
742 }
743 qApp->processEvents();
744 reader->bDoUpdates = true;
745 reader->update();
746 qDebug("finished update");
747}
748
749void QTReaderApp::suspend() { reader->suspend(); }
621 750
@@ -632,3 +761,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
632 stream >> info; 761 stream >> info;
633 QMessageBox::information(this, "OpieReader", info); 762 QMessageBox::information(this, PROGNAME, info);
634 } 763 }
@@ -638,3 +767,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
638 stream >> info; 767 stream >> info;
639 QMessageBox::warning(this, "OpieReader", info); 768 QMessageBox::warning(this, PROGNAME, info);
640 } 769 }
@@ -753,3 +882,3 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
753 { 882 {
754 QMessageBox::information(this, "OpieReader", QString("Can't find\n")+info); 883 QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info);
755 pos = start; 884 pos = start;
@@ -766,2 +895,16 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
766 } 895 }
896 else if ( msg == "Layout/Single Space" )
897 {
898 int info;
899 stream >> info;
900 onespace(info);
901 }
902#ifdef REPALM
903 else if ( msg == "Layout/Repalm(int)" )
904 {
905 int info;
906 stream >> info;
907 repalm(info);
908 }
909#endif
767 else if ( msg == "Markup/Auto(int)" ) 910 else if ( msg == "Markup/Auto(int)" )
@@ -878,2 +1021,18 @@ ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
878 1021
1022void QTReaderApp::setfullscreen(bool sfs)
1023{
1024 reader->bDoUpdates = false;
1025 m_fullscreen = sfs;
1026 showEditTools();
1027 qApp->processEvents();
1028 reader->bDoUpdates = true;
1029 reader->update();
1030}
1031
1032void QTReaderApp::setcontinuous(bool sfs)
1033{
1034 reader->setContinuous(sfs);
1035 reader->refresh();
1036}
1037
879int QTReaderApp::EncNameToInt(const QString& _enc) 1038int QTReaderApp::EncNameToInt(const QString& _enc)
@@ -912,12 +1071,13 @@ void QTReaderApp::autoScroll(bool _b)
912 reader->setautoscroll(_b); 1071 reader->setautoscroll(_b);
1072 setScrollState(reader->m_autoScroll);
913} 1073}
914 1074
915void QTReaderApp::TBD() 1075void QTReaderApp::zoomin()
916{ 1076{
917 QMessageBox::information(this, "OpieReader", "Not yet implemented", 1); 1077 reader->zoomin();
918} 1078}
919 1079
920void QTReaderApp::TBDzoom() 1080void QTReaderApp::zoomout()
921{ 1081{
922 QMessageBox::information(this, "OpieReader", "Zooming is done interactively\nTry left/right cursor keys", 1); 1082 reader->zoomout();
923} 1083}
@@ -931,2 +1091,74 @@ void QTReaderApp::clearBkmkList()
931 1091
1092void QTReaderApp::fileClose()
1093{
1094 if (pOpenlist != NULL)
1095 {
1096 int ind = 0;
1097 Bkmk* p = (*pOpenlist)[ind];
1098 while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile)
1099 {
1100 p = (*pOpenlist)[++ind];
1101 }
1102 if (p != NULL) pOpenlist->erase(ind);
1103 switch (QMessageBox::information ( this , PROGNAME, "What do you want to delete?", "Nothing", "Marks", "Marks\nFile", 1, 0 ))
1104 {
1105 case 0:
1106 default:
1107 break;
1108 case 2:
1109 unlink((const char*)reader->m_lastfile);
1110 case 1:
1111 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
1112 }
1113 }
1114
1115 fileOpen2();
1116}
1117
1118void QTReaderApp::updatefileinfo()
1119{
1120 if (reader->m_string.isNull()) return;
1121 if (reader->m_lastfile.isNull()) return;
1122 tchar* nm = fromQString(reader->m_string);
1123 tchar* fl = fromQString(reader->m_lastfile);
1124 qDebug("Lastfile:%x", fl);
1125 bool notadded = true;
1126 if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>;
1127 else
1128 {
1129 for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++)
1130 {
1131 if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0)
1132 {
1133 iter->value(reader->pagelocate());
1134 unsigned short dlen;
1135 unsigned char* data;
1136 CFiledata fd(iter->anno());
1137 reader->setSaveData(data, dlen, fd.content(), fd.length());
1138 qDebug("Filedata(1):%u, %u", fd.length(), dlen);
1139 // getstate(data, dlen);
1140 iter->setAnno(data, dlen);
1141 notadded = false;
1142 delete [] data;
1143 break;
1144 }
1145 }
1146 }
1147 qDebug("Added?:%x", notadded);
1148 if (notadded)
1149 {
1150 struct stat fnstat;
1151 stat((const char *)reader->m_lastfile, &fnstat);
1152 CFiledata fd(fnstat.st_mtime, fl);
1153 unsigned short dlen;
1154 unsigned char* data;
1155 reader->setSaveData(data, dlen, fd.content(), fd.length());
1156 pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate()));
1157 qDebug("Filedata(2):%u, %u", fd.length(), dlen);
1158 delete [] data;
1159 }
1160 delete [] nm;
1161 delete [] fl;
1162}
1163
932void QTReaderApp::fileOpen() 1164void QTReaderApp::fileOpen()
@@ -939,2 +1171,10 @@ void QTReaderApp::fileOpen()
939*/ 1171*/
1172 qDebug("fileOpen");
1173// if (!reader->m_lastfile.isEmpty())
1174 updatefileinfo();
1175 fileOpen2();
1176}
1177
1178void QTReaderApp::fileOpen2()
1179{
940 if (pBkmklist != NULL) 1180 if (pBkmklist != NULL)
@@ -943,3 +1183,3 @@ void QTReaderApp::fileOpen()
943 { 1183 {
944 if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) 1184 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
945 savebkmks(); 1185 savebkmks();
@@ -955,3 +1195,21 @@ void QTReaderApp::fileOpen()
955*/ 1195*/
956 fileBrowser* fb = new fileBrowser(this,"OpieReader",TRUE, 1196 if (pOpenlist != NULL)
1197 {
1198 m_nRegAction = cOpenFile;
1199 listbkmk(pOpenlist, "Browse");
1200 }
1201 else
1202 {
1203 QString fn = usefilebrowser();
1204 if (!fn.isEmpty() && QFileInfo(fn).isFile())
1205 {
1206 openFile(fn);
1207 }
1208 reader->setFocus();
1209 }
1210}
1211
1212QString QTReaderApp::usefilebrowser()
1213{
1214 fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE,
957 0, 1215 0,
@@ -960,10 +1218,18 @@ void QTReaderApp::fileOpen()
960 1218
1219
1220 QString fn;
961 if (fb->exec()) 1221 if (fb->exec())
962 { 1222 {
963 QString fn(fb->fileList[0]); 1223 fn = fb->fileList[0];
964// fb->populateList();
965 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
966 } 1224 }
1225 qDebug("Selected %s", (const char*)fn);
967 delete fb; 1226 delete fb;
968 reader->setFocus(); 1227 return fn;
1228}
1229
1230void QTReaderApp::showgraphic(QPixmap& pm)
1231{
1232 m_graphicwin->setPixmap(pm);
1233 editorStack->raiseWidget( m_graphicwin );
1234 m_graphicwin->setFocus();
969} 1235}
@@ -975,3 +1241,3 @@ void QTReaderApp::showinfo()
975 { 1241 {
976 QMessageBox::information(this, "OpieReader", "No file loaded", 1); 1242 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
977 } 1243 }
@@ -1022,3 +1288,3 @@ void QTReaderApp::addAnno(const QString& name, const QString& text)
1022 { 1288 {
1023 QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nPlease try again", 1); 1289 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1);
1024 } 1290 }
@@ -1079,3 +1345,3 @@ void QTReaderApp::addanno()
1079 { 1345 {
1080 QMessageBox::information(this, "OpieReader", "No file loaded", 1); 1346 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
1081 } 1347 }
@@ -1088,2 +1354,3 @@ void QTReaderApp::addanno()
1088 editorStack->raiseWidget( m_annoWin ); 1354 editorStack->raiseWidget( m_annoWin );
1355 Global::showInputMethod();
1089 m_annoWin->setFocus(); 1356 m_annoWin->setFocus();
@@ -1134,3 +1401,3 @@ void QTReaderApp::pageup()
1134{ 1401{
1135 reader->goUp(); 1402 reader->NavUp();
1136} 1403}
@@ -1139,3 +1406,3 @@ void QTReaderApp::pagedn()
1139{ 1406{
1140 reader->goDown(); 1407 reader->NavDown();
1141} 1408}
@@ -1146,2 +1413,12 @@ void QTReaderApp::stripcr(bool _b)
1146} 1413}
1414void QTReaderApp::onespace(bool _b)
1415{
1416 reader->setonespace(_b);
1417}
1418#ifdef REPALM
1419void QTReaderApp::repalm(bool _b)
1420{
1421 reader->setrepalm(_b);
1422}
1423#endif
1147void QTReaderApp::remap(bool _b) 1424void QTReaderApp::remap(bool _b)
@@ -1190,3 +1467,6 @@ void QTReaderApp::pagemode(bool _b)
1190} 1467}
1191 1468void QTReaderApp::navkeys(bool _b)
1469{
1470 reader->m_navkeys = _b;
1471}
1192void QTReaderApp::monospace(bool _b) 1472void QTReaderApp::monospace(bool _b)
@@ -1233,3 +1513,3 @@ void QTReaderApp::do_overlap(const QString& lcn)
1233 else 1513 else
1234 QMessageBox::information(this, "OpieReader", "Must be a number"); 1514 QMessageBox::information(this, PROGNAME, "Must be a number");
1235} 1515}
@@ -1248,3 +1528,3 @@ void QTReaderApp::do_mono(const QString& lcn)
1248 else 1528 else
1249 QMessageBox::information(this, "OpieReader", "Must be a number"); 1529 QMessageBox::information(this, PROGNAME, "Must be a number");
1250} 1530}
@@ -1266,2 +1546,3 @@ void QTReaderApp::editFind()
1266#endif 1546#endif
1547 Global::showInputMethod();
1267 searchBar->show(); 1548 searchBar->show();
@@ -1293,2 +1574,3 @@ void QTReaderApp::findClose()
1293 searchEdit->setText(""); 1574 searchEdit->setText("");
1575 Global::hideInputMethod();
1294 searchBar->hide(); 1576 searchBar->hide();
@@ -1310,2 +1592,3 @@ void QTReaderApp::regClose()
1310 regBar->hide(); 1592 regBar->hide();
1593 Global::hideInputMethod();
1311 reader->setFocus(); 1594 reader->setFocus();
@@ -1320,4 +1603,13 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1320 bool ret = true; 1603 bool ret = true;
1604 unsigned long fs, ts;
1605 reader->sizes(fs,ts);
1321 size_t pos = reader->locate(); 1606 size_t pos = reader->locate();
1322 reader->buffdoc.getline(&test,reader->width()); 1607 reader->buffdoc.getline(&test,reader->width());
1608 pbar->show();
1609 pbar->resize(width(), editBar->height());
1610 pbar->reset();
1611 int lastpc = (100*pos)/ts;
1612 pbar->setProgress(lastpc);
1613 qApp->processEvents();
1614 reader->setFocus();
1323#ifdef __ISEARCH 1615#ifdef __ISEARCH
@@ -1333,2 +1625,12 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1333 pos = reader->locate(); 1625 pos = reader->locate();
1626 unsigned int lcn = reader->locate();
1627 int pc = (100*pos)/ts;
1628 if (pc != lastpc)
1629 {
1630 pbar->setProgress(pc);
1631 qApp->processEvents();
1632 reader->setFocus();
1633 lastpc = pc;
1634 }
1635
1334 if (!reader->buffdoc.getline(&test,reader->width())) 1636 if (!reader->buffdoc.getline(&test,reader->width()))
@@ -1344,2 +1646,3 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1344 } 1646 }
1647 pbar->hide();
1345 reader->locate(pos); 1648 reader->locate(pos);
@@ -1390,10 +1693,11 @@ void QTReaderApp::openFile( const QString &f )
1390{ 1693{
1391 openFile(DocLnk(f)); 1694 qDebug("File:%s", (const char*)f);
1392} 1695// openFile(DocLnk(f));
1393 1696//}
1394void QTReaderApp::openFile( const DocLnk &f ) 1697//
1395{ 1698//void QTReaderApp::openFile( const DocLnk &f )
1699//{
1396 clear(); 1700 clear();
1397 FileManager fm; 1701 QFileInfo fm(f);
1398 if ( fm.exists( f ) ) 1702 if ( fm.exists() )
1399 { 1703 {
@@ -1401,17 +1705,14 @@ void QTReaderApp::openFile( const DocLnk &f )
1401 1705
1402 clear(); 1706 if (fm.extension( FALSE ) == "desktop")
1403 1707 {
1404 // editorStack->raiseWidget( reader ); 1708 DocLnk d(f);
1405 1709 QFileInfo fnew(d.file());
1406 // reader->setFocus(); 1710 fm = fnew;
1711 if (!fm.exists()) return;
1712 }
1407 1713
1408 // QMessageBox::information(0, "DocLnk", "Begin"); 1714 clear();
1409 doc = new DocLnk(f);
1410 // QMessageBox::information(0, "DocLnk done", doc->file());
1411 // QMessageBox::information(0, "Progress", "Calling setText()");
1412 // QMessageBox::information(0, "Progress", "Textset");
1413 1715
1414 // updateCaption(); 1716 reader->setText(fm.baseName(), fm.absFilePath());
1415 showEditTools(); 1717 showEditTools();
1416 reader->setText(doc->name(), doc->file());
1417 readbkmks(); 1718 readbkmks();
@@ -1420,3 +1721,3 @@ void QTReaderApp::openFile( const DocLnk &f )
1420 { 1721 {
1421 QMessageBox::information(this, "OpieReader", "File does not exist"); 1722 QMessageBox::information(this, PROGNAME, "File does not exist");
1422 } 1723 }
@@ -1424,2 +1725,44 @@ void QTReaderApp::openFile( const DocLnk &f )
1424} 1725}
1726/*
1727void QTReaderApp::resizeEvent(QResizeEvent* e)
1728{
1729 if (m_fullscreen)
1730 {
1731 showNormal();
1732 showFullScreen();
1733 }
1734}
1735*/
1736void QTReaderApp::keyPressEvent(QKeyEvent* e)
1737{
1738 if (m_fullscreen)
1739 {
1740 switch(e->key())
1741 {
1742 case Key_Escape:
1743 m_actFullscreen->setOn(false);
1744 if (m_fullscreen)
1745 {
1746 qDebug("Fullscreen already set - remove this!");
1747 }
1748 else
1749 {
1750 m_fullscreen = false;
1751 reader->bDoUpdates = false;
1752 showEditTools();
1753 qApp->processEvents();
1754 reader->bDoUpdates = true;
1755 reader->update();
1756 }
1757 e->accept();
1758 break;
1759 default:
1760 e->ignore();
1761 }
1762 }
1763 else
1764 {
1765 e->ignore();
1766 }
1767}
1425 1768
@@ -1427,15 +1770,43 @@ void QTReaderApp::showEditTools()
1427{ 1770{
1428 if ( !doc ) 1771// if ( !doc )
1429 close(); 1772 //close();
1430// fileSelector->hide(); 1773 if (m_fullscreen)
1431//tjw menu->show(); 1774 {
1775 editBar->hide();
1776 searchBar->hide();
1777 regBar->hide();
1778 Global::hideInputMethod();
1779 m_fontBar->hide();
1780 //showNormal();
1781 showFullScreen();
1782 }
1783 else
1784 {
1785 qDebug("him");
1786 Global::hideInputMethod();
1787 qDebug("eb");
1432 editBar->show(); 1788 editBar->show();
1433 if ( searchVisible ) 1789 if ( searchVisible )
1790 {
1791 Global::showInputMethod();
1434 searchBar->show(); 1792 searchBar->show();
1793 }
1435 if ( regVisible ) 1794 if ( regVisible )
1795 {
1796 Global::showInputMethod();
1436 regBar->show(); 1797 regBar->show();
1798 }
1437 if (m_fontVisible) m_fontBar->show(); 1799 if (m_fontVisible) m_fontBar->show();
1800 qDebug("sn");
1801 showNormal();
1802 qDebug("sm");
1803 showMaximized();
1804 //setCentralWidget(reader);
1805 }
1438 1806
1807 qDebug("uc");
1439 updateCaption(); 1808 updateCaption();
1809 qDebug("rw");
1440 editorStack->raiseWidget( reader ); 1810 editorStack->raiseWidget( reader );
1811 qDebug("sf");
1441 reader->setFocus(); 1812 reader->setFocus();
@@ -1475,9 +1846,9 @@ void QTReaderApp::clear()
1475{ 1846{
1476 if (doc != 0) 1847// if (doc != 0)
1477 { 1848// {
1478// QMessageBox::information(this, "QTReader", "Deleting doc", 1); 1849// QMessageBox::information(this, PROGNAME, "Deleting doc", 1);
1479 delete doc; 1850 //delete doc;
1480// QMessageBox::information(this, "QTReader", "Deleted doc", 1); 1851// QMessageBox::information(this, PROGNAME, "Deleted doc", 1);
1481 doc = 0; 1852 //doc = 0;
1482 } 1853 // }
1483 reader->clear(); 1854 reader->clear();
@@ -1487,10 +1858,10 @@ void QTReaderApp::updateCaption()
1487{ 1858{
1488 if ( !doc ) 1859// if ( !doc )
1489 setCaption( tr("OpieReader") ); 1860 //setCaption( tr("QTReader") );
1490 else { 1861// else {
1491 QString s = doc->name(); 1862 //QString s = doc->name();
1492 if ( s.isEmpty() ) 1863 //if ( s.isEmpty() )
1493 s = tr( "Unnamed" ); 1864 // s = tr( "Unnamed" );
1494 setCaption( s + " - " + tr("OpieReader") ); 1865 setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) );
1495 } 1866// }
1496} 1867}
@@ -1501,3 +1872,3 @@ void QTReaderApp::setDocument(const QString& fileref)
1501//QMessageBox::information(0, "setDocument", fileref); 1872//QMessageBox::information(0, "setDocument", fileref);
1502 openFile(DocLnk(fileref)); 1873 openFile(fileref);
1503// showEditTools(); 1874// showEditTools();
@@ -1507,3 +1878,9 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1507{ 1878{
1508 if (m_dontSave) 1879 if (m_fullscreen)
1880 {
1881 m_fullscreen = false;
1882 showEditTools();
1883 e->accept();
1884 }
1885 else if (m_dontSave)
1509 { 1886 {
@@ -1523,2 +1900,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1523 regBar->hide(); 1900 regBar->hide();
1901 Global::hideInputMethod();
1524 regVisible = false; 1902 regVisible = false;
@@ -1529,2 +1907,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1529 searchBar->hide(); 1907 searchBar->hide();
1908 Global::hideInputMethod();
1530 searchVisible = false; 1909 searchVisible = false;
@@ -1534,3 +1913,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1534 { 1913 {
1535 if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) 1914 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
1536 savebkmks(); 1915 savebkmks();
@@ -1541,2 +1920,3 @@ void QTReaderApp::closeEvent( QCloseEvent *e )
1541 bFromDocView = FALSE; 1920 bFromDocView = FALSE;
1921 updatefileinfo();
1542 saveprefs(); 1922 saveprefs();
@@ -1554,3 +1934,3 @@ void QTReaderApp::do_gotomark()
1554 m_nRegAction = cGotoBkmk; 1934 m_nRegAction = cGotoBkmk;
1555 listbkmk(); 1935 listbkmk(pBkmklist);
1556} 1936}
@@ -1560,14 +1940,19 @@ void QTReaderApp::do_delmark()
1560 m_nRegAction = cDelBkmk; 1940 m_nRegAction = cDelBkmk;
1561 listbkmk(); 1941 listbkmk(pBkmklist);
1562} 1942}
1563 1943
1564void QTReaderApp::listbkmk() 1944void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab)
1565{ 1945{
1566 bkmkselector->clear(); 1946 bkmkselector->clear();
1947 if (_lab.isNull())
1948 bkmkselector->setText("Cancel");
1949 else
1950 bkmkselector->setText(_lab);
1567 int cnt = 0; 1951 int cnt = 0;
1568 if (pBkmklist != NULL) 1952 if (plist != NULL)
1569 { 1953 {
1570 for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) 1954 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
1571 { 1955 {
1572#ifdef _UNICODE 1956#ifdef _UNICODE
1957 qDebug("Item:%s", (const char*)toQString(i->name()));
1573 bkmkselector->insertItem(toQString(i->name())); 1958 bkmkselector->insertItem(toQString(i->name()));
@@ -1584,4 +1969,12 @@ void QTReaderApp::listbkmk()
1584 if (m_fontVisible) m_fontBar->hide(); 1969 if (m_fontVisible) m_fontBar->hide();
1585 if (regVisible) regBar->hide(); 1970 if (regVisible)
1586 if (searchVisible) searchBar->hide(); 1971 {
1972 Global::hideInputMethod();
1973 regBar->hide();
1974 }
1975 if (searchVisible)
1976 {
1977 Global::hideInputMethod();
1978 searchBar->hide();
1979 }
1587 editorStack->raiseWidget( bkmkselector ); 1980 editorStack->raiseWidget( bkmkselector );
@@ -1589,3 +1982,3 @@ void QTReaderApp::listbkmk()
1589 else 1982 else
1590 QMessageBox::information(this, "OpieReader", "No bookmarks in memory"); 1983 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
1591} 1984}
@@ -1602,5 +1995,53 @@ void QTReaderApp::do_regedit()
1602// editBar->hide(); 1995// editBar->hide();
1996 reader->bDoUpdates = false;
1997 qDebug("Showing regbar");
1603 regBar->show(); 1998 regBar->show();
1999 qDebug("Showing kbd");
2000 Global::showInputMethod();
1604 regVisible = true; 2001 regVisible = true;
1605 regEdit->setFocus(); 2002 regEdit->setFocus();
2003 qApp->processEvents();
2004 reader->bDoUpdates = true;
2005 reader->update();
2006}
2007
2008bool QTReaderApp::openfrombkmk(Bkmk* bk)
2009{
2010 QString fn = toQString(
2011 CFiledata(bk->anno()).name()
2012 );
2013 qDebug("fileinfo");
2014 if (!fn.isEmpty() && QFileInfo(fn).isFile())
2015 {
2016 qDebug("Opening");
2017 openFile(fn);
2018 struct stat fnstat;
2019 stat((const char *)reader->m_lastfile, &fnstat);
2020
2021 if (CFiledata(bk->anno()).date()
2022 != fnstat.st_mtime)
2023 {
2024 CFiledata fd(bk->anno());
2025 fd.setdate(fnstat.st_mtime);
2026 bk->value(0);
2027 }
2028 else
2029 {
2030 unsigned short svlen = bk->filedatalen();
2031 unsigned char* svdata = bk->filedata();
2032 reader->putSaveData(svdata, svlen);
2033 // setstate(svdata, svlen);
2034 if (svlen != 0)
2035 {
2036 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
2037 }
2038 qDebug("updating");
2039 reader->locate(bk->value());
2040 }
2041 return true;
2042 }
2043 else
2044 {
2045 return false;
2046 }
1606} 2047}
@@ -1611,2 +2052,11 @@ void QTReaderApp::gotobkmk(int ind)
1611 { 2052 {
2053 case cOpenFile:
2054 {
2055 if (!openfrombkmk((*pOpenlist)[ind]))
2056 {
2057 pOpenlist->erase(ind);
2058 QMessageBox::information(this, PROGNAME, "Can't find file");
2059 }
2060 }
2061 break;
1612 case cGotoBkmk: 2062 case cGotoBkmk:
@@ -1621,3 +2071,3 @@ void QTReaderApp::gotobkmk(int ind)
1621 case cRmBkmkFile: 2071 case cRmBkmkFile:
1622 unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); 2072 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
1623 break; 2073 break;
@@ -1629,2 +2079,7 @@ void QTReaderApp::cancelbkmk()
1629{ 2079{
2080 if (m_nRegAction == cOpenFile)
2081 {
2082 QString fn = usefilebrowser();
2083 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
2084 }
1630 showEditTools(); 2085 showEditTools();
@@ -1648,3 +2103,3 @@ void QTReaderApp::do_jump(const QString& lcn)
1648 else 2103 else
1649 QMessageBox::information(this, "OpieReader", "Must be a number"); 2104 QMessageBox::information(this, PROGNAME, "Must be a number");
1650} 2105}
@@ -1653,3 +2108,5 @@ void QTReaderApp::do_regaction()
1653{ 2108{
2109 reader->bDoUpdates = false;
1654 regBar->hide(); 2110 regBar->hide();
2111 Global::hideInputMethod();
1655 regVisible = false; 2112 regVisible = false;
@@ -1679,2 +2136,5 @@ void QTReaderApp::do_regaction()
1679 reader->setFocus(); 2136 reader->setFocus();
2137 qApp->processEvents();
2138 reader->bDoUpdates = true;
2139 reader->update();
1680} 2140}
@@ -1688,3 +2148,3 @@ void QTReaderApp::do_settarget(const QString& _txt)
1688 m_targetmsg = ""; 2148 m_targetmsg = "";
1689 QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename"); 2149 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename");
1690 } 2150 }
@@ -1711,3 +2171,3 @@ void QTReaderApp::setfont()
1711 2171
1712void QTReaderApp::setfontHelper(const QString& lcn, int size) 2172void QTReaderApp::setfontHelper(const QString& lcn, int size = 0)
1713{ 2173{
@@ -1715,11 +2175,18 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size)
1715 QFont f(lcn, 10 /*, QFont::Bold*/); 2175 QFont f(lcn, 10 /*, QFont::Bold*/);
2176 qDebug("bs");
1716 bkmkselector->setFont( f ); 2177 bkmkselector->setFont( f );
2178 qDebug("re");
1717 regEdit->setFont( f ); 2179 regEdit->setFont( f );
2180 qDebug("se");
1718 searchEdit->setFont( f ); 2181 searchEdit->setFont( f );
2182 qDebug("aw");
1719 m_annoWin->setFont( f ); 2183 m_annoWin->setFont( f );
1720 reader->m_fontname = lcn; 2184 reader->m_fontname = lcn;
2185 qDebug("cf1");
1721 if (!reader->ChangeFont(size)) 2186 if (!reader->ChangeFont(size))
1722 { 2187 {
2188 qDebug("cf2");
1723 reader->ChangeFont(size); 2189 reader->ChangeFont(size);
1724 } 2190 }
2191 qDebug("ref");
1725 reader->refresh(); 2192 reader->refresh();
@@ -1727,3 +2194,5 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size)
1727 m_fontVisible = false; 2194 m_fontVisible = false;
1728 showEditTools(); 2195 qDebug("showedit");
2196 if (reader->isVisible()) showEditTools();
2197 qDebug("showeditdone");
1729} 2198}
@@ -1783,3 +2252,3 @@ void QTReaderApp::saveprefs()
1783// reader->saveprefs("uqtreader"); 2252// reader->saveprefs("uqtreader");
1784 Config config( "uqtreader" ); 2253 Config config( APPDIR );
1785 config.setGroup( "View" ); 2254 config.setGroup( "View" );
@@ -1793,2 +2262,3 @@ void QTReaderApp::saveprefs()
1793 config.writeEntry( "Dehyphen", reader->bdehyphen ); 2262 config.writeEntry( "Dehyphen", reader->bdehyphen );
2263 config.writeEntry( "OneSpace", reader->bonespace );
1794 config.writeEntry( "Unindent", reader->bunindent ); 2264 config.writeEntry( "Unindent", reader->bunindent );
@@ -1802,2 +2272,3 @@ void QTReaderApp::saveprefs()
1802 config.writeEntry( "PageMode", reader->m_bpagemode ); 2272 config.writeEntry( "PageMode", reader->m_bpagemode );
2273 config.writeEntry( "CursorNavigation", reader->m_navkeys );
1803 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); 2274 config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced );
@@ -1814,2 +2285,5 @@ void QTReaderApp::saveprefs()
1814 config.writeEntry( "SpaceTarget", m_spaceTarget); 2285 config.writeEntry( "SpaceTarget", m_spaceTarget);
2286#ifdef REPALM
2287 config.writeEntry( "Repalm", reader->brepalm );
2288#endif
1815 config.writeEntry( "Remap", reader->bremap ); 2289 config.writeEntry( "Remap", reader->bremap );
@@ -1817,2 +2291,5 @@ void QTReaderApp::saveprefs()
1817 config.writeEntry( "MakeBold", reader->bmakebold ); 2291 config.writeEntry( "MakeBold", reader->bmakebold );
2292 config.writeEntry( "Continuous", reader->m_continuousDocument );
2293
2294 savefilelist();
1818} 2295}
@@ -1889,3 +2366,3 @@ void QTReaderApp::savebkmks()
1889 { 2366 {
1890 BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); 2367 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true);
1891 bf.write(*pBkmklist); 2368 bf.write(*pBkmklist);
@@ -1895,2 +2372,21 @@ void QTReaderApp::savebkmks()
1895 2372
2373void QTReaderApp::readfilelist()
2374{
2375 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"));
2376 qDebug("Reading open files");
2377 pOpenlist = bf.readall();
2378 if (pOpenlist != NULL) qDebug("...with success");
2379 else qDebug("...without success!");
2380}
2381
2382void QTReaderApp::savefilelist()
2383{
2384 if (pOpenlist != NULL)
2385 {
2386 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true);
2387 qDebug("Writing open files");
2388 bf.write(*pOpenlist);
2389 }
2390}
2391
1896void QTReaderApp::readbkmks() 2392void QTReaderApp::readbkmks()
@@ -1901,3 +2397,18 @@ void QTReaderApp::readbkmks()
1901 } 2397 }
1902 BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); 2398 struct stat fnstat;
2399 struct stat bkstat;
2400 if (
2401 stat((const char *)reader->m_lastfile, &fnstat) == 0
2402 &&
2403 stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0
2404 )
2405 {
2406 if (bkstat.st_mtime < fnstat.st_mtime)
2407 {
2408 unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string));
2409 }
2410 }
2411
2412 BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string));
2413
1903 pBkmklist = bf.readall(); 2414 pBkmklist = bf.readall();
@@ -1923,3 +2434,3 @@ void QTReaderApp::do_addbkmk(const QString& text)
1923 { 2434 {
1924 QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nSelect add again", 1); 2435 QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1);
1925 } 2436 }
@@ -1959,2 +2470,3 @@ void QTReaderApp::showAnnotation()
1959 m_annoIsEditing = false; 2470 m_annoIsEditing = false;
2471 Global::showInputMethod();
1960 editorStack->raiseWidget( m_annoWin ); 2472 editorStack->raiseWidget( m_annoWin );
@@ -1987,2 +2499,3 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
1987 m_annoIsEditing = true; 2499 m_annoIsEditing = true;
2500 Global::showInputMethod();
1988 editorStack->raiseWidget( m_annoWin ); 2501 editorStack->raiseWidget( m_annoWin );
@@ -2019,2 +2532,7 @@ void QTReaderApp::OnActionPressed()
2019 break; 2532 break;
2533 case cesFullScreen:
2534 {
2535 m_actFullscreen->setOn(true);
2536 }
2537 break;
2020 default: 2538 default:
@@ -2029 +2547,60 @@ void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); }
2029void QTReaderApp::restoreFocus() { reader->setFocus(); } 2547void QTReaderApp::restoreFocus() { reader->setFocus(); }
2548
2549/*
2550void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen)
2551{
2552 unsigned short sdlen;
2553 memcpy(&sdlen, _sd, sizeof(sdlen));
2554 sdlen -= sizeof(sdlen);
2555 _sd += sizeof(sdlen);
2556 statedata* sd;
2557 char* data;
2558 if (sdlen < sizeof(statedata)+1)
2559 {
2560 sdlen = sizeof(statedata)+1;
2561 }
2562 data = new char[sdlen];
2563 sd = (statedata*)data;
2564 memcpy(sd, _sd, sdlen);
2565 data[sdlen] = 0;
2566 reader->setstate(*sd);
2567 delete [] data;
2568}
2569
2570void QTReaderApp::getstate(unsigned char*& data, unsigned short& len)
2571{
2572 unsigned char* olddata = data;
2573 unsigned short oldlen = len;
2574 len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length();
2575 data = new unsigned char[len];
2576 memcpy(data, olddata, oldlen);
2577 delete [] olddata;
2578 memcpy(data+oldlen, &len, sizeof(len));
2579 statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short));
2580
2581 sd->bstripcr = reader->bstripcr;
2582 sd->btextfmt = reader->btextfmt;
2583 sd->bautofmt = reader->bautofmt;
2584 sd->bstriphtml = reader->bstriphtml;
2585 sd->bpeanut = reader->bpeanut;
2586 sd->bdehyphen = reader->bdehyphen;
2587 sd->bonespace = reader->bonespace;
2588 sd->bunindent = reader->bunindent;
2589 sd->brepara = reader->brepara;
2590 sd->bdblspce = reader->bdblspce;
2591 sd->m_bpagemode = reader->m_bpagemode;
2592 sd->m_navkeys = reader->m_navkeys;
2593 sd->m_bMonoSpaced = reader->m_bMonoSpaced;
2594 sd->bremap = reader->bremap;
2595 sd->bmakebold = reader->bmakebold;
2596 sd->Continuous = reader->m_continuousDocument;
2597#ifdef REPALM
2598 sd->brepalm = reader->brepalm;
2599#endif
2600 sd->bindenter = reader->bindenter;
2601 sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize()
2602 sd->m_encd = reader->m_encd;
2603 sd->m_charpc = reader->m_charpc;
2604 strcpy(sd->m_fontname, reader->m_fontname.latin1());
2605}
2606*/