Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 780 |
1 files changed, 688 insertions, 92 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 68c80c1..0608b66 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -19,4 +19,5 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qclipboard.h> | ||
21 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
22 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
@@ -39,8 +40,12 @@ | |||
39 | #include <qbuttongroup.h> | 40 | #include <qbuttongroup.h> |
40 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qpe/qcopenvelope_qws.h> | ||
41 | 43 | ||
44 | #include "QTReader.h" | ||
45 | #include "Bkmks.h" | ||
42 | #include "cbkmkselector.h" | 46 | #include "cbkmkselector.h" |
43 | #include "infowin.h" | 47 | #include "infowin.h" |
44 | 48 | #include "CAnnoEdit.h" | |
49 | #include "QFloatBar.h" | ||
45 | //#include <qpe/fontdatabase.h> | 50 | //#include <qpe/fontdatabase.h> |
46 | 51 | ||
@@ -50,4 +55,5 @@ | |||
50 | #include "QTReaderApp.h" | 55 | #include "QTReaderApp.h" |
51 | #include "fileBrowser.h" | 56 | #include "fileBrowser.h" |
57 | #include "CDrawBuffer.h" | ||
52 | 58 | ||
53 | 59 | ||
@@ -85,5 +91,5 @@ void QTReaderApp::listBkmkFiles() | |||
85 | if (cnt > 0) | 91 | if (cnt > 0) |
86 | { | 92 | { |
87 | menu->hide(); | 93 | //tjw menu->hide(); |
88 | editBar->hide(); | 94 | editBar->hide(); |
89 | if (m_fontVisible) m_fontBar->hide(); | 95 | if (m_fontVisible) m_fontBar->hide(); |
@@ -98,5 +104,5 @@ void QTReaderApp::listBkmkFiles() | |||
98 | 104 | ||
99 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 105 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) |
100 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 106 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false) |
101 | { | 107 | { |
102 | // qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 108 | // qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
@@ -118,5 +124,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
118 | bar->setHorizontalStretchable( TRUE ); | 124 | bar->setHorizontalStretchable( TRUE ); |
119 | addToolBar(bar, "tool",QMainWindow::Top, true); | 125 | addToolBar(bar, "tool",QMainWindow::Top, true); |
120 | menu = bar; | 126 | //tjw menu = bar; |
121 | 127 | ||
122 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 128 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
@@ -145,4 +151,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
145 | pbar->hide(); | 151 | pbar->hide(); |
146 | 152 | ||
153 | m_annoWin = new CAnnoEdit(editorStack); | ||
154 | editorStack->addWidget(m_annoWin, get_unique_id()); | ||
155 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); | ||
156 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); | ||
157 | |||
147 | m_infoWin = new infowin(editorStack); | 158 | m_infoWin = new infowin(editorStack); |
148 | editorStack->addWidget(m_infoWin, get_unique_id()); | 159 | editorStack->addWidget(m_infoWin, get_unique_id()); |
@@ -167,9 +178,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
167 | 178 | ||
168 | reader = new QTReader( editorStack ); | 179 | reader = new QTReader( editorStack ); |
180 | |||
181 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | ||
182 | |||
169 | Config config( "uqtreader" ); | 183 | Config config( "uqtreader" ); |
170 | config.setGroup( "View" ); | 184 | config.setGroup( "View" ); |
171 | 185 | ||
172 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 186 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
187 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | ||
188 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | ||
173 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 189 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
190 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | ||
174 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 191 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
175 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 192 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
@@ -178,5 +195,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
178 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 195 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
179 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 196 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
180 | reader->m_bBold = config.readBoolEntry( "Bold", false ); | ||
181 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 197 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
182 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 198 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
@@ -188,7 +204,19 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
188 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 204 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
189 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 205 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
190 | reader->m_targetapp = config.readEntry( "TargetApp", QString::null ); | 206 | reader->bremap = config.readBoolEntry( "Remap", true ); |
191 | reader->m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 207 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
192 | reader->init(); | 208 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
209 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | ||
210 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | ||
211 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | ||
212 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | ||
213 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | ||
214 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | ||
215 | setTwoTouch(m_twoTouch); | ||
216 | |||
217 | |||
218 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | ||
219 | 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&) ) ); | ||
193 | editorStack->addWidget( reader, get_unique_id() ); | 221 | editorStack->addWidget( reader, get_unique_id() ); |
194 | 222 | ||
@@ -213,14 +241,20 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
213 | a->addTo( file ); | 241 | a->addTo( file ); |
214 | 242 | ||
215 | a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); | 243 | QActionGroup* ag = new QActionGroup(this); |
216 | connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 244 | QPopupMenu *spacemenu = new QPopupMenu(this); |
217 | file->insertSeparator(); | 245 | file->insertItem( tr( "On Action..." ), spacemenu ); |
218 | a->addTo( file ); | ||
219 | 246 | ||
220 | a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); | 247 | m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true ); |
221 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 248 | |
222 | a->addTo( file ); | 249 | m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true ); |
250 | |||
251 | m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); | ||
252 | |||
253 | ag->addTo(spacemenu); | ||
254 | |||
255 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); | ||
223 | 256 | ||
224 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true ); | 257 | |
258 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | ||
225 | // connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) ); | 259 | // connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) ); |
226 | a->setOn(false); | 260 | a->setOn(false); |
@@ -243,5 +277,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
243 | a->addTo( file ); | 277 | a->addTo( file ); |
244 | 278 | ||
245 | a = new QAction( tr( "Page/Line scroll" ), QString::null, 0, this, NULL, true ); | 279 | a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, this, NULL, true ); |
246 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 280 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); |
247 | a->setOn(reader->m_bpagemode); | 281 | a->setOn(reader->m_bpagemode); |
@@ -252,8 +286,35 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
252 | a->addTo( file ); | 286 | a->addTo( file ); |
253 | 287 | ||
288 | file->insertSeparator(); | ||
289 | |||
254 | a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); | 290 | a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); |
255 | connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) ); | 291 | connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) ); |
256 | a->addTo( file ); | 292 | a->addTo( file ); |
257 | 293 | ||
294 | a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true ); | ||
295 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | ||
296 | a->setOn(m_twoTouch); | ||
297 | a->addTo( file ); | ||
298 | |||
299 | ag = new QActionGroup(this); | ||
300 | ag->setExclusive(false); | ||
301 | QPopupMenu *encoding = new QPopupMenu(this); | ||
302 | file->insertItem( tr( "Target" ), encoding ); | ||
303 | |||
304 | a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true ); | ||
305 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) ); | ||
306 | a->setOn(m_doAnnotation); | ||
307 | |||
308 | a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true ); | ||
309 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) ); | ||
310 | a->setOn(m_doDictionary); | ||
311 | |||
312 | a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true ); | ||
313 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) ); | ||
314 | a->setOn(m_doClipboard); | ||
315 | |||
316 | ag->addTo(encoding); | ||
317 | |||
318 | |||
258 | /* | 319 | /* |
259 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); | 320 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); |
@@ -277,54 +338,93 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
277 | */ | 338 | */ |
278 | 339 | ||
279 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 340 | // a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
341 | a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL); | ||
280 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 342 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
281 | file->insertSeparator(); | 343 | file->insertSeparator(); |
282 | a->addTo( bar ); | 344 | // a->addTo( bar ); |
283 | a->addTo( file ); | 345 | a->addTo( file ); |
284 | 346 | ||
285 | 347 | ||
286 | a = new QAction( tr( "Strip CR" ), QString::null, 0, this, NULL, true ); | 348 | a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
287 | a->setOn(reader->bstripcr); | 349 | connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); |
288 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); | 350 | a->addTo( bar ); |
289 | a->addTo( format ); | 351 | |
290 | // a->setOn(true); | 352 | m_bkmkAvail->setEnabled(false); |
353 | |||
354 | |||
355 | ag = new QActionGroup(this); | ||
356 | // ag->setExclusive(false); | ||
357 | encoding = new QPopupMenu(this); | ||
358 | format->insertItem( tr( "Markup" ), encoding ); | ||
359 | |||
360 | a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true ); | ||
361 | a->setOn(reader->bautofmt); | ||
362 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) ); | ||
363 | |||
364 | a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true ); | ||
365 | a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut)); | ||
366 | // connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); | ||
291 | 367 | ||
292 | a = new QAction( tr( "Strip HTML" ), QString::null, 0, this, NULL, true ); | 368 | a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true ); |
369 | a->setOn(reader->btextfmt); | ||
370 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); | ||
371 | |||
372 | a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true ); | ||
293 | a->setOn(reader->bstriphtml); | 373 | a->setOn(reader->bstriphtml); |
294 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); | 374 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); |
295 | a->addTo( format ); | ||
296 | 375 | ||
297 | a = new QAction( tr( "Dehyphen" ), QString::null, 0, this, NULL, true ); | 376 | a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true ); |
377 | a->setOn(reader->bpeanut); | ||
378 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) ); | ||
379 | |||
380 | ag->addTo(encoding); | ||
381 | |||
382 | |||
383 | |||
384 | ag = new QActionGroup(this); | ||
385 | ag->setExclusive(false); | ||
386 | encoding = new QPopupMenu(this); | ||
387 | format->insertItem( tr( "Layout" ), encoding ); | ||
388 | |||
389 | a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true ); | ||
390 | a->setOn(reader->bstripcr); | ||
391 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); | ||
392 | |||
393 | a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true ); | ||
298 | a->setOn(reader->bdehyphen); | 394 | a->setOn(reader->bdehyphen); |
299 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); | 395 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); |
300 | a->addTo( format ); | 396 | // a->addTo( format ); |
301 | 397 | ||
302 | a = new QAction( tr( "Unindent" ), QString::null, 0, this, NULL, true ); | 398 | a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); |
303 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); | 399 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); |
304 | a->setOn(reader->bunindent); | 400 | a->setOn(reader->bunindent); |
305 | a->addTo( format ); | 401 | // a->addTo( format ); |
306 | 402 | ||
307 | a = new QAction( tr( "Re-paragraph" ), QString::null, 0, this, NULL, true ); | 403 | a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true ); |
308 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); | 404 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); |
309 | a->setOn(reader->brepara); | 405 | a->setOn(reader->brepara); |
310 | a->addTo( format ); | 406 | // a->addTo( format ); |
311 | 407 | ||
312 | a = new QAction( tr( "Double Space" ), QString::null, 0, this, NULL, true ); | 408 | a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true ); |
313 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); | 409 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); |
314 | a->setOn(reader->bdblspce); | 410 | a->setOn(reader->bdblspce); |
315 | a->addTo( format ); | 411 | // a->addTo( format ); |
316 | 412 | ||
317 | a = new QAction( tr( "Indent+" ), QString::null, 0, this, NULL ); | 413 | a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL ); |
318 | connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); | 414 | connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); |
319 | a->addTo( format ); | 415 | // a->addTo( format ); |
320 | 416 | ||
321 | a = new QAction( tr( "Indent-" ), QString::null, 0, this, NULL ); | 417 | a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); |
322 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); | 418 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); |
323 | a->addTo( format ); | ||
324 | 419 | ||
325 | a = new QAction( tr( "Bold" ), QString::null, 0, this, NULL, true ); | 420 | a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); |
326 | a->setOn(reader->m_bBold); | 421 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); |
327 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setbold(bool) ) ); | 422 | a->setOn(reader->bremap); |
328 | a->addTo( format ); | 423 | |
424 | a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true ); | ||
425 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) ); | ||
426 | a->setOn(reader->bmakebold); | ||
427 | |||
428 | ag->addTo(encoding); | ||
329 | 429 | ||
330 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 430 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
@@ -347,9 +447,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
347 | a->addTo( format ); | 447 | a->addTo( format ); |
348 | 448 | ||
349 | QPopupMenu *encoding = new QPopupMenu(this); | 449 | encoding = new QPopupMenu(this); |
350 | format->insertSeparator(); | 450 | // format->insertSeparator(); |
351 | format->insertItem( tr( "Encoding" ), encoding ); | 451 | format->insertItem( tr( "Encoding" ), encoding ); |
352 | 452 | ||
353 | QActionGroup* ag = new QActionGroup(this); | 453 | ag = new QActionGroup(this); |
354 | 454 | ||
355 | m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true ); | 455 | m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true ); |
@@ -380,4 +480,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
380 | a->addTo( marks ); | 480 | a->addTo( marks ); |
381 | 481 | ||
482 | a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL); | ||
483 | connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) ); | ||
484 | a->addTo( marks ); | ||
485 | |||
382 | a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); | 486 | a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); |
383 | connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 487 | connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
@@ -406,4 +510,14 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
406 | a->addTo( marks ); | 510 | a->addTo( marks ); |
407 | 511 | ||
512 | a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); | ||
513 | connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); | ||
514 | marks->insertSeparator(); | ||
515 | a->addTo( marks ); | ||
516 | |||
517 | a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); | ||
518 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | ||
519 | a->addTo( marks ); | ||
520 | |||
521 | |||
408 | mb->insertItem( tr( "File" ), file ); | 522 | mb->insertItem( tr( "File" ), file ); |
409 | // mb->insertItem( tr( "Edit" ), edit ); | 523 | // mb->insertItem( tr( "Edit" ), edit ); |
@@ -411,12 +525,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
411 | mb->insertItem( tr( "Marks" ), marks ); | 525 | mb->insertItem( tr( "Marks" ), marks ); |
412 | 526 | ||
413 | searchBar = new QToolBar( "Search", this, QMainWindow::Top, TRUE ); | 527 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
414 | 528 | ||
415 | searchBar->setHorizontalStretchable( TRUE ); | 529 | searchBar->setHorizontalStretchable( TRUE ); |
416 | 530 | ||
531 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | ||
532 | |||
417 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 533 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
418 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 534 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
419 | // searchEdit->setFont( f ); | 535 | // searchEdit->setFont( f ); |
420 | searchBar->setStretchableWidget( searchEdit ); | 536 | searchBar->setStretchableWidget( searchEdit ); |
537 | |||
421 | #ifdef __ISEARCH | 538 | #ifdef __ISEARCH |
422 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 539 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
@@ -436,5 +553,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
436 | searchBar->hide(); | 553 | searchBar->hide(); |
437 | 554 | ||
438 | regBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 555 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); |
556 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | ||
439 | 557 | ||
440 | regBar->setHorizontalStretchable( TRUE ); | 558 | regBar->setHorizontalStretchable( TRUE ); |
@@ -466,6 +584,19 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
466 | { | 584 | { |
467 | FontDatabase f; | 585 | FontDatabase f; |
468 | m_fontSelector->insertStringList(f.families()); | 586 | QStringList flist = f.families(); |
587 | m_fontSelector->insertStringList(flist); | ||
588 | |||
589 | bool realfont = false; | ||
590 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | ||
591 | { | ||
592 | if (reader->m_fontname == *nm) | ||
593 | { | ||
594 | realfont = true; | ||
595 | break; | ||
596 | } | ||
597 | } | ||
598 | if (!realfont) reader->m_fontname = flist[0]; | ||
469 | } // delete the FontDatabase!!! | 599 | } // delete the FontDatabase!!! |
600 | |||
470 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 601 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), |
471 | this, SLOT( do_setfont(const QString&) ) ); | 602 | this, SLOT( do_setfont(const QString&) ) ); |
@@ -478,4 +609,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
478 | 609 | ||
479 | 610 | ||
611 | reader->init(); | ||
480 | if (!reader->m_lastfile.isEmpty()) | 612 | if (!reader->m_lastfile.isEmpty()) |
481 | { | 613 | { |
@@ -484,4 +616,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
484 | } | 616 | } |
485 | m_EncodingAction[reader->m_encd]->setOn(true); | 617 | m_EncodingAction[reader->m_encd]->setOn(true); |
618 | m_buttonAction[m_spaceTarget]->setOn(true); | ||
486 | do_setfont(reader->m_fontname); | 619 | do_setfont(reader->m_fontname); |
487 | } | 620 | } |
@@ -499,5 +632,6 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
499 | stream >> info; | 632 | stream >> info; |
500 | QMessageBox::information(this, "QTReader", info); | 633 | QMessageBox::information(this, "QTReader", info); |
501 | } else if ( msg == "warn(QString)" ) | 634 | } |
635 | else if ( msg == "warn(QString)" ) | ||
502 | { | 636 | { |
503 | QString info; | 637 | QString info; |
@@ -505,4 +639,240 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
505 | QMessageBox::warning(this, "QTReader", info); | 639 | QMessageBox::warning(this, "QTReader", info); |
506 | } | 640 | } |
641 | |||
642 | |||
643 | else if ( msg == "exit()" ) | ||
644 | { | ||
645 | m_dontSave = true; | ||
646 | close(); | ||
647 | } | ||
648 | else if ( msg == "pageDown()" ) | ||
649 | { | ||
650 | reader->dopagedn(); | ||
651 | } | ||
652 | else if ( msg == "pageUp()" ) | ||
653 | { | ||
654 | reader->dopageup(); | ||
655 | } | ||
656 | else if ( msg == "lineDown()" ) | ||
657 | { | ||
658 | reader->lineDown(); | ||
659 | } | ||
660 | else if ( msg == "lineUp()" ) | ||
661 | { | ||
662 | reader->lineUp(); | ||
663 | } | ||
664 | else if ( msg == "showText()" ) | ||
665 | { | ||
666 | showEditTools(); | ||
667 | } | ||
668 | else if ( msg == "File/Open(QString)" ) | ||
669 | { | ||
670 | QString info; | ||
671 | stream >> info; | ||
672 | openFile( info ); | ||
673 | } | ||
674 | else if ( msg == "File/Info()" ) | ||
675 | { | ||
676 | showinfo(); | ||
677 | } | ||
678 | else if ( msg == "File/Start Block()" ) | ||
679 | { | ||
680 | editMark(); | ||
681 | } | ||
682 | else if ( msg == "File/Copy Block()" ) | ||
683 | { | ||
684 | editCopy(); | ||
685 | } | ||
686 | else if ( msg == "File/Scroll(int)" ) | ||
687 | { | ||
688 | int info; | ||
689 | stream >> info; | ||
690 | autoScroll(info); | ||
691 | } | ||
692 | else if ( msg == "File/Jump(int)" ) | ||
693 | { | ||
694 | int info; | ||
695 | stream >> info; | ||
696 | reader->locate(info); | ||
697 | } | ||
698 | else if ( msg == "File/Page/Line Scroll(int)" ) | ||
699 | { | ||
700 | int info; | ||
701 | stream >> info; | ||
702 | pagemode(info); | ||
703 | } | ||
704 | else if ( msg == "File/Set Overlap(int)" ) | ||
705 | { | ||
706 | int info; | ||
707 | stream >> info; | ||
708 | reader->m_overlap = info; | ||
709 | } | ||
710 | else if ( msg == "File/Set Dictionary(QString)" ) | ||
711 | { | ||
712 | QString info; | ||
713 | stream >> info; | ||
714 | do_settarget(info); | ||
715 | } | ||
716 | else if ( msg == "File/Two/One Touch(int)" ) | ||
717 | { | ||
718 | int info; | ||
719 | stream >> info; | ||
720 | setTwoTouch(info); | ||
721 | } | ||
722 | else if ( msg == "Target/Annotation(int)" ) | ||
723 | { | ||
724 | int info; | ||
725 | stream >> info; | ||
726 | OnAnnotation(info); | ||
727 | } | ||
728 | else if ( msg == "Target/Dictionary(int)" ) | ||
729 | { | ||
730 | int info; | ||
731 | stream >> info; | ||
732 | OnDictionary(info); | ||
733 | } | ||
734 | else if ( msg == "Target/Clipboard(int)" ) | ||
735 | { | ||
736 | int info; | ||
737 | stream >> info; | ||
738 | OnClipboard(info); | ||
739 | } | ||
740 | else if ( msg == "File/Find(QString)" ) | ||
741 | { | ||
742 | QString info; | ||
743 | stream >> info; | ||
744 | QRegExp arg(info); | ||
745 | size_t pos = reader->pagelocate(); | ||
746 | size_t start = pos; | ||
747 | CDrawBuffer test(&(reader->m_fontControl)); | ||
748 | reader->buffdoc.getline(&test,reader->width()); | ||
749 | while (arg.match(toQString(test.data())) == -1) | ||
750 | { | ||
751 | pos = reader->locate(); | ||
752 | if (!reader->buffdoc.getline(&test,reader->width())) | ||
753 | { | ||
754 | QMessageBox::information(this, "QTReader", QString("Can't find\n")+info); | ||
755 | pos = start; | ||
756 | break; | ||
757 | } | ||
758 | } | ||
759 | reader->locate(pos); | ||
760 | } | ||
761 | else if ( msg == "Layout/Strip CR(int)" ) | ||
762 | { | ||
763 | int info; | ||
764 | stream >> info; | ||
765 | stripcr(info); | ||
766 | } | ||
767 | else if ( msg == "Markup/Auto(int)" ) | ||
768 | { | ||
769 | int info; | ||
770 | stream >> info; | ||
771 | autofmt(info); | ||
772 | } | ||
773 | else if ( msg == "Markup/Text(int)" ) | ||
774 | { | ||
775 | int info; | ||
776 | stream >> info; | ||
777 | textfmt(info); | ||
778 | } | ||
779 | else if ( msg == "Markup/HTML(int)" ) | ||
780 | { | ||
781 | int info; | ||
782 | stream >> info; | ||
783 | striphtml(info); | ||
784 | } | ||
785 | else if ( msg == "Markup/Peanut(int)" ) | ||
786 | { | ||
787 | int info; | ||
788 | stream >> info; | ||
789 | peanut(info); | ||
790 | } | ||
791 | else if ( msg == "Layout/Dehyphen(int)" ) | ||
792 | { | ||
793 | int info; | ||
794 | stream >> info; | ||
795 | dehyphen(info); | ||
796 | } | ||
797 | else if ( msg == "Layout/Unindent(int)" ) | ||
798 | { | ||
799 | int info; | ||
800 | stream >> info; | ||
801 | unindent(info); | ||
802 | } | ||
803 | else if ( msg == "Layout/Re-paragraph(int)" ) | ||
804 | { | ||
805 | int info; | ||
806 | stream >> info; | ||
807 | repara(info); | ||
808 | } | ||
809 | else if ( msg == "Layout/Double Space(int)" ) | ||
810 | { | ||
811 | int info; | ||
812 | stream >> info; | ||
813 | dblspce(info); | ||
814 | } | ||
815 | else if ( msg == "Layout/Indent(int)" ) | ||
816 | { | ||
817 | int info; | ||
818 | stream >> info; | ||
819 | reader->bindenter = info; | ||
820 | reader->setfilter(reader->getfilter()); | ||
821 | } | ||
822 | else if ( msg == "Layout/Remap(int)" ) | ||
823 | { | ||
824 | int info; | ||
825 | stream >> info; | ||
826 | remap(info); | ||
827 | } | ||
828 | else if ( msg == "Layout/Embolden(int)" ) | ||
829 | { | ||
830 | int info; | ||
831 | stream >> info; | ||
832 | embolden(info); | ||
833 | } | ||
834 | else if ( msg == "Format/Ideogram/Word(int)" ) | ||
835 | { | ||
836 | int info; | ||
837 | stream >> info; | ||
838 | monospace(info); | ||
839 | } | ||
840 | else if ( msg == "Format/Set width(int)" ) | ||
841 | { | ||
842 | int info; | ||
843 | stream >> info; | ||
844 | reader->m_charpc = info; | ||
845 | reader->setfont(); | ||
846 | reader->refresh(); | ||
847 | } | ||
848 | else if ( msg == "Format/Encoding(QString)" ) | ||
849 | { | ||
850 | QString info; | ||
851 | stream >> info; | ||
852 | reader->setencoding(EncNameToInt(info)); | ||
853 | } | ||
854 | else if ( msg == "Format/Set Font(QString,int)" ) | ||
855 | { | ||
856 | QString fontname; | ||
857 | int size; | ||
858 | stream >> fontname; | ||
859 | stream >> size; | ||
860 | setfontHelper(fontname, size); | ||
861 | } | ||
862 | else if ( msg == "Marks/Autogen(QString)" ) | ||
863 | { | ||
864 | QString info; | ||
865 | stream >> info; | ||
866 | do_autogen(info); | ||
867 | } | ||
868 | } | ||
869 | |||
870 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | ||
871 | { | ||
872 | for (int i = 0; i < MAX_ACTIONS; i++) | ||
873 | { | ||
874 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; | ||
875 | } | ||
876 | return cesAutoScroll; | ||
507 | } | 877 | } |
508 | 878 | ||
@@ -528,4 +898,10 @@ void QTReaderApp::encodingSelected(QAction* _a) | |||
528 | } | 898 | } |
529 | 899 | ||
900 | void QTReaderApp::buttonActionSelected(QAction* _a) | ||
901 | { | ||
902 | // qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); | ||
903 | m_spaceTarget = ActNameToInt(_a->text()); | ||
904 | } | ||
905 | |||
530 | QTReaderApp::~QTReaderApp() | 906 | QTReaderApp::~QTReaderApp() |
531 | { | 907 | { |
@@ -590,4 +966,5 @@ void QTReaderApp::fileOpen() | |||
590 | } | 966 | } |
591 | delete fb; | 967 | delete fb; |
968 | reader->setFocus(); | ||
592 | } | 969 | } |
593 | 970 | ||
@@ -613,4 +990,105 @@ void QTReaderApp::showinfo() | |||
613 | } | 990 | } |
614 | 991 | ||
992 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) | ||
993 | { | ||
994 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | ||
995 | #ifdef _UNICODE | ||
996 | CBuffer buff(name.length()+1); | ||
997 | int i; | ||
998 | for (i = 0; i < name.length(); i++) | ||
999 | { | ||
1000 | buff[i] = name[i].unicode(); | ||
1001 | } | ||
1002 | buff[i] = 0; | ||
1003 | CBuffer buff2(text.length()+1); | ||
1004 | for (i = 0; i < text.length(); i++) | ||
1005 | { | ||
1006 | buff2[i] = text[i].unicode(); | ||
1007 | } | ||
1008 | buff2[i] = 0; | ||
1009 | pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); | ||
1010 | #else | ||
1011 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | ||
1012 | #endif | ||
1013 | m_fBkmksChanged = true; | ||
1014 | pBkmklist->sort(); | ||
1015 | } | ||
1016 | |||
1017 | void QTReaderApp::addAnno(const QString& name, const QString& text) | ||
1018 | { | ||
1019 | if (m_annoIsEditing) | ||
1020 | { | ||
1021 | if (name.isEmpty()) | ||
1022 | { | ||
1023 | QMessageBox::information(this, "QTReader", "Need a name for the bookmark\nPlease try again", 1); | ||
1024 | } | ||
1025 | else | ||
1026 | { | ||
1027 | addAnno(name, text, m_annoWin->getPosn()); | ||
1028 | } | ||
1029 | showEditTools(); | ||
1030 | } | ||
1031 | else | ||
1032 | { | ||
1033 | if (m_annoWin->edited()) | ||
1034 | { | ||
1035 | CBuffer buff(text.length()+1); | ||
1036 | int i; | ||
1037 | for (i = 0; i < text.length(); i++) | ||
1038 | { | ||
1039 | buff[i] = text[i].unicode(); | ||
1040 | } | ||
1041 | buff[i] = 0; | ||
1042 | m_fBkmksChanged = true; | ||
1043 | m_anno->setAnno(buff.data()); | ||
1044 | } | ||
1045 | bool found = findNextBookmark(m_anno->value()+1); | ||
1046 | if (found) | ||
1047 | { | ||
1048 | m_annoWin->setName(toQString(m_anno->name())); | ||
1049 | m_annoWin->setAnno(toQString(m_anno->anno())); | ||
1050 | } | ||
1051 | else | ||
1052 | { | ||
1053 | showEditTools(); | ||
1054 | } | ||
1055 | } | ||
1056 | } | ||
1057 | |||
1058 | bool QTReaderApp::findNextBookmark(size_t start) | ||
1059 | { | ||
1060 | bool found = false; | ||
1061 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | ||
1062 | { | ||
1063 | if (iter->value() >= start) | ||
1064 | { | ||
1065 | if (iter->value() < reader->locate()) | ||
1066 | { | ||
1067 | found = true; | ||
1068 | m_anno = iter.pContent(); | ||
1069 | } | ||
1070 | break; | ||
1071 | } | ||
1072 | } | ||
1073 | return found; | ||
1074 | } | ||
1075 | |||
1076 | void QTReaderApp::addanno() | ||
1077 | { | ||
1078 | if (reader->empty()) | ||
1079 | { | ||
1080 | QMessageBox::information(this, "QTReader", "No file loaded", 1); | ||
1081 | } | ||
1082 | else | ||
1083 | { | ||
1084 | m_annoWin->setName(""); | ||
1085 | m_annoWin->setAnno(""); | ||
1086 | m_annoWin->setPosn(reader->pagelocate()); | ||
1087 | m_annoIsEditing = true; | ||
1088 | editorStack->raiseWidget( m_annoWin ); | ||
1089 | m_annoWin->setFocus(); | ||
1090 | } | ||
1091 | } | ||
1092 | |||
615 | void QTReaderApp::infoClose() | 1093 | void QTReaderApp::infoClose() |
616 | { | 1094 | { |
@@ -645,17 +1123,10 @@ void QTReaderApp::editCopy() | |||
645 | unsigned long endpos = reader->locate(); | 1123 | unsigned long endpos = reader->locate(); |
646 | reader->jumpto(m_savedpos); | 1124 | reader->jumpto(m_savedpos); |
647 | while (reader->locate() < endpos && (ch = reader->getch()) != UEOF) | 1125 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
648 | { | 1126 | { |
649 | text += ch; | 1127 | text += ch; |
650 | } | 1128 | } |
651 | cb->setText(text); | 1129 | cb->setText(text); |
652 | // text = cb->text(); | ||
653 | // if (text) | ||
654 | // qDebug("The clipboard contains: %s", (const tchar*)text); | ||
655 | reader->locate(currentpos); | 1130 | reader->locate(currentpos); |
656 | #ifndef QT_NO_CLIPBOARD | ||
657 | // TBD(); | ||
658 | // reader->copy(); | ||
659 | #endif | ||
660 | } | 1131 | } |
661 | 1132 | ||
@@ -674,4 +1145,24 @@ void QTReaderApp::stripcr(bool _b) | |||
674 | reader->setstripcr(_b); | 1145 | reader->setstripcr(_b); |
675 | } | 1146 | } |
1147 | void QTReaderApp::remap(bool _b) | ||
1148 | { | ||
1149 | reader->setremap(_b); | ||
1150 | } | ||
1151 | void QTReaderApp::peanut(bool _b) | ||
1152 | { | ||
1153 | reader->setpeanut(_b); | ||
1154 | } | ||
1155 | void QTReaderApp::embolden(bool _b) | ||
1156 | { | ||
1157 | reader->setmakebold(_b); | ||
1158 | } | ||
1159 | void QTReaderApp::autofmt(bool _b) | ||
1160 | { | ||
1161 | reader->setautofmt(_b); | ||
1162 | } | ||
1163 | void QTReaderApp::textfmt(bool _b) | ||
1164 | { | ||
1165 | reader->settextfmt(_b); | ||
1166 | } | ||
676 | void QTReaderApp::striphtml(bool _b) | 1167 | void QTReaderApp::striphtml(bool _b) |
677 | { | 1168 | { |
@@ -690,10 +1181,4 @@ void QTReaderApp::repara(bool _b) | |||
690 | reader->setrepara(_b); | 1181 | reader->setrepara(_b); |
691 | } | 1182 | } |
692 | void QTReaderApp::setbold(bool _b) | ||
693 | { | ||
694 | reader->m_bBold = _b; | ||
695 | reader->ChangeFont(reader->fontsizes[reader->m_textsize]); | ||
696 | reader->refresh(); | ||
697 | } | ||
698 | void QTReaderApp::dblspce(bool _b) | 1183 | void QTReaderApp::dblspce(bool _b) |
699 | { | 1184 | { |
@@ -731,7 +1216,7 @@ void QTReaderApp::settarget() | |||
731 | { | 1216 | { |
732 | m_nRegAction = cSetTarget; | 1217 | m_nRegAction = cSetTarget; |
733 | QString text = ((reader->m_targetapp.isEmpty()) ? QString("") : reader->m_targetapp) | 1218 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
734 | + "/" | 1219 | + "/" |
735 | + ((reader->m_targetmsg.isEmpty()) ? QString("") : reader->m_targetmsg); | 1220 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
736 | regEdit->setText(text); | 1221 | regEdit->setText(text); |
737 | do_regedit(); | 1222 | do_regedit(); |
@@ -757,4 +1242,6 @@ void QTReaderApp::do_mono(const QString& lcn) | |||
757 | { | 1242 | { |
758 | reader->m_charpc = ulcn; | 1243 | reader->m_charpc = ulcn; |
1244 | reader->setfont(); | ||
1245 | reader->refresh(); | ||
759 | // reader->setmono(true); | 1246 | // reader->setmono(true); |
760 | } | 1247 | } |
@@ -794,5 +1281,5 @@ void QTReaderApp::findNext() | |||
794 | QRegExp arg = searchEdit->text(); | 1281 | QRegExp arg = searchEdit->text(); |
795 | #endif | 1282 | #endif |
796 | CBuffer test; | 1283 | CDrawBuffer test(&(reader->m_fontControl)); |
797 | size_t start = reader->pagelocate(); | 1284 | size_t start = reader->pagelocate(); |
798 | reader->jumpto(start); | 1285 | reader->jumpto(start); |
@@ -826,11 +1313,11 @@ void QTReaderApp::regClose() | |||
826 | 1313 | ||
827 | #ifdef __ISEARCH | 1314 | #ifdef __ISEARCH |
828 | bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QString& arg) | 1315 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
829 | #else | 1316 | #else |
830 | bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg) | 1317 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
831 | #endif | 1318 | #endif |
832 | { | 1319 | { |
833 | bool ret = true; | 1320 | bool ret = true; |
834 | size_t pos = start; | 1321 | size_t pos = reader->locate(); |
835 | reader->buffdoc.getline(&test,reader->width()); | 1322 | reader->buffdoc.getline(&test,reader->width()); |
836 | #ifdef __ISEARCH | 1323 | #ifdef __ISEARCH |
@@ -896,9 +1383,5 @@ void QTReaderApp::search(const QString & arg) | |||
896 | void QTReaderApp::search() | 1383 | void QTReaderApp::search() |
897 | { | 1384 | { |
898 | QRegExp arg = searchEdit->text(); | 1385 | findNext(); |
899 | CBuffer test; | ||
900 | size_t start = reader->pagelocate(); | ||
901 | // reader->jumpto(start); | ||
902 | dosearch(start, test, arg); | ||
903 | } | 1386 | } |
904 | #endif | 1387 | #endif |
@@ -946,5 +1429,5 @@ void QTReaderApp::showEditTools() | |||
946 | close(); | 1429 | close(); |
947 | // fileSelector->hide(); | 1430 | // fileSelector->hide(); |
948 | menu->show(); | 1431 | //tjw menu->show(); |
949 | editBar->show(); | 1432 | editBar->show(); |
950 | if ( searchVisible ) | 1433 | if ( searchVisible ) |
@@ -1004,10 +1487,10 @@ void QTReaderApp::updateCaption() | |||
1004 | { | 1487 | { |
1005 | if ( !doc ) | 1488 | if ( !doc ) |
1006 | setCaption( tr("Opie Reader") ); | 1489 | setCaption( tr("QTReader") ); |
1007 | else { | 1490 | else { |
1008 | QString s = doc->name(); | 1491 | QString s = doc->name(); |
1009 | if ( s.isEmpty() ) | 1492 | if ( s.isEmpty() ) |
1010 | s = tr( "Unnamed" ); | 1493 | s = tr( "Unnamed" ); |
1011 | setCaption( s + " - " + tr("Opie Reader") ); | 1494 | setCaption( s + " - " + tr("QTReader") ); |
1012 | } | 1495 | } |
1013 | } | 1496 | } |
@@ -1023,4 +1506,10 @@ void QTReaderApp::setDocument(const QString& fileref) | |||
1023 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 1506 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
1024 | { | 1507 | { |
1508 | if (m_dontSave) | ||
1509 | { | ||
1510 | e->accept(); | ||
1511 | } | ||
1512 | else | ||
1513 | { | ||
1025 | if (editorStack->visibleWidget() == reader) | 1514 | if (editorStack->visibleWidget() == reader) |
1026 | { | 1515 | { |
@@ -1059,4 +1548,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1059 | } | 1548 | } |
1060 | } | 1549 | } |
1550 | } | ||
1061 | 1551 | ||
1062 | void QTReaderApp::do_gotomark() | 1552 | void QTReaderApp::do_gotomark() |
@@ -1078,5 +1568,4 @@ void QTReaderApp::listbkmk() | |||
1078 | if (pBkmklist != NULL) | 1568 | if (pBkmklist != NULL) |
1079 | { | 1569 | { |
1080 | if (m_fBkmksChanged) pBkmklist->sort(); | ||
1081 | for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) | 1570 | for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) |
1082 | { | 1571 | { |
@@ -1091,5 +1580,5 @@ void QTReaderApp::listbkmk() | |||
1091 | if (cnt > 0) | 1580 | if (cnt > 0) |
1092 | { | 1581 | { |
1093 | menu->hide(); | 1582 | //tjw menu->hide(); |
1094 | editBar->hide(); | 1583 | editBar->hide(); |
1095 | if (m_fontVisible) m_fontBar->hide(); | 1584 | if (m_fontVisible) m_fontBar->hide(); |
@@ -1128,4 +1617,5 @@ void QTReaderApp::gotobkmk(int ind) | |||
1128 | pBkmklist->erase(ind); | 1617 | pBkmklist->erase(ind); |
1129 | m_fBkmksChanged = true; | 1618 | m_fBkmksChanged = true; |
1619 | // pBkmklist->sort(); | ||
1130 | break; | 1620 | break; |
1131 | case cRmBkmkFile: | 1621 | case cRmBkmkFile: |
@@ -1195,12 +1685,12 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
1195 | if (ind == -1) | 1685 | if (ind == -1) |
1196 | { | 1686 | { |
1197 | reader->m_targetapp = ""; | 1687 | m_targetapp = ""; |
1198 | reader->m_targetmsg = ""; | 1688 | m_targetmsg = ""; |
1199 | QMessageBox::information(this, "QTReader", "Format is\nappname/messagename"); | 1689 | QMessageBox::information(this, "QTReader", "Format is\nappname/messagename"); |
1200 | } | 1690 | } |
1201 | else | 1691 | else |
1202 | { | 1692 | { |
1203 | reader->m_targetapp = _txt.left(ind); | 1693 | m_targetapp = _txt.left(ind); |
1204 | reader->m_targetmsg = _txt.right(_txt.length()-ind-1); | 1694 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
1205 | } | 1695 | } |
1206 | } | 1696 | } |
@@ -1220,12 +1710,17 @@ void QTReaderApp::setfont() | |||
1220 | } | 1710 | } |
1221 | 1711 | ||
1222 | void QTReaderApp::do_setfont(const QString& lcn) | 1712 | void QTReaderApp::setfontHelper(const QString& lcn, int size = 0) |
1223 | { | 1713 | { |
1714 | if (size == 0) size = reader->m_fontControl.currentsize(); | ||
1224 | QFont f(lcn, 10 /*, QFont::Bold*/); | 1715 | QFont f(lcn, 10 /*, QFont::Bold*/); |
1225 | bkmkselector->setFont( f ); | 1716 | bkmkselector->setFont( f ); |
1226 | regEdit->setFont( f ); | 1717 | regEdit->setFont( f ); |
1227 | searchEdit->setFont( f ); | 1718 | searchEdit->setFont( f ); |
1719 | m_annoWin->setFont( f ); | ||
1228 | reader->m_fontname = lcn; | 1720 | reader->m_fontname = lcn; |
1229 | reader->ChangeFont(reader->fontsizes[reader->m_textsize]); | 1721 | if (!reader->ChangeFont(size)) |
1722 | { | ||
1723 | reader->ChangeFont(size); | ||
1724 | } | ||
1230 | reader->refresh(); | 1725 | reader->refresh(); |
1231 | m_fontBar->hide(); | 1726 | m_fontBar->hide(); |
@@ -1234,4 +1729,9 @@ void QTReaderApp::do_setfont(const QString& lcn) | |||
1234 | } | 1729 | } |
1235 | 1730 | ||
1731 | void QTReaderApp::do_setfont(const QString& lcn) | ||
1732 | { | ||
1733 | setfontHelper(lcn); | ||
1734 | } | ||
1735 | |||
1236 | void QTReaderApp::do_autogen(const QString& regText) | 1736 | void QTReaderApp::do_autogen(const QString& regText) |
1237 | { | 1737 | { |
@@ -1271,6 +1771,7 @@ pbar->resize(width(), editBar->height()); | |||
1271 | if (re.match(buff.data()) != -1) | 1771 | if (re.match(buff.data()) != -1) |
1272 | #endif | 1772 | #endif |
1273 | pBkmklist->push_back(Bkmk(buff.data(),lcn)); | 1773 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
1274 | } | 1774 | } |
1775 | pBkmklist->sort(); | ||
1275 | pbar->setProgress(100); | 1776 | pbar->setProgress(100); |
1276 | qApp->processEvents(); | 1777 | qApp->processEvents(); |
@@ -1287,4 +1788,6 @@ void QTReaderApp::saveprefs() | |||
1287 | 1788 | ||
1288 | config.writeEntry( "StripCr", reader->bstripcr ); | 1789 | config.writeEntry( "StripCr", reader->bstripcr ); |
1790 | config.writeEntry( "AutoFmt", reader->bautofmt ); | ||
1791 | config.writeEntry( "TextFmt", reader->btextfmt ); | ||
1289 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 1792 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
1290 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 1793 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
@@ -1293,6 +1796,5 @@ void QTReaderApp::saveprefs() | |||
1293 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 1796 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
1294 | config.writeEntry( "Indent", reader->bindenter ); | 1797 | config.writeEntry( "Indent", reader->bindenter ); |
1295 | config.writeEntry( "FontSize", (int)(reader->fontsizes[reader->m_textsize]) ); | 1798 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
1296 | config.writeEntry( "Bold", reader->m_bBold ); | ||
1297 | config.writeEntry( "ScrollDelay", reader->m_delay); | 1799 | config.writeEntry( "ScrollDelay", reader->m_delay); |
1298 | config.writeEntry( "LastFile", reader->m_lastfile ); | 1800 | config.writeEntry( "LastFile", reader->m_lastfile ); |
@@ -1304,6 +1806,14 @@ void QTReaderApp::saveprefs() | |||
1304 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 1806 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
1305 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 1807 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
1306 | config.writeEntry( "TargetApp", reader->m_targetapp ); | 1808 | config.writeEntry( "TargetApp", m_targetapp ); |
1307 | config.writeEntry( "TargetMsg", reader->m_targetmsg ); | 1809 | config.writeEntry( "TargetMsg", m_targetmsg ); |
1810 | config.writeEntry( "TwoTouch", m_twoTouch ); | ||
1811 | config.writeEntry( "Annotation", m_doAnnotation); | ||
1812 | config.writeEntry( "Dictionary", m_doDictionary); | ||
1813 | config.writeEntry( "Clipboard", m_doClipboard); | ||
1814 | config.writeEntry( "SpaceTarget", m_spaceTarget); | ||
1815 | config.writeEntry( "Remap", reader->bremap ); | ||
1816 | config.writeEntry( "Peanut", reader->bpeanut ); | ||
1817 | config.writeEntry( "MakeBold", reader->bmakebold ); | ||
1308 | } | 1818 | } |
1309 | 1819 | ||
@@ -1392,5 +1902,5 @@ void QTReaderApp::readbkmks() | |||
1392 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); | 1902 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); |
1393 | pBkmklist = bf.readall(); | 1903 | pBkmklist = bf.readall(); |
1394 | m_fBkmksChanged = false; | 1904 | m_fBkmksChanged = bf.upgraded(); |
1395 | if (pBkmklist == NULL) | 1905 | if (pBkmklist == NULL) |
1396 | { | 1906 | { |
@@ -1425,9 +1935,95 @@ void QTReaderApp::do_addbkmk(const QString& text) | |||
1425 | } | 1935 | } |
1426 | buff[i] = 0; | 1936 | buff[i] = 0; |
1427 | pBkmklist->push_front(Bkmk(buff.data(), reader->pagelocate())); | 1937 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); |
1428 | #else | 1938 | #else |
1429 | pBkmklist->push_front(Bkmk((const tchar*)text,reader->pagelocate())); | 1939 | pBkmklist->push_front(Bkmk((const tchar*)text,reader->pagelocate())); |
1430 | #endif | 1940 | #endif |
1431 | m_fBkmksChanged = true; | 1941 | m_fBkmksChanged = true; |
1942 | pBkmklist->sort(); | ||
1432 | } | 1943 | } |
1433 | } | 1944 | } |
1945 | |||
1946 | void QTReaderApp::OnRedraw() | ||
1947 | { | ||
1948 | if (pBkmklist != NULL) | ||
1949 | { | ||
1950 | bool found = findNextBookmark(reader->pagelocate()); | ||
1951 | m_bkmkAvail->setEnabled(found); | ||
1952 | } | ||
1953 | } | ||
1954 | |||
1955 | void QTReaderApp::showAnnotation() | ||
1956 | { | ||
1957 | m_annoWin->setName(toQString(m_anno->name())); | ||
1958 | m_annoWin->setAnno(toQString(m_anno->anno())); | ||
1959 | m_annoIsEditing = false; | ||
1960 | editorStack->raiseWidget( m_annoWin ); | ||
1961 | m_annoWin->setFocus(); | ||
1962 | } | ||
1963 | |||
1964 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) | ||
1965 | { | ||
1966 | // qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); | ||
1967 | |||
1968 | if (m_doClipboard) | ||
1969 | { | ||
1970 | QClipboard* cb = QApplication::clipboard(); | ||
1971 | cb->setText(wrd); | ||
1972 | if (wrd.length() > 10) | ||
1973 | { | ||
1974 | Global::statusMessage(wrd.left(8) + ".."); | ||
1975 | } | ||
1976 | else | ||
1977 | { | ||
1978 | Global::statusMessage(wrd); | ||
1979 | } | ||
1980 | } | ||
1981 | if (m_doAnnotation) | ||
1982 | { | ||
1983 | //addAnno(wrd, "Need to be able to edit this", posn); | ||
1984 | m_annoWin->setName(line); | ||
1985 | m_annoWin->setAnno(""); | ||
1986 | m_annoWin->setPosn(posn); | ||
1987 | m_annoIsEditing = true; | ||
1988 | editorStack->raiseWidget( m_annoWin ); | ||
1989 | } | ||
1990 | if (m_doDictionary) | ||
1991 | { | ||
1992 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) | ||
1993 | { | ||
1994 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); | ||
1995 | e << wrd; | ||
1996 | } | ||
1997 | } | ||
1998 | } | ||
1999 | |||
2000 | void QTReaderApp::OnActionPressed() | ||
2001 | { | ||
2002 | switch (m_spaceTarget) | ||
2003 | { | ||
2004 | case cesOpenFile: | ||
2005 | { | ||
2006 | fileOpen(); | ||
2007 | } | ||
2008 | break; | ||
2009 | case cesAutoScroll: | ||
2010 | { | ||
2011 | reader->setautoscroll(!reader->m_autoScroll); | ||
2012 | setScrollState(reader->m_autoScroll); | ||
2013 | } | ||
2014 | break; | ||
2015 | case cesActionMark: | ||
2016 | { | ||
2017 | addbkmk(); | ||
2018 | } | ||
2019 | break; | ||
2020 | default: | ||
2021 | { | ||
2022 | qDebug("Unknown ActionType:%u", m_spaceTarget); | ||
2023 | } | ||
2024 | break; | ||
2025 | } | ||
2026 | } | ||
2027 | |||
2028 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | ||
2029 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | ||