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
@@ -12,129 +12,155 @@
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qclipboard.h> 21#include <qclipboard.h>
22#include <qwidgetstack.h> 22#include <qwidgetstack.h>
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>
26#include <qcombobox.h> 29#include <qcombobox.h>
27#include <qpopupmenu.h> 30#include <qpopupmenu.h>
28#include <qaction.h> 31#include <qaction.h>
29#include <qapplication.h> 32#include <qapplication.h>
30#include <qlineedit.h> 33#include <qlineedit.h>
31#include <qtoolbutton.h> 34#include <qtoolbutton.h>
32#include <qspinbox.h> 35#include <qspinbox.h>
33#include <qobjectlist.h> 36#include <qobjectlist.h>
34#include <qpe/global.h> 37#include <qpe/global.h>
35#include <qpe/applnk.h> 38#include <qpe/applnk.h>
36#include <qfileinfo.h> 39#include <qfileinfo.h>
37#include <stdlib.h> //getenv 40#include <stdlib.h> //getenv
38#include <qprogressbar.h> 41#include <qprogressbar.h>
39#include <qpe/config.h> 42#include <qpe/config.h>
40#include <qbuttongroup.h> 43#include <qbuttongroup.h>
41#include <qradiobutton.h> 44#include <qradiobutton.h>
42#include <qpe/qcopenvelope_qws.h> 45#include <qpe/qcopenvelope_qws.h>
43 46
44#include "QTReader.h" 47#include "QTReader.h"
48#include "GraphicWin.h"
45#include "Bkmks.h" 49#include "Bkmks.h"
46#include "cbkmkselector.h" 50#include "cbkmkselector.h"
47#include "infowin.h" 51#include "infowin.h"
48#include "CAnnoEdit.h" 52#include "CAnnoEdit.h"
49#include "QFloatBar.h" 53#include "QFloatBar.h"
50//#include <qpe/fontdatabase.h> 54//#include <qpe/fontdatabase.h>
51 55
52#include <qpe/resource.h> 56#include <qpe/resource.h>
53#include <qpe/qpeapplication.h> 57#include <qpe/qpeapplication.h>
54 58
55#include "QTReaderApp.h" 59#include "QTReaderApp.h"
56#include "fileBrowser.h" 60#include "fileBrowser.h"
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
59 73
60unsigned long QTReaderApp::m_uid = 0; 74unsigned long QTReaderApp::m_uid = 0;
61 75
62void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } 76void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
63 77
64#include <unistd.h> 78#include <unistd.h>
65#include <stddef.h> 79#include <stddef.h>
66#include <dirent.h> 80#include <dirent.h>
67 81
68void QTReaderApp::listBkmkFiles() 82void QTReaderApp::listBkmkFiles()
69{ 83{
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
75 while(1) 90 while(1)
76 { 91 {
77 struct dirent* de; 92 struct dirent* de;
78 struct stat buf; 93 struct stat buf;
79 de = readdir(d); 94 de = readdir(d);
80 if (de == NULL) break; 95 if (de == NULL) break;
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 {
84 bkmkselector->insertItem(de->d_name); 99 bkmkselector->insertItem(de->d_name);
85 cnt++; 100 cnt++;
86 } 101 }
87 } 102 }
88 103
89 closedir(d); 104 closedir(d);
90 105
91 if (cnt > 0) 106 if (cnt > 0)
92 { 107 {
93//tjw menu->hide(); 108//tjw menu->hide();
94 editBar->hide(); 109 editBar->hide();
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;
99 editorStack->raiseWidget( bkmkselector ); 122 editorStack->raiseWidget( bkmkselector );
100 } 123 }
101 else 124 else
102 QMessageBox::information(this, "OpieReader", "No bookmark files"); 125 QMessageBox::information(this, PROGNAME, "No bookmark files");
103} 126}
104 127
105QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 128QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
106 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false) 129 : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false)
107{ 130{
108// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); 131// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir());
109// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); 132// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml"));
110 133
111 pBkmklist = NULL; 134 pBkmklist = NULL;
112 doc = 0; 135 pOpenlist = NULL;
136// doc = 0;
113 137
114 m_fBkmksChanged = false; 138 m_fBkmksChanged = false;
115 139
116 QString lang = getenv( "LANG" ); 140 QString lang = getenv( "LANG" );
117 141
118 m_autogenstr = "^ *[A-Z].*[a-z] *$"; 142 m_autogenstr = "^ *[A-Z].*[a-z] *$";
119 setToolBarsMovable( FALSE ); 143 setToolBarsMovable( FALSE );
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 );
125 addToolBar(bar, "tool",QMainWindow::Top, true); 150 addToolBar(bar, "tool",QMainWindow::Top, true);
126//tjw menu = bar; 151//tjw menu = bar;
127 152
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 );
130 QPopupMenu *format = new QPopupMenu( this ); 156 QPopupMenu *format = new QPopupMenu( this );
131 // QPopupMenu *edit = new QPopupMenu( this ); 157 // QPopupMenu *edit = new QPopupMenu( this );
132 158
133// bar = new QToolBar( this ); 159// bar = new QToolBar( this );
134 editBar = bar; 160 editBar = bar;
135 161
136 /* 162 /*
137 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 163 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
138 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
139 a->addTo( bar ); 165 a->addTo( bar );
140 a->addTo( file ); 166 a->addTo( file );
@@ -150,90 +176,112 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
150 pbar = new QProgressBar(this); 176 pbar = new QProgressBar(this);
151 pbar->hide(); 177 pbar->hide();
152 178
153 m_annoWin = new CAnnoEdit(editorStack); 179 m_annoWin = new CAnnoEdit(editorStack);
154 editorStack->addWidget(m_annoWin, get_unique_id()); 180 editorStack->addWidget(m_annoWin, get_unique_id());
155 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); 181 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) );
156 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); 182 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) );
157 183
158 m_infoWin = new infowin(editorStack); 184 m_infoWin = new infowin(editorStack);
159 editorStack->addWidget(m_infoWin, get_unique_id()); 185 editorStack->addWidget(m_infoWin, get_unique_id());
160 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); 186 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) );
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");
163 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); 193 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
164 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); 194 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
165 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); 195 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
166 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); 196 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
167 editorStack->addWidget( bkmkselector, get_unique_id() ); 197 editorStack->addWidget( bkmkselector, get_unique_id() );
168 198
169/* 199/*
170 importSelector = new FileSelector( "*", editorStack, "importselector", false ); 200 importSelector = new FileSelector( "*", editorStack, "importselector", false );
171 connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); 201 connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) );
172 202
173 editorStack->addWidget( importSelector, get_unique_id() ); 203 editorStack->addWidget( importSelector, get_unique_id() );
174 204
175 // don't need the close visible, it is redundant... 205 // don't need the close visible, it is redundant...
176 importSelector->setCloseVisible( FALSE ); 206 importSelector->setCloseVisible( FALSE );
177*/ 207*/
208 qDebug("Reading file list");
209 readfilelist();
178 210
179 reader = new QTReader( editorStack ); 211 reader = new QTReader( editorStack );
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" );
185 220
186 reader->bstripcr = config.readBoolEntry( "StripCr", true ); 221 reader->bstripcr = config.readBoolEntry( "StripCr", true );
187 reader->btextfmt = config.readBoolEntry( "TextFmt", false ); 222 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
188 reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); 223 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
189 reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); 224 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
190 reader->bpeanut = config.readBoolEntry( "Peanut", false ); 225 reader->bpeanut = config.readBoolEntry( "Peanut", false );
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 );
193 reader->brepara = config.readBoolEntry( "Repara", false ); 229 reader->brepara = config.readBoolEntry( "Repara", false );
194 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); 230 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
195 reader->bindenter = config.readNumEntry( "Indent", 0 ); 231 reader->bindenter = config.readNumEntry( "Indent", 0 );
196 reader->m_textsize = config.readNumEntry( "FontSize", 12 ); 232 reader->m_textsize = config.readNumEntry( "FontSize", 12 );
197 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); 233 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
198 reader->m_lastfile = config.readEntry( "LastFile", QString::null ); 234 reader->m_lastfile = config.readEntry( "LastFile", QString::null );
199 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); 235 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
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);
202 reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); 239 reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
203 reader->m_encd = config.readNumEntry( "Encoding", 0 ); 240 reader->m_encd = config.readNumEntry( "Encoding", 0 );
204 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); 241 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
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 );
209 m_targetmsg = config.readEntry( "TargetMsg", QString::null ); 250 m_targetmsg = config.readEntry( "TargetMsg", QString::null );
210 m_twoTouch = config.readBoolEntry( "TwoTouch", false); 251 m_twoTouch = config.readBoolEntry( "TwoTouch", false);
211 m_doAnnotation = config.readBoolEntry( "Annotation", false); 252 m_doAnnotation = config.readBoolEntry( "Annotation", false);
212 m_doDictionary = config.readBoolEntry( "Dictionary", false); 253 m_doDictionary = config.readBoolEntry( "Dictionary", false);
213 m_doClipboard = config.readBoolEntry( "Clipboard", false); 254 m_doClipboard = config.readBoolEntry( "Clipboard", false);
214 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); 255 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
215 setTwoTouch(m_twoTouch); 256 setTwoTouch(m_twoTouch);
216 257
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() ) );
219 connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) ); 262 connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) );
220 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); 263 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) );
221 editorStack->addWidget( reader, get_unique_id() ); 264 editorStack->addWidget( reader, get_unique_id() );
222 265
223 QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 266 QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
224 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 267 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
225 a->addTo( bar ); 268 a->addTo( bar );
226 a->addTo( file ); 269 a->addTo( file );
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 /*
229 a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 277 a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
230 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); 278 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
231 a->addTo( file ); 279 a->addTo( file );
232 280
233 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 281 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
234 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 282 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
235 a->addTo( editBar ); 283 a->addTo( editBar );
236 a->addTo( edit ); 284 a->addTo( edit );
237 */ 285 */
238 286
239 a = new QAction( tr( "Info" ), QString::null, 0, this, NULL); 287 a = new QAction( tr( "Info" ), QString::null, 0, this, NULL);
@@ -241,73 +289,83 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
241 a->addTo( file ); 289 a->addTo( file );
242 290
243 QActionGroup* ag = new QActionGroup(this); 291 QActionGroup* ag = new QActionGroup(this);
244 QPopupMenu *spacemenu = new QPopupMenu(this); 292 QPopupMenu *spacemenu = new QPopupMenu(this);
245 file->insertItem( tr( "On Action..." ), spacemenu ); 293 file->insertItem( tr( "On Action..." ), spacemenu );
246 294
247 m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true ); 295 m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true );
248 296
249 m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true ); 297 m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true );
250 298
251 m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); 299 m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true );
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);
254 304
255 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); 305 connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) );
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
266 /* 336 /*
267 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); 337 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
268 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 338 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
269 a->addTo( file ); 339 a->addTo( file );
270 340
271 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); 341 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true );
272 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 342 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
273 a->addTo( file ); 343 a->addTo( file );
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
288 file->insertSeparator(); 346 file->insertSeparator();
289 347
290 a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); 348 a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL);
291 connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) ); 349 connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) );
292 a->addTo( file ); 350 a->addTo( file );
293 351
294 a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true ); 352 a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true );
295 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); 353 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
296 a->setOn(m_twoTouch); 354 a->setOn(m_twoTouch);
297 a->addTo( file ); 355 a->addTo( file );
298 356
299 ag = new QActionGroup(this); 357 ag = new QActionGroup(this);
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 );
303 361
304 a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true ); 362 a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true );
305 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) ); 363 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) );
306 a->setOn(m_doAnnotation); 364 a->setOn(m_doAnnotation);
307 365
308 a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true ); 366 a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true );
309 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) ); 367 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) );
310 a->setOn(m_doDictionary); 368 a->setOn(m_doDictionary);
311 369
312 a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true ); 370 a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true );
313 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) ); 371 connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) );
@@ -336,24 +394,35 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
336 a->addTo( editBar ); 394 a->addTo( editBar );
337 a->addTo( edit ); 395 a->addTo( edit );
338 */ 396 */
339 397
340// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 398// a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
341 a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL); 399 a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL);
342 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 400 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
343 file->insertSeparator(); 401 file->insertSeparator();
344// a->addTo( bar ); 402// a->addTo( bar );
345 a->addTo( file ); 403 a->addTo( file );
346 404
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 );
349 connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); 418 connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) );
350 a->addTo( bar ); 419 a->addTo( bar );
351 420
352 m_bkmkAvail->setEnabled(false); 421 m_bkmkAvail->setEnabled(false);
353 422
354 423
355 ag = new QActionGroup(this); 424 ag = new QActionGroup(this);
356// ag->setExclusive(false); 425// ag->setExclusive(false);
357 encoding = new QPopupMenu(this); 426 encoding = new QPopupMenu(this);
358 format->insertItem( tr( "Markup" ), encoding ); 427 format->insertItem( tr( "Markup" ), encoding );
359 428
@@ -386,69 +455,80 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
386 encoding = new QPopupMenu(this); 455 encoding = new QPopupMenu(this);
387 format->insertItem( tr( "Layout" ), encoding ); 456 format->insertItem( tr( "Layout" ), encoding );
388 457
389 a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true ); 458 a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true );
390 a->setOn(reader->bstripcr); 459 a->setOn(reader->bstripcr);
391 connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); 460 connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) );
392 461
393 a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true ); 462 a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true );
394 a->setOn(reader->bdehyphen); 463 a->setOn(reader->bdehyphen);
395 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); 464 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) );
396// a->addTo( format ); 465// a->addTo( format );
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 );
399 connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); 472 connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) );
400 a->setOn(reader->bunindent); 473 a->setOn(reader->bunindent);
401// a->addTo( format ); 474// a->addTo( format );
402 475
403 a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true ); 476 a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true );
404 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); 477 connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) );
405 a->setOn(reader->brepara); 478 a->setOn(reader->brepara);
406// a->addTo( format ); 479// a->addTo( format );
407 480
408 a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true ); 481 a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true );
409 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); 482 connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) );
410 a->setOn(reader->bdblspce); 483 a->setOn(reader->bdblspce);
411// a->addTo( format ); 484// a->addTo( format );
412 485
413 a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL ); 486 a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL );
414 connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); 487 connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) );
415// a->addTo( format ); 488// a->addTo( format );
416 489
417 a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); 490 a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL );
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 );
421 connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); 498 connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) );
422 a->setOn(reader->bremap); 499 a->setOn(reader->bremap);
423 500
424 a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true ); 501 a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true );
425 connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) ); 502 connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) );
426 a->setOn(reader->bmakebold); 503 a->setOn(reader->bmakebold);
427 504
428 ag->addTo(encoding); 505 ag->addTo(encoding);
429 506
430 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); 507 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
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
438 519
439 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); 520 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
440 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); 521 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
441 a->setOn(reader->m_bMonoSpaced); 522 a->setOn(reader->m_bMonoSpaced);
442 format->insertSeparator();
443 a->addTo( format ); 523 a->addTo( format );
444 524
445 a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL); 525 a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL);
446 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); 526 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
447 a->addTo( format ); 527 a->addTo( format );
448 528
449 encoding = new QPopupMenu(this); 529 encoding = new QPopupMenu(this);
450// format->insertSeparator(); 530// format->insertSeparator();
451 format->insertItem( tr( "Encoding" ), encoding ); 531 format->insertItem( tr( "Encoding" ), encoding );
452 532
453 ag = new QActionGroup(this); 533 ag = new QActionGroup(this);
454 534
@@ -570,82 +650,131 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
570 a->addTo( regBar ); 650 a->addTo( regBar );
571 651
572 a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 652 a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
573 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); 653 connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) );
574 a->addTo( regBar ); 654 a->addTo( regBar );
575 655
576 regBar->hide(); 656 regBar->hide();
577 657
578 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); 658 m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE );
579 659
580 m_fontBar->setHorizontalStretchable( TRUE ); 660 m_fontBar->setHorizontalStretchable( TRUE );
581 661
662 qDebug("Font selector");
582 m_fontSelector = new QComboBox(false, m_fontBar); 663 m_fontSelector = new QComboBox(false, m_fontBar);
583 m_fontBar->setStretchableWidget( m_fontSelector ); 664 m_fontBar->setStretchableWidget( m_fontSelector );
584 { 665 {
585 FontDatabase f; 666 FontDatabase f;
586 QStringList flist = f.families(); 667 QStringList flist = f.families();
587 m_fontSelector->insertStringList(flist); 668 m_fontSelector->insertStringList(flist);
588 669
589 bool realfont = false; 670 bool realfont = false;
590 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) 671 for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++)
591 { 672 {
592 if (reader->m_fontname == *nm) 673 if (reader->m_fontname == *nm)
593 { 674 {
594 realfont = true; 675 realfont = true;
595 break;
596 } 676 }
677 if (*nm == "courier") reader->m_fontControl.hasCourier(true);
597 } 678 }
598 if (!realfont) reader->m_fontname = flist[0]; 679 if (!realfont) reader->m_fontname = flist[0];
599 } // delete the FontDatabase!!! 680 } // delete the FontDatabase!!!
600 681
601 connect( m_fontSelector, SIGNAL( activated(const QString& ) ), 682 connect( m_fontSelector, SIGNAL( activated(const QString& ) ),
602 this, SLOT( do_setfont(const QString&) ) ); 683 this, SLOT( do_setfont(const QString&) ) );
603 684
604 m_fontBar->hide(); 685 m_fontBar->hide();
605 m_fontVisible = false; 686 m_fontVisible = false;
606 687
607 connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), 688 connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ),
608 this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); 689 this, SLOT( msgHandler(const QCString&, const QByteArray&) ) );
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
622void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) 751void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
623{ 752{
624 QString msg = QString::fromUtf8(_msg); 753 QString msg = QString::fromUtf8(_msg);
625 754
626// qDebug("Received:%s", (const char*)msg); 755// qDebug("Received:%s", (const char*)msg);
627 756
628 QDataStream stream( _data, IO_ReadOnly ); 757 QDataStream stream( _data, IO_ReadOnly );
629 if ( msg == "info(QString)" ) 758 if ( msg == "info(QString)" )
630 { 759 {
631 QString info; 760 QString info;
632 stream >> info; 761 stream >> info;
633 QMessageBox::information(this, "OpieReader", info); 762 QMessageBox::information(this, PROGNAME, info);
634 } 763 }
635 else if ( msg == "warn(QString)" ) 764 else if ( msg == "warn(QString)" )
636 { 765 {
637 QString info; 766 QString info;
638 stream >> info; 767 stream >> info;
639 QMessageBox::warning(this, "OpieReader", info); 768 QMessageBox::warning(this, PROGNAME, info);
640 } 769 }
641 770
642 771
643 else if ( msg == "exit()" ) 772 else if ( msg == "exit()" )
644 { 773 {
645 m_dontSave = true; 774 m_dontSave = true;
646 close(); 775 close();
647 } 776 }
648 else if ( msg == "pageDown()" ) 777 else if ( msg == "pageDown()" )
649 { 778 {
650 reader->dopagedn(); 779 reader->dopagedn();
651 } 780 }
@@ -742,37 +871,51 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
742 QString info; 871 QString info;
743 stream >> info; 872 stream >> info;
744 QRegExp arg(info); 873 QRegExp arg(info);
745 size_t pos = reader->pagelocate(); 874 size_t pos = reader->pagelocate();
746 size_t start = pos; 875 size_t start = pos;
747 CDrawBuffer test(&(reader->m_fontControl)); 876 CDrawBuffer test(&(reader->m_fontControl));
748 reader->buffdoc.getline(&test,reader->width()); 877 reader->buffdoc.getline(&test,reader->width());
749 while (arg.match(toQString(test.data())) == -1) 878 while (arg.match(toQString(test.data())) == -1)
750 { 879 {
751 pos = reader->locate(); 880 pos = reader->locate();
752 if (!reader->buffdoc.getline(&test,reader->width())) 881 if (!reader->buffdoc.getline(&test,reader->width()))
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;
756 break; 885 break;
757 } 886 }
758 } 887 }
759 reader->locate(pos); 888 reader->locate(pos);
760 } 889 }
761 else if ( msg == "Layout/Strip CR(int)" ) 890 else if ( msg == "Layout/Strip CR(int)" )
762 { 891 {
763 int info; 892 int info;
764 stream >> info; 893 stream >> info;
765 stripcr(info); 894 stripcr(info);
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)" )
768 { 911 {
769 int info; 912 int info;
770 stream >> info; 913 stream >> info;
771 autofmt(info); 914 autofmt(info);
772 } 915 }
773 else if ( msg == "Markup/Text(int)" ) 916 else if ( msg == "Markup/Text(int)" )
774 { 917 {
775 int info; 918 int info;
776 stream >> info; 919 stream >> info;
777 textfmt(info); 920 textfmt(info);
778 } 921 }
@@ -867,24 +1010,40 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data)
867 } 1010 }
868} 1011}
869 1012
870ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) 1013ActionTypes QTReaderApp::ActNameToInt(const QString& _enc)
871{ 1014{
872 for (int i = 0; i < MAX_ACTIONS; i++) 1015 for (int i = 0; i < MAX_ACTIONS; i++)
873 { 1016 {
874 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; 1017 if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i;
875 } 1018 }
876 return cesAutoScroll; 1019 return cesAutoScroll;
877} 1020}
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)
880{ 1039{
881 for (int i = 0; i < MAX_ENCODING; i++) 1040 for (int i = 0; i < MAX_ENCODING; i++)
882 { 1041 {
883 if (m_EncodingAction[i]->text() == _enc) return i; 1042 if (m_EncodingAction[i]->text() == _enc) return i;
884 } 1043 }
885 return 0; 1044 return 0;
886/* 1045/*
887 if (_enc == "Ascii") return 0; 1046 if (_enc == "Ascii") return 0;
888 if (_enc == "UTF-8") return 1; 1047 if (_enc == "UTF-8") return 1;
889 if (_enc == "UCS-2(BE)") return 2; 1048 if (_enc == "UCS-2(BE)") return 2;
890 if (_enc == "USC-2(LE)") return 3; 1049 if (_enc == "USC-2(LE)") return 3;
@@ -901,88 +1060,195 @@ void QTReaderApp::buttonActionSelected(QAction* _a)
901{ 1060{
902// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); 1061// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text()));
903 m_spaceTarget = ActNameToInt(_a->text()); 1062 m_spaceTarget = ActNameToInt(_a->text());
904} 1063}
905 1064
906QTReaderApp::~QTReaderApp() 1065QTReaderApp::~QTReaderApp()
907{ 1066{
908} 1067}
909 1068
910void QTReaderApp::autoScroll(bool _b) 1069void QTReaderApp::autoScroll(bool _b)
911{ 1070{
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}
924 1084
925void QTReaderApp::clearBkmkList() 1085void QTReaderApp::clearBkmkList()
926{ 1086{
927 delete pBkmklist; 1087 delete pBkmklist;
928 pBkmklist = NULL; 1088 pBkmklist = NULL;
929 m_fBkmksChanged = false; 1089 m_fBkmksChanged = false;
930} 1090}
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()
933{ 1165{
934/* 1166/*
935 menu->hide(); 1167 menu->hide();
936 editBar->hide(); 1168 editBar->hide();
937 if (regVisible) regBar->hide(); 1169 if (regVisible) regBar->hide();
938 if (searchVisible) searchBar->hide(); 1170 if (searchVisible) searchBar->hide();
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)
941 { 1181 {
942 if (m_fBkmksChanged) 1182 if (m_fBkmksChanged)
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();
946 } 1186 }
947 delete pBkmklist; 1187 delete pBkmklist;
948 pBkmklist = NULL; 1188 pBkmklist = NULL;
949 m_fBkmksChanged = false; 1189 m_fBkmksChanged = false;
950 } 1190 }
951 reader->disableAutoscroll(); 1191 reader->disableAutoscroll();
952/* 1192/*
953 editorStack->raiseWidget( fileSelector ); 1193 editorStack->raiseWidget( fileSelector );
954 fileSelector->reread(); 1194 fileSelector->reread();
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,
958// WStyle_Customize | WStyle_NoBorderEx, 1216// WStyle_Customize | WStyle_NoBorderEx,
959 "*", QFileInfo(reader->m_lastfile).dirPath(true)); 1217 "*", QFileInfo(reader->m_lastfile).dirPath(true));
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}
970 1236
971void QTReaderApp::showinfo() 1237void QTReaderApp::showinfo()
972{ 1238{
973 unsigned long fs, ts, pl; 1239 unsigned long fs, ts, pl;
974 if (reader->empty()) 1240 if (reader->empty())
975 { 1241 {
976 QMessageBox::information(this, "OpieReader", "No file loaded", 1); 1242 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
977 } 1243 }
978 else 1244 else
979 { 1245 {
980 reader->sizes(fs,ts); 1246 reader->sizes(fs,ts);
981 pl = reader->pagelocate(); 1247 pl = reader->pagelocate();
982 m_infoWin->setFileSize(fs); 1248 m_infoWin->setFileSize(fs);
983 m_infoWin->setTextSize(ts); 1249 m_infoWin->setTextSize(ts);
984 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); 1250 m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts);
985 m_infoWin->setLocation(pl); 1251 m_infoWin->setLocation(pl);
986 m_infoWin->setRead((100*pl + (ts >> 1))/ts); 1252 m_infoWin->setRead((100*pl + (ts >> 1))/ts);
987 editorStack->raiseWidget( m_infoWin ); 1253 editorStack->raiseWidget( m_infoWin );
988 m_infoWin->setFocus(); 1254 m_infoWin->setFocus();
@@ -1011,25 +1277,25 @@ void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn)
1011 pBkmklist->push_front(Bkmk((const tchar*)text,posn)); 1277 pBkmklist->push_front(Bkmk((const tchar*)text,posn));
1012#endif 1278#endif
1013 m_fBkmksChanged = true; 1279 m_fBkmksChanged = true;
1014 pBkmklist->sort(); 1280 pBkmklist->sort();
1015} 1281}
1016 1282
1017void QTReaderApp::addAnno(const QString& name, const QString& text) 1283void QTReaderApp::addAnno(const QString& name, const QString& text)
1018{ 1284{
1019 if (m_annoIsEditing) 1285 if (m_annoIsEditing)
1020 { 1286 {
1021 if (name.isEmpty()) 1287 if (name.isEmpty())
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 }
1025 else 1291 else
1026 { 1292 {
1027 addAnno(name, text, m_annoWin->getPosn()); 1293 addAnno(name, text, m_annoWin->getPosn());
1028 } 1294 }
1029 showEditTools(); 1295 showEditTools();
1030 } 1296 }
1031 else 1297 else
1032 { 1298 {
1033 if (m_annoWin->edited()) 1299 if (m_annoWin->edited())
1034 { 1300 {
1035 CBuffer buff(text.length()+1); 1301 CBuffer buff(text.length()+1);
@@ -1068,33 +1334,34 @@ bool QTReaderApp::findNextBookmark(size_t start)
1068 m_anno = iter.pContent(); 1334 m_anno = iter.pContent();
1069 } 1335 }
1070 break; 1336 break;
1071 } 1337 }
1072 } 1338 }
1073 return found; 1339 return found;
1074} 1340}
1075 1341
1076void QTReaderApp::addanno() 1342void QTReaderApp::addanno()
1077{ 1343{
1078 if (reader->empty()) 1344 if (reader->empty())
1079 { 1345 {
1080 QMessageBox::information(this, "OpieReader", "No file loaded", 1); 1346 QMessageBox::information(this, PROGNAME, "No file loaded", 1);
1081 } 1347 }
1082 else 1348 else
1083 { 1349 {
1084 m_annoWin->setName(""); 1350 m_annoWin->setName("");
1085 m_annoWin->setAnno(""); 1351 m_annoWin->setAnno("");
1086 m_annoWin->setPosn(reader->pagelocate()); 1352 m_annoWin->setPosn(reader->pagelocate());
1087 m_annoIsEditing = true; 1353 m_annoIsEditing = true;
1088 editorStack->raiseWidget( m_annoWin ); 1354 editorStack->raiseWidget( m_annoWin );
1355 Global::showInputMethod();
1089 m_annoWin->setFocus(); 1356 m_annoWin->setFocus();
1090 } 1357 }
1091} 1358}
1092 1359
1093void QTReaderApp::infoClose() 1360void QTReaderApp::infoClose()
1094{ 1361{
1095 showEditTools(); 1362 showEditTools();
1096} 1363}
1097 1364
1098/* 1365/*
1099void QTReaderApp::fileRevert() 1366void QTReaderApp::fileRevert()
1100{ 1367{
@@ -1123,36 +1390,46 @@ void QTReaderApp::editCopy()
1123 unsigned long endpos = reader->locate(); 1390 unsigned long endpos = reader->locate();
1124 reader->jumpto(m_savedpos); 1391 reader->jumpto(m_savedpos);
1125 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) 1392 while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF)
1126 { 1393 {
1127 text += ch; 1394 text += ch;
1128 } 1395 }
1129 cb->setText(text); 1396 cb->setText(text);
1130 reader->locate(currentpos); 1397 reader->locate(currentpos);
1131} 1398}
1132 1399
1133void QTReaderApp::pageup() 1400void QTReaderApp::pageup()
1134{ 1401{
1135 reader->goUp(); 1402 reader->NavUp();
1136} 1403}
1137 1404
1138void QTReaderApp::pagedn() 1405void QTReaderApp::pagedn()
1139{ 1406{
1140 reader->goDown(); 1407 reader->NavDown();
1141} 1408}
1142 1409
1143void QTReaderApp::stripcr(bool _b) 1410void QTReaderApp::stripcr(bool _b)
1144{ 1411{
1145 reader->setstripcr(_b); 1412 reader->setstripcr(_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)
1148{ 1425{
1149 reader->setremap(_b); 1426 reader->setremap(_b);
1150} 1427}
1151void QTReaderApp::peanut(bool _b) 1428void QTReaderApp::peanut(bool _b)
1152{ 1429{
1153 reader->setpeanut(_b); 1430 reader->setpeanut(_b);
1154} 1431}
1155void QTReaderApp::embolden(bool _b) 1432void QTReaderApp::embolden(bool _b)
1156{ 1433{
1157 reader->setmakebold(_b); 1434 reader->setmakebold(_b);
1158} 1435}
@@ -1179,25 +1456,28 @@ void QTReaderApp::unindent(bool _b)
1179void QTReaderApp::repara(bool _b) 1456void QTReaderApp::repara(bool _b)
1180{ 1457{
1181 reader->setrepara(_b); 1458 reader->setrepara(_b);
1182} 1459}
1183void QTReaderApp::dblspce(bool _b) 1460void QTReaderApp::dblspce(bool _b)
1184{ 1461{
1185 reader->setdblspce(_b); 1462 reader->setdblspce(_b);
1186} 1463}
1187void QTReaderApp::pagemode(bool _b) 1464void QTReaderApp::pagemode(bool _b)
1188{ 1465{
1189 reader->setpagemode(_b); 1466 reader->setpagemode(_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)
1193{ 1473{
1194 reader->setmono(_b); 1474 reader->setmono(_b);
1195} 1475}
1196 1476
1197void QTReaderApp::setspacing() 1477void QTReaderApp::setspacing()
1198{ 1478{
1199 m_nRegAction = cMonoSpace; 1479 m_nRegAction = cMonoSpace;
1200 char lcn[20]; 1480 char lcn[20];
1201 sprintf(lcn, "%lu", reader->m_charpc); 1481 sprintf(lcn, "%lu", reader->m_charpc);
1202 regEdit->setText(lcn); 1482 regEdit->setText(lcn);
1203 do_regedit(); 1483 do_regedit();
@@ -1222,57 +1502,58 @@ void QTReaderApp::settarget()
1222 do_regedit(); 1502 do_regedit();
1223} 1503}
1224 1504
1225void QTReaderApp::do_overlap(const QString& lcn) 1505void QTReaderApp::do_overlap(const QString& lcn)
1226{ 1506{
1227 bool ok; 1507 bool ok;
1228 unsigned long ulcn = lcn.toULong(&ok); 1508 unsigned long ulcn = lcn.toULong(&ok);
1229 if (ok) 1509 if (ok)
1230 { 1510 {
1231 reader->m_overlap = ulcn; 1511 reader->m_overlap = ulcn;
1232 } 1512 }
1233 else 1513 else
1234 QMessageBox::information(this, "OpieReader", "Must be a number"); 1514 QMessageBox::information(this, PROGNAME, "Must be a number");
1235} 1515}
1236 1516
1237void QTReaderApp::do_mono(const QString& lcn) 1517void QTReaderApp::do_mono(const QString& lcn)
1238{ 1518{
1239 bool ok; 1519 bool ok;
1240 unsigned long ulcn = lcn.toULong(&ok); 1520 unsigned long ulcn = lcn.toULong(&ok);
1241 if (ok) 1521 if (ok)
1242 { 1522 {
1243 reader->m_charpc = ulcn; 1523 reader->m_charpc = ulcn;
1244 reader->setfont(); 1524 reader->setfont();
1245 reader->refresh(); 1525 reader->refresh();
1246// reader->setmono(true); 1526// reader->setmono(true);
1247 } 1527 }
1248 else 1528 else
1249 QMessageBox::information(this, "OpieReader", "Must be a number"); 1529 QMessageBox::information(this, PROGNAME, "Must be a number");
1250} 1530}
1251 1531
1252/* 1532/*
1253void QTReaderApp::editPaste() 1533void QTReaderApp::editPaste()
1254{ 1534{
1255#ifndef QT_NO_CLIPBOARD 1535#ifndef QT_NO_CLIPBOARD
1256 editor->paste(); 1536 editor->paste();
1257#endif 1537#endif
1258} 1538}
1259*/ 1539*/
1260 1540
1261void QTReaderApp::editFind() 1541void QTReaderApp::editFind()
1262{ 1542{
1263 searchStart = reader->pagelocate(); 1543 searchStart = reader->pagelocate();
1264#ifdef __ISEARCH 1544#ifdef __ISEARCH
1265 searchStack = new QStack<searchrecord>; 1545 searchStack = new QStack<searchrecord>;
1266#endif 1546#endif
1547 Global::showInputMethod();
1267 searchBar->show(); 1548 searchBar->show();
1268 searchVisible = TRUE; 1549 searchVisible = TRUE;
1269 searchEdit->setFocus(); 1550 searchEdit->setFocus();
1270#ifdef __ISEARCH 1551#ifdef __ISEARCH
1271 searchStack->push(new searchrecord("",reader->pagelocate())); 1552 searchStack->push(new searchrecord("",reader->pagelocate()));
1272#endif 1553#endif
1273} 1554}
1274 1555
1275void QTReaderApp::findNext() 1556void QTReaderApp::findNext()
1276{ 1557{
1277 // qDebug("findNext called\n"); 1558 // qDebug("findNext called\n");
1278#ifdef __ISEARCH 1559#ifdef __ISEARCH
@@ -1282,75 +1563,97 @@ void QTReaderApp::findNext()
1282#endif 1563#endif
1283 CDrawBuffer test(&(reader->m_fontControl)); 1564 CDrawBuffer test(&(reader->m_fontControl));
1284 size_t start = reader->pagelocate(); 1565 size_t start = reader->pagelocate();
1285 reader->jumpto(start); 1566 reader->jumpto(start);
1286 reader->buffdoc.getline(&test,reader->width()); 1567 reader->buffdoc.getline(&test,reader->width());
1287 dosearch(start, test, arg); 1568 dosearch(start, test, arg);
1288} 1569}
1289 1570
1290void QTReaderApp::findClose() 1571void QTReaderApp::findClose()
1291{ 1572{
1292 searchVisible = FALSE; 1573 searchVisible = FALSE;
1293 searchEdit->setText(""); 1574 searchEdit->setText("");
1575 Global::hideInputMethod();
1294 searchBar->hide(); 1576 searchBar->hide();
1295#ifdef __ISEARCH 1577#ifdef __ISEARCH
1296// searchStack = new QStack<searchrecord>; 1578// searchStack = new QStack<searchrecord>;
1297 while (!searchStack->isEmpty()) 1579 while (!searchStack->isEmpty())
1298 { 1580 {
1299 delete searchStack->pop(); 1581 delete searchStack->pop();
1300 } 1582 }
1301 delete searchStack; 1583 delete searchStack;
1302#endif 1584#endif
1303 reader->setFocus(); 1585 reader->setFocus();
1304} 1586}
1305 1587
1306void QTReaderApp::regClose() 1588void QTReaderApp::regClose()
1307{ 1589{
1308 regVisible = FALSE; 1590 regVisible = FALSE;
1309 regEdit->setText(""); 1591 regEdit->setText("");
1310 regBar->hide(); 1592 regBar->hide();
1593 Global::hideInputMethod();
1311 reader->setFocus(); 1594 reader->setFocus();
1312} 1595}
1313 1596
1314#ifdef __ISEARCH 1597#ifdef __ISEARCH
1315bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) 1598bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg)
1316#else 1599#else
1317bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) 1600bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
1318#endif 1601#endif
1319{ 1602{
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
1324 while (strstr(test.data(),(const tchar*)arg) == NULL) 1616 while (strstr(test.data(),(const tchar*)arg) == NULL)
1325#else 1617#else
1326#ifdef _UNICODE 1618#ifdef _UNICODE
1327 while (arg.match(toQString(test.data())) == -1) 1619 while (arg.match(toQString(test.data())) == -1)
1328#else 1620#else
1329 while (arg.match(test.data()) == -1) 1621 while (arg.match(test.data()) == -1)
1330#endif 1622#endif
1331#endif 1623#endif
1332 { 1624 {
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()))
1335 { 1637 {
1336 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) 1638 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
1337 pos = searchStart; 1639 pos = searchStart;
1338 else 1640 else
1339 pos = start; 1641 pos = start;
1340 ret = false; 1642 ret = false;
1341 findClose(); 1643 findClose();
1342 break; 1644 break;
1343 } 1645 }
1344 } 1646 }
1647 pbar->hide();
1345 reader->locate(pos); 1648 reader->locate(pos);
1346 return ret; 1649 return ret;
1347} 1650}
1348 1651
1349#ifdef __ISEARCH 1652#ifdef __ISEARCH
1350void QTReaderApp::search(const QString & arg) 1653void QTReaderApp::search(const QString & arg)
1351{ 1654{
1352 searchrecord* ss = searchStack->top(); 1655 searchrecord* ss = searchStack->top();
1353 CBuffer test; 1656 CBuffer test;
1354 size_t start = reader->pagelocate(); 1657 size_t start = reader->pagelocate();
1355 bool haspopped = false; 1658 bool haspopped = false;
1356 while (arg.left(ss->s.length()) != ss->s) 1659 while (arg.left(ss->s.length()) != ss->s)
@@ -1379,74 +1682,142 @@ void QTReaderApp::search(const QString & arg)
1379 } 1682 }
1380 dosearch(start, test, arg); 1683 dosearch(start, test, arg);
1381} 1684}
1382#else 1685#else
1383void QTReaderApp::search() 1686void QTReaderApp::search()
1384{ 1687{
1385 findNext(); 1688 findNext();
1386} 1689}
1387#endif 1690#endif
1388 1691
1389void QTReaderApp::openFile( const QString &f ) 1692void 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 {
1400// QMessageBox::information(0, "Progress", "Calling fileNew()"); 1704// QMessageBox::information(0, "Progress", "Calling fileNew()");
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();
1418 } 1719 }
1419 else 1720 else
1420 { 1721 {
1421 QMessageBox::information(this, "OpieReader", "File does not exist"); 1722 QMessageBox::information(this, PROGNAME, "File does not exist");
1422 } 1723 }
1423 1724
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
1426void QTReaderApp::showEditTools() 1769void 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();
1442} 1813}
1443/* 1814/*
1444void QTReaderApp::save() 1815void QTReaderApp::save()
1445{ 1816{
1446 if ( !doc ) 1817 if ( !doc )
1447 return; 1818 return;
1448 if ( !editor->edited() ) 1819 if ( !editor->edited() )
1449 return; 1820 return;
1450 1821
1451 QString rt = editor->text(); 1822 QString rt = editor->text();
1452 QString pt = rt; 1823 QString pt = rt;
@@ -1464,203 +1835,289 @@ void QTReaderApp::save()
1464 } else { 1835 } else {
1465 docname = pt.left( i ); 1836 docname = pt.left( i );
1466 } 1837 }
1467 doc->setName(docname); 1838 doc->setName(docname);
1468 } 1839 }
1469 FileManager fm; 1840 FileManager fm;
1470 fm.saveFile( *doc, rt ); 1841 fm.saveFile( *doc, rt );
1471} 1842}
1472*/ 1843*/
1473 1844
1474void QTReaderApp::clear() 1845void 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();
1484} 1855}
1485 1856
1486void QTReaderApp::updateCaption() 1857void 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}
1497 1868
1498void QTReaderApp::setDocument(const QString& fileref) 1869void QTReaderApp::setDocument(const QString& fileref)
1499{ 1870{
1500 bFromDocView = TRUE; 1871 bFromDocView = TRUE;
1501//QMessageBox::information(0, "setDocument", fileref); 1872//QMessageBox::information(0, "setDocument", fileref);
1502 openFile(DocLnk(fileref)); 1873 openFile(fileref);
1503// showEditTools(); 1874// showEditTools();
1504} 1875}
1505 1876
1506void QTReaderApp::closeEvent( QCloseEvent *e ) 1877void 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 {
1510 e->accept(); 1887 e->accept();
1511 } 1888 }
1512 else 1889 else
1513 { 1890 {
1514 if (editorStack->visibleWidget() == reader) 1891 if (editorStack->visibleWidget() == reader)
1515 { 1892 {
1516 if (m_fontVisible) 1893 if (m_fontVisible)
1517 { 1894 {
1518 m_fontBar->hide(); 1895 m_fontBar->hide();
1519 m_fontVisible = false; 1896 m_fontVisible = false;
1520 } 1897 }
1521 if (regVisible) 1898 if (regVisible)
1522 { 1899 {
1523 regBar->hide(); 1900 regBar->hide();
1901 Global::hideInputMethod();
1524 regVisible = false; 1902 regVisible = false;
1525 return; 1903 return;
1526 } 1904 }
1527 if (searchVisible) 1905 if (searchVisible)
1528 { 1906 {
1529 searchBar->hide(); 1907 searchBar->hide();
1908 Global::hideInputMethod();
1530 searchVisible = false; 1909 searchVisible = false;
1531 return; 1910 return;
1532 } 1911 }
1533 if (m_fBkmksChanged && pBkmklist != NULL) 1912 if (m_fBkmksChanged && pBkmklist != NULL)
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();
1537 delete pBkmklist; 1916 delete pBkmklist;
1538 pBkmklist = NULL; 1917 pBkmklist = NULL;
1539 m_fBkmksChanged = false; 1918 m_fBkmksChanged = false;
1540 } 1919 }
1541 bFromDocView = FALSE; 1920 bFromDocView = FALSE;
1921 updatefileinfo();
1542 saveprefs(); 1922 saveprefs();
1543 e->accept(); 1923 e->accept();
1544 } 1924 }
1545 else 1925 else
1546 { 1926 {
1547 showEditTools(); 1927 showEditTools();
1548 } 1928 }
1549 } 1929 }
1550} 1930}
1551 1931
1552void QTReaderApp::do_gotomark() 1932void QTReaderApp::do_gotomark()
1553{ 1933{
1554 m_nRegAction = cGotoBkmk; 1934 m_nRegAction = cGotoBkmk;
1555 listbkmk(); 1935 listbkmk(pBkmklist);
1556} 1936}
1557 1937
1558void QTReaderApp::do_delmark() 1938void QTReaderApp::do_delmark()
1559{ 1939{
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()));
1574#else 1959#else
1575 bkmkselector->insertItem(i->name()); 1960 bkmkselector->insertItem(i->name());
1576#endif 1961#endif
1577 cnt++; 1962 cnt++;
1578 } 1963 }
1579 } 1964 }
1580 if (cnt > 0) 1965 if (cnt > 0)
1581 { 1966 {
1582//tjw menu->hide(); 1967//tjw menu->hide();
1583 editBar->hide(); 1968 editBar->hide();
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 );
1588 } 1981 }
1589 else 1982 else
1590 QMessageBox::information(this, "OpieReader", "No bookmarks in memory"); 1983 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
1591} 1984}
1592 1985
1593void QTReaderApp::do_autogen() 1986void QTReaderApp::do_autogen()
1594{ 1987{
1595 m_nRegAction = cAutoGen; 1988 m_nRegAction = cAutoGen;
1596 regEdit->setText(m_autogenstr); 1989 regEdit->setText(m_autogenstr);
1597 do_regedit(); 1990 do_regedit();
1598} 1991}
1599 1992
1600void QTReaderApp::do_regedit() 1993void QTReaderApp::do_regedit()
1601{ 1994{
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}
1607 2048
1608void QTReaderApp::gotobkmk(int ind) 2049void QTReaderApp::gotobkmk(int ind)
1609{ 2050{
1610 switch (m_nRegAction) 2051 switch (m_nRegAction)
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:
1613 reader->locate((*pBkmklist)[ind]->value()); 2063 reader->locate((*pBkmklist)[ind]->value());
1614 break; 2064 break;
1615 case cDelBkmk: 2065 case cDelBkmk:
1616// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); 2066// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
1617 pBkmklist->erase(ind); 2067 pBkmklist->erase(ind);
1618 m_fBkmksChanged = true; 2068 m_fBkmksChanged = true;
1619// pBkmklist->sort(); 2069// pBkmklist->sort();
1620 break; 2070 break;
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;
1624 } 2074 }
1625 showEditTools(); 2075 showEditTools();
1626} 2076}
1627 2077
1628void QTReaderApp::cancelbkmk() 2078void 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();
1631} 2086}
1632 2087
1633void QTReaderApp::jump() 2088void QTReaderApp::jump()
1634{ 2089{
1635 m_nRegAction = cJump; 2090 m_nRegAction = cJump;
1636 char lcn[20]; 2091 char lcn[20];
1637 sprintf(lcn, "%lu", reader->pagelocate()); 2092 sprintf(lcn, "%lu", reader->pagelocate());
1638 regEdit->setText(lcn); 2093 regEdit->setText(lcn);
1639 do_regedit(); 2094 do_regedit();
1640} 2095}
1641 2096
1642void QTReaderApp::do_jump(const QString& lcn) 2097void QTReaderApp::do_jump(const QString& lcn)
1643{ 2098{
1644 bool ok; 2099 bool ok;
1645 unsigned long ulcn = lcn.toULong(&ok); 2100 unsigned long ulcn = lcn.toULong(&ok);
1646 if (ok) 2101 if (ok)
1647 reader->locate(ulcn); 2102 reader->locate(ulcn);
1648 else 2103 else
1649 QMessageBox::information(this, "OpieReader", "Must be a number"); 2104 QMessageBox::information(this, PROGNAME, "Must be a number");
1650} 2105}
1651 2106
1652void QTReaderApp::do_regaction() 2107void QTReaderApp::do_regaction()
1653{ 2108{
2109 reader->bDoUpdates = false;
1654 regBar->hide(); 2110 regBar->hide();
2111 Global::hideInputMethod();
1655 regVisible = false; 2112 regVisible = false;
1656 switch(m_nRegAction) 2113 switch(m_nRegAction)
1657 { 2114 {
1658 case cAutoGen: 2115 case cAutoGen:
1659 do_autogen(regEdit->text()); 2116 do_autogen(regEdit->text());
1660 break; 2117 break;
1661 case cAddBkmk: 2118 case cAddBkmk:
1662 do_addbkmk(regEdit->text()); 2119 do_addbkmk(regEdit->text());
1663 break; 2120 break;
1664 case cJump: 2121 case cJump:
1665 do_jump(regEdit->text()); 2122 do_jump(regEdit->text());
1666 break; 2123 break;
@@ -1668,73 +2125,85 @@ void QTReaderApp::do_regaction()
1668 do_mono(regEdit->text()); 2125 do_mono(regEdit->text());
1669 break; 2126 break;
1670 case cOverlap: 2127 case cOverlap:
1671 do_overlap(regEdit->text()); 2128 do_overlap(regEdit->text());
1672 break; 2129 break;
1673 case cSetTarget: 2130 case cSetTarget:
1674 do_settarget(regEdit->text()); 2131 do_settarget(regEdit->text());
1675 break; 2132 break;
1676 } 2133 }
1677 reader->restore(); 2134 reader->restore();
1678// editBar->show(); 2135// editBar->show();
1679 reader->setFocus(); 2136 reader->setFocus();
2137 qApp->processEvents();
2138 reader->bDoUpdates = true;
2139 reader->update();
1680} 2140}
1681 2141
1682void QTReaderApp::do_settarget(const QString& _txt) 2142void QTReaderApp::do_settarget(const QString& _txt)
1683{ 2143{
1684 int ind = _txt.find('/'); 2144 int ind = _txt.find('/');
1685 if (ind == -1) 2145 if (ind == -1)
1686 { 2146 {
1687 m_targetapp = ""; 2147 m_targetapp = "";
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 }
1691 else 2151 else
1692 { 2152 {
1693 m_targetapp = _txt.left(ind); 2153 m_targetapp = _txt.left(ind);
1694 m_targetmsg = _txt.right(_txt.length()-ind-1); 2154 m_targetmsg = _txt.right(_txt.length()-ind-1);
1695 } 2155 }
1696} 2156}
1697 2157
1698void QTReaderApp::setfont() 2158void QTReaderApp::setfont()
1699{ 2159{
1700 for (int i = 1; i <= m_fontSelector->count(); i++) 2160 for (int i = 1; i <= m_fontSelector->count(); i++)
1701 { 2161 {
1702 if (m_fontSelector->text(i) == reader->m_fontname) 2162 if (m_fontSelector->text(i) == reader->m_fontname)
1703 { 2163 {
1704 m_fontSelector->setCurrentItem(i); 2164 m_fontSelector->setCurrentItem(i);
1705 break; 2165 break;
1706 } 2166 }
1707 } 2167 }
1708 m_fontBar->show(); 2168 m_fontBar->show();
1709 m_fontVisible = true; 2169 m_fontVisible = true;
1710} 2170}
1711 2171
1712void QTReaderApp::setfontHelper(const QString& lcn, int size) 2172void QTReaderApp::setfontHelper(const QString& lcn, int size = 0)
1713{ 2173{
1714 if (size == 0) size = reader->m_fontControl.currentsize(); 2174 if (size == 0) size = reader->m_fontControl.currentsize();
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();
1726 m_fontBar->hide(); 2193 m_fontBar->hide();
1727 m_fontVisible = false; 2194 m_fontVisible = false;
1728 showEditTools(); 2195 qDebug("showedit");
2196 if (reader->isVisible()) showEditTools();
2197 qDebug("showeditdone");
1729} 2198}
1730 2199
1731void QTReaderApp::do_setfont(const QString& lcn) 2200void QTReaderApp::do_setfont(const QString& lcn)
1732{ 2201{
1733 setfontHelper(lcn); 2202 setfontHelper(lcn);
1734} 2203}
1735 2204
1736void QTReaderApp::do_autogen(const QString& regText) 2205void QTReaderApp::do_autogen(const QString& regText)
1737{ 2206{
1738 unsigned long fs, ts; 2207 unsigned long fs, ts;
1739 reader->sizes(fs,ts); 2208 reader->sizes(fs,ts);
1740 // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); 2209 // qDebug("Reg:%s\n", (const tchar*)(regEdit->text()));
@@ -1772,58 +2241,66 @@ pbar->resize(width(), editBar->height());
1772#endif 2241#endif
1773 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); 2242 pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn));
1774 } 2243 }
1775 pBkmklist->sort(); 2244 pBkmklist->sort();
1776 pbar->setProgress(100); 2245 pbar->setProgress(100);
1777 qApp->processEvents(); 2246 qApp->processEvents();
1778 pbar->hide(); 2247 pbar->hide();
1779} 2248}
1780 2249
1781void QTReaderApp::saveprefs() 2250void QTReaderApp::saveprefs()
1782{ 2251{
1783// reader->saveprefs("uqtreader"); 2252// reader->saveprefs("uqtreader");
1784 Config config( "uqtreader" ); 2253 Config config( APPDIR );
1785 config.setGroup( "View" ); 2254 config.setGroup( "View" );
1786 2255
1787 reader->m_lastposn = reader->pagelocate(); 2256 reader->m_lastposn = reader->pagelocate();
1788 2257
1789 config.writeEntry( "StripCr", reader->bstripcr ); 2258 config.writeEntry( "StripCr", reader->bstripcr );
1790 config.writeEntry( "AutoFmt", reader->bautofmt ); 2259 config.writeEntry( "AutoFmt", reader->bautofmt );
1791 config.writeEntry( "TextFmt", reader->btextfmt ); 2260 config.writeEntry( "TextFmt", reader->btextfmt );
1792 config.writeEntry( "StripHtml", reader->bstriphtml ); 2261 config.writeEntry( "StripHtml", reader->bstriphtml );
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 );
1795 config.writeEntry( "Repara", reader->brepara ); 2265 config.writeEntry( "Repara", reader->brepara );
1796 config.writeEntry( "DoubleSpace", reader->bdblspce ); 2266 config.writeEntry( "DoubleSpace", reader->bdblspce );
1797 config.writeEntry( "Indent", reader->bindenter ); 2267 config.writeEntry( "Indent", reader->bindenter );
1798 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); 2268 config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) );
1799 config.writeEntry( "ScrollDelay", reader->m_delay); 2269 config.writeEntry( "ScrollDelay", reader->m_delay);
1800 config.writeEntry( "LastFile", reader->m_lastfile ); 2270 config.writeEntry( "LastFile", reader->m_lastfile );
1801 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); 2271 config.writeEntry( "LastPosn", (int)(reader->pagelocate()) );
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 );
1804 config.writeEntry( "Fontname", reader->m_fontname ); 2275 config.writeEntry( "Fontname", reader->m_fontname );
1805 config.writeEntry( "Encoding", reader->m_encd ); 2276 config.writeEntry( "Encoding", reader->m_encd );
1806 config.writeEntry( "CharSpacing", reader->m_charpc ); 2277 config.writeEntry( "CharSpacing", reader->m_charpc );
1807 config.writeEntry( "Overlap", (int)(reader->m_overlap) ); 2278 config.writeEntry( "Overlap", (int)(reader->m_overlap) );
1808 config.writeEntry( "TargetApp", m_targetapp ); 2279 config.writeEntry( "TargetApp", m_targetapp );
1809 config.writeEntry( "TargetMsg", m_targetmsg ); 2280 config.writeEntry( "TargetMsg", m_targetmsg );
1810 config.writeEntry( "TwoTouch", m_twoTouch ); 2281 config.writeEntry( "TwoTouch", m_twoTouch );
1811 config.writeEntry( "Annotation", m_doAnnotation); 2282 config.writeEntry( "Annotation", m_doAnnotation);
1812 config.writeEntry( "Dictionary", m_doDictionary); 2283 config.writeEntry( "Dictionary", m_doDictionary);
1813 config.writeEntry( "Clipboard", m_doClipboard); 2284 config.writeEntry( "Clipboard", m_doClipboard);
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 );
1816 config.writeEntry( "Peanut", reader->bpeanut ); 2290 config.writeEntry( "Peanut", reader->bpeanut );
1817 config.writeEntry( "MakeBold", reader->bmakebold ); 2291 config.writeEntry( "MakeBold", reader->bmakebold );
2292 config.writeEntry( "Continuous", reader->m_continuousDocument );
2293
2294 savefilelist();
1818} 2295}
1819 2296
1820void QTReaderApp::indentplus() 2297void QTReaderApp::indentplus()
1821{ 2298{
1822 reader->indentplus(); 2299 reader->indentplus();
1823} 2300}
1824 2301
1825void QTReaderApp::indentminus() 2302void QTReaderApp::indentminus()
1826{ 2303{
1827 reader->indentminus(); 2304 reader->indentminus();
1828} 2305}
1829 2306
@@ -1878,59 +2355,93 @@ void info_cb(Fl_Widget* o, void* _data)
1878 posn->value(sz); 2355 posn->value(sz);
1879 2356
1880 frcn->value((100*pl + (ts >> 1))/ts); 2357 frcn->value((100*pl + (ts >> 1))/ts);
1881 } 2358 }
1882 infowin->show(); 2359 infowin->show();
1883} 2360}
1884*/ 2361*/
1885 2362
1886void QTReaderApp::savebkmks() 2363void QTReaderApp::savebkmks()
1887{ 2364{
1888 if (pBkmklist != NULL) 2365 if (pBkmklist != NULL)
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);
1892 } 2369 }
1893 m_fBkmksChanged = false; 2370 m_fBkmksChanged = false;
1894} 2371}
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()
1897{ 2393{
1898 if (pBkmklist != NULL) 2394 if (pBkmklist != NULL)
1899 { 2395 {
1900 delete pBkmklist; 2396 delete pBkmklist;
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();
1904 m_fBkmksChanged = bf.upgraded(); 2415 m_fBkmksChanged = bf.upgraded();
1905 if (pBkmklist == NULL) 2416 if (pBkmklist == NULL)
1906 { 2417 {
1907 pBkmklist = reader->getbkmklist(); 2418 pBkmklist = reader->getbkmklist();
1908 } 2419 }
1909 if (pBkmklist != NULL) 2420 if (pBkmklist != NULL)
1910 pBkmklist->sort(); 2421 pBkmklist->sort();
1911} 2422}
1912 2423
1913void QTReaderApp::addbkmk() 2424void QTReaderApp::addbkmk()
1914{ 2425{
1915 m_nRegAction = cAddBkmk; 2426 m_nRegAction = cAddBkmk;
1916 regEdit->setText(reader->firstword()); 2427 regEdit->setText(reader->firstword());
1917 do_regedit(); 2428 do_regedit();
1918} 2429}
1919 2430
1920void QTReaderApp::do_addbkmk(const QString& text) 2431void QTReaderApp::do_addbkmk(const QString& text)
1921{ 2432{
1922 if (text.isEmpty()) 2433 if (text.isEmpty())
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 }
1926 else 2437 else
1927 { 2438 {
1928 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 2439 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
1929#ifdef _UNICODE 2440#ifdef _UNICODE
1930 CBuffer buff; 2441 CBuffer buff;
1931 int i = 0; 2442 int i = 0;
1932 for (i = 0; i < text.length(); i++) 2443 for (i = 0; i < text.length(); i++)
1933 { 2444 {
1934 buff[i] = text[i].unicode(); 2445 buff[i] = text[i].unicode();
1935 } 2446 }
1936 buff[i] = 0; 2447 buff[i] = 0;
@@ -1948,24 +2459,25 @@ void QTReaderApp::OnRedraw()
1948 if (pBkmklist != NULL) 2459 if (pBkmklist != NULL)
1949 { 2460 {
1950 bool found = findNextBookmark(reader->pagelocate()); 2461 bool found = findNextBookmark(reader->pagelocate());
1951 m_bkmkAvail->setEnabled(found); 2462 m_bkmkAvail->setEnabled(found);
1952 } 2463 }
1953} 2464}
1954 2465
1955void QTReaderApp::showAnnotation() 2466void QTReaderApp::showAnnotation()
1956{ 2467{
1957 m_annoWin->setName(toQString(m_anno->name())); 2468 m_annoWin->setName(toQString(m_anno->name()));
1958 m_annoWin->setAnno(toQString(m_anno->anno())); 2469 m_annoWin->setAnno(toQString(m_anno->anno()));
1959 m_annoIsEditing = false; 2470 m_annoIsEditing = false;
2471 Global::showInputMethod();
1960 editorStack->raiseWidget( m_annoWin ); 2472 editorStack->raiseWidget( m_annoWin );
1961 m_annoWin->setFocus(); 2473 m_annoWin->setFocus();
1962} 2474}
1963 2475
1964void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) 2476void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line)
1965{ 2477{
1966// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); 2478// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd);
1967 2479
1968 if (m_doClipboard) 2480 if (m_doClipboard)
1969 { 2481 {
1970 QClipboard* cb = QApplication::clipboard(); 2482 QClipboard* cb = QApplication::clipboard();
1971 cb->setText(wrd); 2483 cb->setText(wrd);
@@ -1976,24 +2488,25 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString&
1976 else 2488 else
1977 { 2489 {
1978 Global::statusMessage(wrd); 2490 Global::statusMessage(wrd);
1979 } 2491 }
1980 } 2492 }
1981 if (m_doAnnotation) 2493 if (m_doAnnotation)
1982 { 2494 {
1983// addAnno(wrd, "Need to be able to edit this", posn); 2495// addAnno(wrd, "Need to be able to edit this", posn);
1984 m_annoWin->setName(line); 2496 m_annoWin->setName(line);
1985 m_annoWin->setAnno(""); 2497 m_annoWin->setAnno("");
1986 m_annoWin->setPosn(posn); 2498 m_annoWin->setPosn(posn);
1987 m_annoIsEditing = true; 2499 m_annoIsEditing = true;
2500 Global::showInputMethod();
1988 editorStack->raiseWidget( m_annoWin ); 2501 editorStack->raiseWidget( m_annoWin );
1989 } 2502 }
1990 if (m_doDictionary) 2503 if (m_doDictionary)
1991 { 2504 {
1992 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) 2505 if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty())
1993 { 2506 {
1994 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); 2507 QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8());
1995 e << wrd; 2508 e << wrd;
1996 } 2509 }
1997 } 2510 }
1998} 2511}
1999 2512
@@ -2008,22 +2521,86 @@ void QTReaderApp::OnActionPressed()
2008 break; 2521 break;
2009 case cesAutoScroll: 2522 case cesAutoScroll:
2010 { 2523 {
2011 reader->setautoscroll(!reader->m_autoScroll); 2524 reader->setautoscroll(!reader->m_autoScroll);
2012 setScrollState(reader->m_autoScroll); 2525 setScrollState(reader->m_autoScroll);
2013 } 2526 }
2014 break; 2527 break;
2015 case cesActionMark: 2528 case cesActionMark:
2016 { 2529 {
2017 addbkmk(); 2530 addbkmk();
2018 } 2531 }
2019 break; 2532 break;
2533 case cesFullScreen:
2534 {
2535 m_actFullscreen->setOn(true);
2536 }
2537 break;
2020 default: 2538 default:
2021 { 2539 {
2022 qDebug("Unknown ActionType:%u", m_spaceTarget); 2540 qDebug("Unknown ActionType:%u", m_spaceTarget);
2023 } 2541 }
2024 break; 2542 break;
2025 } 2543 }
2026} 2544}
2027 2545
2028void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } 2546void 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*/