summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/QTReaderApp.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp1693
1 files changed, 1135 insertions, 558 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
@@ -1,8 +1,8 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. Allrights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
@@ -18,13 +18,16 @@
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>
@@ -39,12 +42,13 @@
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>
@@ -52,12 +56,22 @@
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
@@ -65,70 +79,82 @@ void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); }
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 {
98 m_nRegAction = cRmBkmkFile; 113 Global::hideInputMethod();
114 regBar->hide();
115 }
116 if (searchVisible)
117 {
118 Global::hideInputMethod();
119 searchBar->hide();
120 }
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;
@@ -156,12 +182,16 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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() );
@@ -172,62 +202,80 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -247,46 +295,56 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -295,13 +353,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
@@ -342,12 +400,23 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
@@ -392,12 +461,16 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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 );
@@ -413,36 +486,43 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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
@@ -534,16 +614,16 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
534// QFont f("unifont", 16 /*, QFont::Bold*/); 614// QFont f("unifont", 16 /*, QFont::Bold*/);
535// searchEdit->setFont( f ); 615// searchEdit->setFont( f );
536 searchBar->setStretchableWidget( searchEdit ); 616 searchBar->setStretchableWidget( searchEdit );
537 617
538#ifdef __ISEARCH 618#ifdef __ISEARCH
539 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 619 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
540 this, SLOT( search( const QString& ) ) ); 620 this, SLOT( search( const QString& ) ) );
541#else 621#else
542 connect( searchEdit, SIGNAL( returnPressed( ) ), 622 connect( searchEdit, SIGNAL( returnPressed( ) ),
543 this, SLOT( search( ) ) ); 623 this, SLOT( search( ) ) );
544#endif 624#endif
545 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 625 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
546 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 626 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
547 a->addTo( searchBar ); 627 a->addTo( searchBar );
548 628
549 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 629 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
@@ -560,13 +640,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
560 regEdit = new QLineEdit( regBar, "regEdit" ); 640 regEdit = new QLineEdit( regBar, "regEdit" );
561// regEdit->setFont( f ); 641// regEdit->setFont( f );
562 642
563 regBar->setStretchableWidget( regEdit ); 643 regBar->setStretchableWidget( regEdit );
564 644
565 connect( regEdit, SIGNAL( returnPressed( ) ), 645 connect( regEdit, SIGNAL( returnPressed( ) ),
566 this, SLOT( do_regaction() ) ); 646 this, SLOT( do_regaction() ) );
567 647
568 a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 648 a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
569 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); 649 connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) );
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 );
@@ -576,314 +656,393 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f )
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; 676 }
596 } 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
610 690
691 qDebug("Initing");
611 reader->init(); 692 reader->init();
612 if (!reader->m_lastfile.isEmpty()) 693 qDebug("Inited");
613 {
614 openFile( reader->m_lastfile );
615 doc = new DocLnk(reader->m_lastfile);
616 }
617 m_EncodingAction[reader->m_encd]->setOn(true); 694 m_EncodingAction[reader->m_encd]->setOn(true);
618 m_buttonAction[m_spaceTarget]->setOn(true); 695 m_buttonAction[m_spaceTarget]->setOn(true);
696 qDebug("fonting");
619 do_setfont(reader->m_fontname); 697 do_setfont(reader->m_fontname);
620} 698 if (!reader->m_lastfile.isEmpty())
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");
733 openFile( reader->m_lastfile );
734 }
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 }
652 else if ( msg == "pageUp()" ) 781 else if ( msg == "pageUp()" )
653 { 782 {
654 reader->dopageup(); 783 reader->dopageup();
655 } 784 }
656 else if ( msg == "lineDown()" ) 785 else if ( msg == "lineDown()" )
657 { 786 {
658 reader->lineDown(); 787 reader->lineDown();
659 } 788 }
660 else if ( msg == "lineUp()" ) 789 else if ( msg == "lineUp()" )
661 { 790 {
662 reader->lineUp(); 791 reader->lineUp();
663 } 792 }
664 else if ( msg == "showText()" ) 793 else if ( msg == "showText()" )
665 { 794 {
666 showEditTools(); 795 showEditTools();
667 } 796 }
668 else if ( msg == "File/Open(QString)" ) 797 else if ( msg == "File/Open(QString)" )
669 { 798 {
670 QString info; 799 QString info;
671 stream >> info; 800 stream >> info;
672 openFile( info ); 801 openFile( info );
673 } 802 }
674 else if ( msg == "File/Info()" ) 803 else if ( msg == "File/Info()" )
675 { 804 {
676 showinfo(); 805 showinfo();
677 } 806 }
678 else if ( msg == "File/Start Block()" ) 807 else if ( msg == "File/Start Block()" )
679 { 808 {
680 editMark(); 809 editMark();
681 } 810 }
682 else if ( msg == "File/Copy Block()" ) 811 else if ( msg == "File/Copy Block()" )
683 { 812 {
684 editCopy(); 813 editCopy();
685 } 814 }
686 else if ( msg == "File/Scroll(int)" ) 815 else if ( msg == "File/Scroll(int)" )
687 { 816 {
688 int info; 817 int info;
689 stream >> info; 818 stream >> info;
690 autoScroll(info); 819 autoScroll(info);
691 } 820 }
692 else if ( msg == "File/Jump(int)" ) 821 else if ( msg == "File/Jump(int)" )
693 { 822 {
694 int info; 823 int info;
695 stream >> info; 824 stream >> info;
696 reader->locate(info); 825 reader->locate(info);
697 } 826 }
698 else if ( msg == "File/Page/Line Scroll(int)" ) 827 else if ( msg == "File/Page/Line Scroll(int)" )
699 { 828 {
700 int info; 829 int info;
701 stream >> info; 830 stream >> info;
702 pagemode(info); 831 pagemode(info);
703 } 832 }
704 else if ( msg == "File/Set Overlap(int)" ) 833 else if ( msg == "File/Set Overlap(int)" )
705 { 834 {
706 int info; 835 int info;
707 stream >> info; 836 stream >> info;
708 reader->m_overlap = info; 837 reader->m_overlap = info;
709 } 838 }
710 else if ( msg == "File/Set Dictionary(QString)" ) 839 else if ( msg == "File/Set Dictionary(QString)" )
711 { 840 {
712 QString info; 841 QString info;
713 stream >> info; 842 stream >> info;
714 do_settarget(info); 843 do_settarget(info);
715 } 844 }
716 else if ( msg == "File/Two/One Touch(int)" ) 845 else if ( msg == "File/Two/One Touch(int)" )
717 { 846 {
718 int info; 847 int info;
719 stream >> info; 848 stream >> info;
720 setTwoTouch(info); 849 setTwoTouch(info);
721 } 850 }
722 else if ( msg == "Target/Annotation(int)" ) 851 else if ( msg == "Target/Annotation(int)" )
723 { 852 {
724 int info; 853 int info;
725 stream >> info; 854 stream >> info;
726 OnAnnotation(info); 855 OnAnnotation(info);
727 } 856 }
728 else if ( msg == "Target/Dictionary(int)" ) 857 else if ( msg == "Target/Dictionary(int)" )
729 { 858 {
730 int info; 859 int info;
731 stream >> info; 860 stream >> info;
732 OnDictionary(info); 861 OnDictionary(info);
733 } 862 }
734 else if ( msg == "Target/Clipboard(int)" ) 863 else if ( msg == "Target/Clipboard(int)" )
735 { 864 {
736 int info; 865 int info;
737 stream >> info; 866 stream >> info;
738 OnClipboard(info); 867 OnClipboard(info);
739 } 868 }
740 else if ( msg == "File/Find(QString)" ) 869 else if ( msg == "File/Find(QString)" )
741 { 870 {
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);
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);
766 } 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 }
779 else if ( msg == "Markup/HTML(int)" ) 922 else if ( msg == "Markup/HTML(int)" )
780 { 923 {
781 int info; 924 int info;
782 stream >> info; 925 stream >> info;
783 striphtml(info); 926 striphtml(info);
784 } 927 }
785 else if ( msg == "Markup/Peanut(int)" ) 928 else if ( msg == "Markup/Peanut(int)" )
786 { 929 {
787 int info; 930 int info;
788 stream >> info; 931 stream >> info;
789 peanut(info); 932 peanut(info);
790 } 933 }
791 else if ( msg == "Layout/Dehyphen(int)" ) 934 else if ( msg == "Layout/Dehyphen(int)" )
792 { 935 {
793 int info; 936 int info;
794 stream >> info; 937 stream >> info;
795 dehyphen(info); 938 dehyphen(info);
796 } 939 }
797 else if ( msg == "Layout/Unindent(int)" ) 940 else if ( msg == "Layout/Unindent(int)" )
798 { 941 {
799 int info; 942 int info;
800 stream >> info; 943 stream >> info;
801 unindent(info); 944 unindent(info);
802 } 945 }
803 else if ( msg == "Layout/Re-paragraph(int)" ) 946 else if ( msg == "Layout/Re-paragraph(int)" )
804 { 947 {
805 int info; 948 int info;
806 stream >> info; 949 stream >> info;
807 repara(info); 950 repara(info);
808 } 951 }
809 else if ( msg == "Layout/Double Space(int)" ) 952 else if ( msg == "Layout/Double Space(int)" )
810 { 953 {
811 int info; 954 int info;
812 stream >> info; 955 stream >> info;
813 dblspce(info); 956 dblspce(info);
814 } 957 }
815 else if ( msg == "Layout/Indent(int)" ) 958 else if ( msg == "Layout/Indent(int)" )
816 { 959 {
817 int info; 960 int info;
818 stream >> info; 961 stream >> info;
819 reader->bindenter = info; 962 reader->bindenter = info;
820 reader->setfilter(reader->getfilter()); 963 reader->setfilter(reader->getfilter());
821 } 964 }
822 else if ( msg == "Layout/Remap(int)" ) 965 else if ( msg == "Layout/Remap(int)" )
823 { 966 {
824 int info; 967 int info;
825 stream >> info; 968 stream >> info;
826 remap(info); 969 remap(info);
827 } 970 }
828 else if ( msg == "Layout/Embolden(int)" ) 971 else if ( msg == "Layout/Embolden(int)" )
829 { 972 {
830 int info; 973 int info;
831 stream >> info; 974 stream >> info;
832 embolden(info); 975 embolden(info);
833 } 976 }
834 else if ( msg == "Format/Ideogram/Word(int)" ) 977 else if ( msg == "Format/Ideogram/Word(int)" )
835 { 978 {
836 int info; 979 int info;
837 stream >> info; 980 stream >> info;
838 monospace(info); 981 monospace(info);
839 } 982 }
840 else if ( msg == "Format/Set width(int)" ) 983 else if ( msg == "Format/Set width(int)" )
841 { 984 {
842 int info; 985 int info;
843 stream >> info; 986 stream >> info;
844 reader->m_charpc = info; 987 reader->m_charpc = info;
845 reader->setfont(); 988 reader->setfont();
846 reader->refresh(); 989 reader->refresh();
847 } 990 }
848 else if ( msg == "Format/Encoding(QString)" ) 991 else if ( msg == "Format/Encoding(QString)" )
849 { 992 {
850 QString info; 993 QString info;
851 stream >> info; 994 stream >> info;
852 reader->setencoding(EncNameToInt(info)); 995 reader->setencoding(EncNameToInt(info));
853 } 996 }
854 else if ( msg == "Format/Set Font(QString,int)" ) 997 else if ( msg == "Format/Set Font(QString,int)" )
855 { 998 {
856 QString fontname; 999 QString fontname;
857 int size; 1000 int size;
858 stream >> fontname; 1001 stream >> fontname;
859 stream >> size; 1002 stream >> size;
860 setfontHelper(fontname, size); 1003 setfontHelper(fontname, size);
861 } 1004 }
862 else if ( msg == "Marks/Autogen(QString)" ) 1005 else if ( msg == "Marks/Autogen(QString)" )
863 { 1006 {
864 QString info; 1007 QString info;
865 stream >> info; 1008 stream >> info;
866 do_autogen(info); 1009 do_autogen(info);
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;
@@ -907,106 +1066,213 @@ QTReaderApp::~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;
1090}
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;
930} 1162}
931 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)
957 0, 1197 {
958// WStyle_Customize | WStyle_NoBorderEx, 1198 m_nRegAction = cOpenFile;
959 "*", QFileInfo(reader->m_lastfile).dirPath(true)); 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,
1215 0,
1216 // WStyle_Customize | WStyle_NoBorderEx,
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();
989 } 1255 }
990} 1256}
991 1257
992void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) 1258void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn)
993{ 1259{
994 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; 1260 if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>;
995#ifdef _UNICODE 1261#ifdef _UNICODE
996 CBuffer buff(name.length()+1); 1262 CBuffer buff(name.length()+1);
997 int i; 1263 int i;
998 for (i = 0; i < name.length(); i++) 1264 for (i = 0; i < name.length(); i++)
999 { 1265 {
1000 buff[i] = name[i].unicode(); 1266 buff[i] = name[i].unicode();
1001 } 1267 }
1002 buff[i] = 0; 1268 buff[i] = 0;
1003 CBuffer buff2(text.length()+1); 1269 CBuffer buff2(text.length()+1);
1004 for (i = 0; i < text.length(); i++) 1270 for (i = 0; i < text.length(); i++)
1005 { 1271 {
1006 buff2[i] = text[i].unicode(); 1272 buff2[i] = text[i].unicode();
1007 } 1273 }
1008 buff2[i] = 0; 1274 buff2[i] = 0;
1009 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); 1275 pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn));
1010#else 1276#else
1011 pBkmklist->push_front(Bkmk((const tchar*)text,posn)); 1277 pBkmklist->push_front(Bkmk((const tchar*)text,posn));
1012#endif 1278#endif
@@ -1015,81 +1281,82 @@ void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn)
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);
1036 int i; 1302 int i;
1037 for (i = 0; i < text.length(); i++) 1303 for (i = 0; i < text.length(); i++)
1038 { 1304 {
1039 buff[i] = text[i].unicode(); 1305 buff[i] = text[i].unicode();
1040 } 1306 }
1041 buff[i] = 0; 1307 buff[i] = 0;
1042 m_fBkmksChanged = true; 1308 m_fBkmksChanged = true;
1043 m_anno->setAnno(buff.data()); 1309 m_anno->setAnno(buff.data());
1044 } 1310 }
1045 bool found = findNextBookmark(m_anno->value()+1); 1311 bool found = findNextBookmark(m_anno->value()+1);
1046 if (found) 1312 if (found)
1047 { 1313 {
1048 m_annoWin->setName(toQString(m_anno->name())); 1314 m_annoWin->setName(toQString(m_anno->name()));
1049 m_annoWin->setAnno(toQString(m_anno->anno())); 1315 m_annoWin->setAnno(toQString(m_anno->anno()));
1050 } 1316 }
1051 else 1317 else
1052 { 1318 {
1053 showEditTools(); 1319 showEditTools();
1054 } 1320 }
1055 } 1321 }
1056} 1322}
1057 1323
1058bool QTReaderApp::findNextBookmark(size_t start) 1324bool QTReaderApp::findNextBookmark(size_t start)
1059{ 1325{
1060 bool found = false; 1326 bool found = false;
1061 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) 1327 for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++)
1062 { 1328 {
1063 if (iter->value() >= start) 1329 if (iter->value() >= start)
1064 { 1330 {
1065 if (iter->value() < reader->locate()) 1331 if (iter->value() < reader->locate())
1066 { 1332 {
1067 found = true; 1333 found = true;
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 );
1089 m_annoWin->setFocus(); 1355 Global::showInputMethod();
1356 m_annoWin->setFocus();
1090 } 1357 }
1091} 1358}
1092 1359
1093void QTReaderApp::infoClose() 1360void QTReaderApp::infoClose()
1094{ 1361{
1095 showEditTools(); 1362 showEditTools();
@@ -1113,40 +1380,50 @@ void QTReaderApp::editMark()
1113{ 1380{
1114 m_savedpos = reader->pagelocate(); 1381 m_savedpos = reader->pagelocate();
1115} 1382}
1116 1383
1117void QTReaderApp::editCopy() 1384void QTReaderApp::editCopy()
1118{ 1385{
1119 QClipboard* cb = QApplication::clipboard(); 1386 QClipboard* cb = QApplication::clipboard();
1120 QString text; 1387 QString text;
1121 int ch; 1388 int ch;
1122 unsigned long currentpos = reader->pagelocate(); 1389 unsigned long currentpos = reader->pagelocate();
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{
@@ -1185,13 +1462,16 @@ void QTReaderApp::dblspce(bool _b)
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()
@@ -1213,43 +1493,43 @@ void QTReaderApp::setoverlap()
1213} 1493}
1214 1494
1215void QTReaderApp::settarget() 1495void QTReaderApp::settarget()
1216{ 1496{
1217 m_nRegAction = cSetTarget; 1497 m_nRegAction = cSetTarget;
1218 QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) 1498 QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp)
1219 + "/" 1499 + "/"
1220 + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); 1500 + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg);
1221 regEdit->setText(text); 1501 regEdit->setText(text);
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
@@ -1261,12 +1541,13 @@ void QTReaderApp::editPaste()
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
@@ -1288,12 +1569,13 @@ void QTReaderApp::findNext()
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();
@@ -1305,46 +1587,67 @@ void QTReaderApp::findClose()
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)
@@ -1385,251 +1688,403 @@ void QTReaderApp::search()
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")
1707 {
1708 DocLnk d(f);
1709 QFileInfo fnew(d.file());
1710 fm = fnew;
1711 if (!fm.exists()) return;
1712 }
1403 1713
1404 // editorStack->raiseWidget( reader ); 1714 clear();
1405
1406 // reader->setFocus();
1407
1408 // QMessageBox::information(0, "DocLnk", "Begin");
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");
1723 }
1724
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();
1422 } 1766 }
1423
1424} 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 {
1432 editBar->show(); 1775 editBar->hide();
1433 if ( searchVisible ) 1776 searchBar->hide();
1434 searchBar->show(); 1777 regBar->hide();
1435 if ( regVisible ) 1778 Global::hideInputMethod();
1436 regBar->show(); 1779 m_fontBar->hide();
1437 if (m_fontVisible) m_fontBar->show(); 1780 //showNormal();
1438 1781 showFullScreen();
1782 }
1783 else
1784 {
1785 qDebug("him");
1786 Global::hideInputMethod();
1787 qDebug("eb");
1788 editBar->show();
1789 if ( searchVisible )
1790 {
1791 Global::showInputMethod();
1792 searchBar->show();
1793 }
1794 if ( regVisible )
1795 {
1796 Global::showInputMethod();
1797 regBar->show();
1798 }
1799 if (m_fontVisible) m_fontBar->show();
1800 qDebug("sn");
1801 showNormal();
1802 qDebug("sm");
1803 showMaximized();
1804 //setCentralWidget(reader);
1805 }
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;
1453 1824
1454 if ( doc->name().isEmpty() ) { 1825 if ( doc->name().isEmpty() ) {
1455 unsigned ispace = pt.find( ' ' ); 1826 unsigned ispace = pt.find( ' ' );
1456 unsigned ienter = pt.find( '\n' ); 1827 unsigned ienter = pt.find( '\n' );
1457 int i = (ispace < ienter) ? ispace : ienter; 1828 int i = (ispace < ienter) ? ispace : ienter;
1458 QString docname; 1829 QString docname;
1459 if ( i == -1 ) { 1830 if ( i == -1 ) {
1460 if ( pt.isEmpty() ) 1831 if ( pt.isEmpty() )
1461 docname = "Empty Text"; 1832 docname = "Empty Text";
1462 else 1833 else
1463 docname = pt; 1834 docname = pt;
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)
1509 { 1880 {
1510 e->accept(); 1881 m_fullscreen = false;
1882 showEditTools();
1883 e->accept();
1884 }
1885 else if (m_dontSave)
1886 {
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();
1524 regVisible = false; 1901 Global::hideInputMethod();
1525 return; 1902 regVisible = false;
1526 } 1903 return;
1527 if (searchVisible) 1904 }
1528 { 1905 if (searchVisible)
1529 searchBar->hide(); 1906 {
1530 searchVisible = false; 1907 searchBar->hide();
1531 return; 1908 Global::hideInputMethod();
1532 } 1909 searchVisible = false;
1533 if (m_fBkmksChanged && pBkmklist != NULL) 1910 return;
1534 { 1911 }
1535 if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) 1912 if (m_fBkmksChanged && pBkmklist != NULL)
1536 savebkmks(); 1913 {
1537 delete pBkmklist; 1914 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
1538 pBkmklist = NULL; 1915 savebkmks();
1539 m_fBkmksChanged = false; 1916 delete pBkmklist;
1540 } 1917 pBkmklist = NULL;
1541 bFromDocView = FALSE; 1918 m_fBkmksChanged = false;
1542 saveprefs(); 1919 }
1543 e->accept(); 1920 bFromDocView = FALSE;
1544 } 1921 updatefileinfo();
1545 else 1922 saveprefs();
1546 { 1923 e->accept();
1547 showEditTools(); 1924 }
1548 } 1925 else
1926 {
1927 showEditTools();
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
1573 bkmkselector->insertItem(toQString(i->name())); 1957 qDebug("Item:%s", (const char*)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 {
1612 case cGotoBkmk: 2053 case cOpenFile:
1613 reader->locate((*pBkmklist)[ind]->value()); 2054 {
1614 break; 2055 if (!openfrombkmk((*pOpenlist)[ind]))
1615 case cDelBkmk: 2056 {
1616// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); 2057 pOpenlist->erase(ind);
1617 pBkmklist->erase(ind); 2058 QMessageBox::information(this, PROGNAME, "Can't find file");
1618 m_fBkmksChanged = true; 2059 }
1619// pBkmklist->sort(); 2060 }
1620 break; 2061 break;
1621 case cRmBkmkFile: 2062 case cGotoBkmk:
1622 unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); 2063 reader->locate((*pBkmklist)[ind]->value());
1623 break; 2064 break;
2065 case cDelBkmk:
2066 // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
2067 pBkmklist->erase(ind);
2068 m_fBkmksChanged = true;
2069 // pBkmklist->sort();
2070 break;
2071 case cRmBkmkFile:
2072 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
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;
@@ -1641,94 +2096,108 @@ void QTReaderApp::jump()
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;
1667 case cMonoSpace: 2124 case cMonoSpace:
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 {
1723 reader->ChangeFont(size); 2188 qDebug("cf2");
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}
@@ -1756,68 +2225,76 @@ pbar->resize(width(), editBar->height());
1756 { 2225 {
1757 unsigned int lcn = reader->locate(); 2226 unsigned int lcn = reader->locate();
1758 int pc = (100*lcn)/ts; 2227 int pc = (100*lcn)/ts;
1759 if (pc != lastpc) 2228 if (pc != lastpc)
1760 { 2229 {
1761 pbar->setProgress(pc); 2230 pbar->setProgress(pc);
1762 qApp->processEvents(); 2231 qApp->processEvents();
1763 if (reader->locate() != lcn) reader->jumpto(lcn); 2232 if (reader->locate() != lcn) reader->jumpto(lcn);
1764 reader->setFocus(); 2233 reader->setFocus();
1765 lastpc = pc; 2234 lastpc = pc;
1766 } 2235 }
1767 i = reader->buffdoc.getpara(buff); 2236 i = reader->buffdoc.getpara(buff);
1768#ifdef _UNICODE 2237#ifdef _UNICODE
1769 if (re.match(toQString(buff.data())) != -1) 2238 if (re.match(toQString(buff.data())) != -1)
1770#else 2239#else
1771 if (re.match(buff.data()) != -1) 2240 if (re.match(buff.data()) != -1)
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}
@@ -1841,189 +2318,289 @@ void QTReaderApp::oldFile()
1841/* 2318/*
1842void info_cb(Fl_Widget* o, void* _data) 2319void info_cb(Fl_Widget* o, void* _data)
1843{ 2320{
1844 2321
1845 if (infowin == NULL) 2322 if (infowin == NULL)
1846 { 2323 {
1847 2324
1848 infowin = new Fl_Window(160,240); 2325 infowin = new Fl_Window(160,240);
1849 filename = new Fl_Output(45,5,110,14,"Filename"); 2326 filename = new Fl_Output(45,5,110,14,"Filename");
1850 filesize = new Fl_Output(45,25,110,14,"Filesize"); 2327 filesize = new Fl_Output(45,25,110,14,"Filesize");
1851 textsize = new Fl_Output(45,45,110,14,"Textsize"); 2328 textsize = new Fl_Output(45,45,110,14,"Textsize");
1852 comprat = new CBar(45,65,110,14,"Ratio %"); 2329 comprat = new CBar(45,65,110,14,"Ratio %");
1853 posn = new Fl_Output(45,85,110,14,"Location"); 2330 posn = new Fl_Output(45,85,110,14,"Location");
1854 frcn = new CBar(45,105,110,14,"% Read"); 2331 frcn = new CBar(45,105,110,14,"% Read");
1855 about = new Fl_Multiline_Output(5,125,150,90); 2332 about = new Fl_Multiline_Output(5,125,150,90);
1856 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); 2333 about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files");
1857 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); 2334 Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay");
1858 infowin->set_modal(); 2335 infowin->set_modal();
1859 } 2336 }
1860 if (((reader_ui *)_data)->g_filename[0] != '\0') 2337 if (((reader_ui *)_data)->g_filename[0] != '\0')
1861 { 2338 {
1862 unsigned long fs,ts; 2339 unsigned long fs,ts;
1863 tchar sz[20]; 2340 tchar sz[20];
1864 ((reader_ui *)_data)->input->sizes(fs,ts); 2341 ((reader_ui *)_data)->input->sizes(fs,ts);
1865 unsigned long pl = ((reader_ui *)_data)->input->locate(); 2342 unsigned long pl = ((reader_ui *)_data)->input->locate();
1866 2343
1867 filename->value(((reader_ui *)_data)->g_filename); 2344 filename->value(((reader_ui *)_data)->g_filename);
1868 2345
1869 sprintf(sz,"%u",fs); 2346 sprintf(sz,"%u",fs);
1870 filesize->value(sz); 2347 filesize->value(sz);
1871 2348
1872 sprintf(sz,"%u",ts); 2349 sprintf(sz,"%u",ts);
1873 textsize->value(sz); 2350 textsize->value(sz);
1874 2351
1875 comprat->value(100-(100*fs + (ts >> 1))/ts); 2352 comprat->value(100-(100*fs + (ts >> 1))/ts);
1876 2353
1877 sprintf(sz,"%u",pl); 2354 sprintf(sz,"%u",pl);
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);
2369 }
2370 m_fBkmksChanged = false;
2371}
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);
1892 } 2389 }
1893 m_fBkmksChanged = false;
1894} 2390}
1895 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;
2397 }
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 }
1901 } 2410 }
1902 BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); 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;
1937 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); 2448 pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate()));
1938#else 2449#else
1939 pBkmklist->push_front(Bkmk((const tchar*)text,reader->pagelocate())); 2450 pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate()));
1940#endif 2451#endif
1941 m_fBkmksChanged = true; 2452 m_fBkmksChanged = true;
1942 pBkmklist->sort(); 2453 pBkmklist->sort();
1943 } 2454 }
1944} 2455}
1945 2456
1946void QTReaderApp::OnRedraw() 2457void QTReaderApp::OnRedraw()
1947{ 2458{
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);
1972 if (wrd.length() > 10) 2484 if (wrd.length() > 10)
1973 { 2485 {
1974 Global::statusMessage(wrd.left(8) + ".."); 2486 Global::statusMessage(wrd.left(8) + "..");
1975 } 2487 }
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;
1988 editorStack->raiseWidget( m_annoWin ); 2500 Global::showInputMethod();
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
2000void QTReaderApp::OnActionPressed() 2513void QTReaderApp::OnActionPressed()
2001{ 2514{
2002 switch (m_spaceTarget) 2515 switch (m_spaceTarget)
2003 { 2516 {
2004 case cesOpenFile: 2517 case cesOpenFile:
2005 { 2518 {
2006 fileOpen(); 2519 fileOpen();
2007 } 2520 }
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;
2020 default: 2533 case cesFullScreen:
2021 { 2534 {
2022 qDebug("Unknown ActionType:%u", m_spaceTarget); 2535 m_actFullscreen->setOn(true);
2023 } 2536 }
2024 break; 2537 break;
2538 default:
2539 {
2540 qDebug("Unknown ActionType:%u", m_spaceTarget);
2541 }
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*/