Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 1224 |
1 files changed, 910 insertions, 314 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 68c80c1..0608b66 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -20,2 +20,3 @@ | |||
20 | 20 | ||
21 | #include <qclipboard.h> | ||
21 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
@@ -40,6 +41,10 @@ | |||
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> |
@@ -51,2 +56,3 @@ | |||
51 | #include "fileBrowser.h" | 56 | #include "fileBrowser.h" |
57 | #include "CDrawBuffer.h" | ||
52 | 58 | ||
@@ -70,12 +76,12 @@ void QTReaderApp::listBkmkFiles() | |||
70 | { | 76 | { |
71 | struct dirent* de; | 77 | struct dirent* de; |
72 | struct stat buf; | 78 | struct stat buf; |
73 | de = readdir(d); | 79 | de = readdir(d); |
74 | if (de == NULL) break; | 80 | if (de == NULL) break; |
75 | 81 | ||
76 | if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 82 | if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
77 | { | 83 | { |
78 | bkmkselector->insertItem(de->d_name); | 84 | bkmkselector->insertItem(de->d_name); |
79 | cnt++; | 85 | cnt++; |
80 | } | 86 | } |
81 | } | 87 | } |
@@ -86,3 +92,3 @@ void QTReaderApp::listBkmkFiles() | |||
86 | { | 92 | { |
87 | menu->hide(); | 93 | //tjw menu->hide(); |
88 | editBar->hide(); | 94 | editBar->hide(); |
@@ -91,3 +97,3 @@ void QTReaderApp::listBkmkFiles() | |||
91 | if (searchVisible) searchBar->hide(); | 97 | if (searchVisible) searchBar->hide(); |
92 | m_nRegAction = cRmBkmkFile; | 98 | m_nRegAction = cRmBkmkFile; |
93 | editorStack->raiseWidget( bkmkselector ); | 99 | editorStack->raiseWidget( bkmkselector ); |
@@ -99,3 +105,3 @@ void QTReaderApp::listBkmkFiles() | |||
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 | { |
@@ -107,3 +113,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
107 | 113 | ||
108 | m_fBkmksChanged = false; | 114 | m_fBkmksChanged = false; |
109 | 115 | ||
@@ -111,3 +117,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
111 | 117 | ||
112 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 118 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
113 | setToolBarsMovable( FALSE ); | 119 | setToolBarsMovable( FALSE ); |
@@ -119,3 +125,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
119 | addToolBar(bar, "tool",QMainWindow::Top, true); | 125 | addToolBar(bar, "tool",QMainWindow::Top, true); |
120 | menu = bar; | 126 | //tjw menu = bar; |
121 | 127 | ||
@@ -146,2 +152,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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); |
@@ -168,2 +179,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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" ); |
@@ -172,3 +186,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 ); |
@@ -179,3 +196,2 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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); |
@@ -189,5 +205,17 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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() ); |
@@ -214,12 +242,18 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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); | ||
223 | 254 | ||
224 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true ); | 255 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); |
256 | |||
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() ) ); |
@@ -244,3 +278,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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) ) ); |
@@ -253,2 +287,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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); |
@@ -257,2 +293,27 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 | /* |
@@ -278,6 +339,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 ); |
@@ -285,45 +347,83 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 ); | ||
290 | // a->setOn(true); | ||
291 | 351 | ||
292 | a = new QAction( tr( "Strip HTML" ), QString::null, 0, this, NULL, 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) ) ); | ||
367 | |||
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 | ||
@@ -348,7 +448,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 | ||
@@ -381,2 +481,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 ); |
@@ -407,2 +511,12 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 ); |
@@ -412,3 +526,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
412 | 526 | ||
413 | searchBar = new QToolBar( "Search", this, QMainWindow::Top, TRUE ); | 527 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
414 | 528 | ||
@@ -416,2 +530,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
416 | 530 | ||
531 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | ||
532 | |||
417 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 533 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
@@ -420,8 +536,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags 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 & ) ), |
423 | this, SLOT( search( const QString& ) ) ); | 540 | this, SLOT( search( const QString& ) ) ); |
424 | #else | 541 | #else |
425 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 542 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
426 | this, SLOT( search( ) ) ); | 543 | this, SLOT( search( ) ) ); |
427 | #endif | 544 | #endif |
@@ -437,3 +554,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
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 | ||
@@ -447,3 +565,3 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
447 | connect( regEdit, SIGNAL( returnPressed( ) ), | 565 | connect( regEdit, SIGNAL( returnPressed( ) ), |
448 | this, SLOT( do_regaction() ) ); | 566 | this, SLOT( do_regaction() ) ); |
449 | 567 | ||
@@ -466,7 +584,20 @@ 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&) ) ); |
472 | 603 | ||
@@ -476,11 +607,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
476 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 607 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
477 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 608 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
478 | 609 | ||
479 | 610 | ||
611 | reader->init(); | ||
480 | if (!reader->m_lastfile.isEmpty()) | 612 | if (!reader->m_lastfile.isEmpty()) |
481 | { | 613 | { |
482 | openFile( reader->m_lastfile ); | 614 | openFile( reader->m_lastfile ); |
483 | doc = new DocLnk(reader->m_lastfile); | 615 | doc = new DocLnk(reader->m_lastfile); |
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); |
@@ -497,10 +630,238 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
497 | { | 630 | { |
498 | QString info; | 631 | QString info; |
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)" ) | ||
636 | { | ||
637 | QString info; | ||
638 | stream >> info; | ||
639 | QMessageBox::warning(this, "QTReader", info); | ||
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)" ) | ||
502 | { | 855 | { |
503 | QString info; | 856 | QString fontname; |
504 | stream >> info; | 857 | int size; |
505 | QMessageBox::warning(this, "QTReader", info); | 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); | ||
506 | } | 867 | } |
@@ -508,2 +869,11 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
508 | 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; | ||
877 | } | ||
878 | |||
509 | int QTReaderApp::EncNameToInt(const QString& _enc) | 879 | int QTReaderApp::EncNameToInt(const QString& _enc) |
@@ -512,3 +882,3 @@ int QTReaderApp::EncNameToInt(const QString& _enc) | |||
512 | { | 882 | { |
513 | if (m_EncodingAction[i]->text() == _enc) return i; | 883 | if (m_EncodingAction[i]->text() == _enc) return i; |
514 | } | 884 | } |
@@ -529,2 +899,8 @@ void QTReaderApp::encodingSelected(QAction* _a) | |||
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() |
@@ -550,5 +926,5 @@ void QTReaderApp::clearBkmkList() | |||
550 | { | 926 | { |
551 | delete pBkmklist; | 927 | delete pBkmklist; |
552 | pBkmklist = NULL; | 928 | pBkmklist = NULL; |
553 | m_fBkmksChanged = false; | 929 | m_fBkmksChanged = false; |
554 | } | 930 | } |
@@ -565,10 +941,10 @@ void QTReaderApp::fileOpen() | |||
565 | { | 941 | { |
566 | if (m_fBkmksChanged) | 942 | if (m_fBkmksChanged) |
567 | { | 943 | { |
568 | if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0) | 944 | if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0) |
569 | savebkmks(); | 945 | savebkmks(); |
570 | } | 946 | } |
571 | delete pBkmklist; | 947 | delete pBkmklist; |
572 | pBkmklist = NULL; | 948 | pBkmklist = NULL; |
573 | m_fBkmksChanged = false; | 949 | m_fBkmksChanged = false; |
574 | } | 950 | } |
@@ -580,5 +956,5 @@ void QTReaderApp::fileOpen() | |||
580 | fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, | 956 | fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, |
581 | 0, | 957 | 0, |
582 | // WStyle_Customize | WStyle_NoBorderEx, | 958 | // WStyle_Customize | WStyle_NoBorderEx, |
583 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 959 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
584 | 960 | ||
@@ -586,7 +962,8 @@ void QTReaderApp::fileOpen() | |||
586 | { | 962 | { |
587 | QString fn(fb->fileList[0]); | 963 | QString fn(fb->fileList[0]); |
588 | // fb->populateList(); | 964 | // fb->populateList(); |
589 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | 965 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); |
590 | } | 966 | } |
591 | delete fb; | 967 | delete fb; |
968 | reader->setFocus(); | ||
592 | } | 969 | } |
@@ -598,3 +975,3 @@ void QTReaderApp::showinfo() | |||
598 | { | 975 | { |
599 | QMessageBox::information(this, "QTReader", "No file loaded", 1); | 976 | QMessageBox::information(this, "QTReader", "No file loaded", 1); |
600 | } | 977 | } |
@@ -602,11 +979,112 @@ void QTReaderApp::showinfo() | |||
602 | { | 979 | { |
603 | reader->sizes(fs,ts); | 980 | reader->sizes(fs,ts); |
604 | pl = reader->pagelocate(); | 981 | pl = reader->pagelocate(); |
605 | m_infoWin->setFileSize(fs); | 982 | m_infoWin->setFileSize(fs); |
606 | m_infoWin->setTextSize(ts); | 983 | m_infoWin->setTextSize(ts); |
607 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 984 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
608 | m_infoWin->setLocation(pl); | 985 | m_infoWin->setLocation(pl); |
609 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 986 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
610 | editorStack->raiseWidget( m_infoWin ); | 987 | editorStack->raiseWidget( m_infoWin ); |
611 | m_infoWin->setFocus(); | 988 | m_infoWin->setFocus(); |
989 | } | ||
990 | } | ||
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(); | ||
612 | } | 1090 | } |
@@ -640,21 +1118,14 @@ void QTReaderApp::editCopy() | |||
640 | { | 1118 | { |
641 | QClipboard* cb = QApplication::clipboard(); | 1119 | QClipboard* cb = QApplication::clipboard(); |
642 | QString text; | 1120 | QString text; |
643 | int ch; | 1121 | int ch; |
644 | unsigned long currentpos = reader->pagelocate(); | 1122 | unsigned long currentpos = reader->pagelocate(); |
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(); | 1130 | reader->locate(currentpos); |
653 | // if (text) | ||
654 | // qDebug("The clipboard contains: %s", (const tchar*)text); | ||
655 | reader->locate(currentpos); | ||
656 | #ifndef QT_NO_CLIPBOARD | ||
657 | // TBD(); | ||
658 | // reader->copy(); | ||
659 | #endif | ||
660 | } | 1131 | } |
@@ -675,2 +1146,22 @@ void QTReaderApp::stripcr(bool _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) |
@@ -691,8 +1182,2 @@ void QTReaderApp::repara(bool _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) |
@@ -732,5 +1217,5 @@ void QTReaderApp::settarget() | |||
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); |
@@ -745,6 +1230,6 @@ void QTReaderApp::do_overlap(const QString& lcn) | |||
745 | { | 1230 | { |
746 | reader->m_overlap = ulcn; | 1231 | reader->m_overlap = ulcn; |
747 | } | 1232 | } |
748 | else | 1233 | else |
749 | QMessageBox::information(this, "QTReader", "Must be a number"); | 1234 | QMessageBox::information(this, "QTReader", "Must be a number"); |
750 | } | 1235 | } |
@@ -757,7 +1242,9 @@ void QTReaderApp::do_mono(const QString& lcn) | |||
757 | { | 1242 | { |
758 | reader->m_charpc = ulcn; | 1243 | reader->m_charpc = ulcn; |
759 | // reader->setmono(true); | 1244 | reader->setfont(); |
1245 | reader->refresh(); | ||
1246 | //reader->setmono(true); | ||
760 | } | 1247 | } |
761 | else | 1248 | else |
762 | QMessageBox::information(this, "QTReader", "Must be a number"); | 1249 | QMessageBox::information(this, "QTReader", "Must be a number"); |
763 | } | 1250 | } |
@@ -795,3 +1282,3 @@ void QTReaderApp::findNext() | |||
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(); |
@@ -827,5 +1314,5 @@ void QTReaderApp::regClose() | |||
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 |
@@ -833,3 +1320,3 @@ bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg) | |||
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()); |
@@ -847,11 +1334,11 @@ bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg) | |||
847 | if (!reader->buffdoc.getline(&test,reader->width())) | 1334 | if (!reader->buffdoc.getline(&test,reader->width())) |
848 | { | 1335 | { |
849 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 1336 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
850 | pos = searchStart; | 1337 | pos = searchStart; |
851 | else | 1338 | else |
852 | pos = start; | 1339 | pos = start; |
853 | ret = false; | 1340 | ret = false; |
854 | findClose(); | 1341 | findClose(); |
855 | break; | 1342 | break; |
856 | } | 1343 | } |
857 | } | 1344 | } |
@@ -897,7 +1384,3 @@ 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 | } |
@@ -939,3 +1422,3 @@ void QTReaderApp::openFile( const DocLnk &f ) | |||
939 | } | 1422 | } |
940 | 1423 | ||
941 | } | 1424 | } |
@@ -945,10 +1428,10 @@ void QTReaderApp::showEditTools() | |||
945 | if ( !doc ) | 1428 | if ( !doc ) |
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 ) |
951 | searchBar->show(); | 1434 | searchBar->show(); |
952 | if ( regVisible ) | 1435 | if ( regVisible ) |
953 | regBar->show(); | 1436 | regBar->show(); |
954 | if (m_fontVisible) m_fontBar->show(); | 1437 | if (m_fontVisible) m_fontBar->show(); |
@@ -963,5 +1446,5 @@ void QTReaderApp::save() | |||
963 | if ( !doc ) | 1446 | if ( !doc ) |
964 | return; | 1447 | return; |
965 | if ( !editor->edited() ) | 1448 | if ( !editor->edited() ) |
966 | return; | 1449 | return; |
967 | 1450 | ||
@@ -971,15 +1454,15 @@ void QTReaderApp::save() | |||
971 | if ( doc->name().isEmpty() ) { | 1454 | if ( doc->name().isEmpty() ) { |
972 | unsigned ispace = pt.find( ' ' ); | 1455 | unsigned ispace = pt.find( ' ' ); |
973 | unsigned ienter = pt.find( '\n' ); | 1456 | unsigned ienter = pt.find( '\n' ); |
974 | int i = (ispace < ienter) ? ispace : ienter; | 1457 | int i = (ispace < ienter) ? ispace : ienter; |
975 | QString docname; | 1458 | QString docname; |
976 | if ( i == -1 ) { | 1459 | if ( i == -1 ) { |
977 | if ( pt.isEmpty() ) | 1460 | if ( pt.isEmpty() ) |
978 | docname = "Empty Text"; | 1461 | docname = "Empty Text"; |
979 | else | 1462 | else |
980 | docname = pt; | 1463 | docname = pt; |
981 | } else { | 1464 | } else { |
982 | docname = pt.left( i ); | 1465 | docname = pt.left( i ); |
983 | } | 1466 | } |
984 | doc->setName(docname); | 1467 | doc->setName(docname); |
985 | } | 1468 | } |
@@ -995,5 +1478,5 @@ void QTReaderApp::clear() | |||
995 | // QMessageBox::information(this, "QTReader", "Deleting doc", 1); | 1478 | // QMessageBox::information(this, "QTReader", "Deleting doc", 1); |
996 | delete doc; | 1479 | delete doc; |
997 | // QMessageBox::information(this, "QTReader", "Deleted doc", 1); | 1480 | // QMessageBox::information(this, "QTReader", "Deleted doc", 1); |
998 | doc = 0; | 1481 | doc = 0; |
999 | } | 1482 | } |
@@ -1005,8 +1488,8 @@ void QTReaderApp::updateCaption() | |||
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 | } |
@@ -1024,32 +1507,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1024 | { | 1507 | { |
1025 | if (editorStack->visibleWidget() == reader) | 1508 | if (m_dontSave) |
1026 | { | 1509 | { |
1027 | if (m_fontVisible) | 1510 | e->accept(); |
1028 | { | ||
1029 | m_fontBar->hide(); | ||
1030 | m_fontVisible = false; | ||
1031 | } | ||
1032 | if (regVisible) | ||
1033 | { | ||
1034 | regBar->hide(); | ||
1035 | regVisible = false; | ||
1036 | return; | ||
1037 | } | ||
1038 | if (searchVisible) | ||
1039 | { | ||
1040 | searchBar->hide(); | ||
1041 | searchVisible = false; | ||
1042 | return; | ||
1043 | } | ||
1044 | if (m_fBkmksChanged && pBkmklist != NULL) | ||
1045 | { | ||
1046 | if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0) | ||
1047 | savebkmks(); | ||
1048 | delete pBkmklist; | ||
1049 | pBkmklist = NULL; | ||
1050 | m_fBkmksChanged = false; | ||
1051 | } | ||
1052 | bFromDocView = FALSE; | ||
1053 | saveprefs(); | ||
1054 | e->accept(); | ||
1055 | } | 1511 | } |
@@ -1057,3 +1513,37 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1057 | { | 1513 | { |
1058 | showEditTools(); | 1514 | if (editorStack->visibleWidget() == reader) |
1515 | { | ||
1516 | if (m_fontVisible) | ||
1517 | { | ||
1518 | m_fontBar->hide(); | ||
1519 | m_fontVisible = false; | ||
1520 | } | ||
1521 | if (regVisible) | ||
1522 | { | ||
1523 | regBar->hide(); | ||
1524 | regVisible = false; | ||
1525 | return; | ||
1526 | } | ||
1527 | if (searchVisible) | ||
1528 | { | ||
1529 | searchBar->hide(); | ||
1530 | searchVisible = false; | ||
1531 | return; | ||
1532 | } | ||
1533 | if (m_fBkmksChanged && pBkmklist != NULL) | ||
1534 | { | ||
1535 | if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0) | ||
1536 | savebkmks(); | ||
1537 | delete pBkmklist; | ||
1538 | pBkmklist = NULL; | ||
1539 | m_fBkmksChanged = false; | ||
1540 | } | ||
1541 | bFromDocView = FALSE; | ||
1542 | saveprefs(); | ||
1543 | e->accept(); | ||
1544 | } | ||
1545 | else | ||
1546 | { | ||
1547 | showEditTools(); | ||
1548 | } | ||
1059 | } | 1549 | } |
@@ -1079,12 +1569,11 @@ void QTReaderApp::listbkmk() | |||
1079 | { | 1569 | { |
1080 | if (m_fBkmksChanged) pBkmklist->sort(); | 1570 | for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) |
1081 | for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) | 1571 | { |
1082 | { | ||
1083 | #ifdef _UNICODE | 1572 | #ifdef _UNICODE |
1084 | bkmkselector->insertItem(toQString(i->name())); | 1573 | bkmkselector->insertItem(toQString(i->name())); |
1085 | #else | 1574 | #else |
1086 | bkmkselector->insertItem(i->name()); | 1575 | bkmkselector->insertItem(i->name()); |
1087 | #endif | 1576 | #endif |
1088 | cnt++; | 1577 | cnt++; |
1089 | } | 1578 | } |
1090 | } | 1579 | } |
@@ -1092,3 +1581,3 @@ void QTReaderApp::listbkmk() | |||
1092 | { | 1581 | { |
1093 | menu->hide(); | 1582 | //tjw menu->hide(); |
1094 | editBar->hide(); | 1583 | editBar->hide(); |
@@ -1122,13 +1611,14 @@ void QTReaderApp::gotobkmk(int ind) | |||
1122 | { | 1611 | { |
1123 | case cGotoBkmk: | 1612 | case cGotoBkmk: |
1124 | reader->locate((*pBkmklist)[ind]->value()); | 1613 | reader->locate((*pBkmklist)[ind]->value()); |
1125 | break; | 1614 | break; |
1126 | case cDelBkmk: | 1615 | case cDelBkmk: |
1127 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 1616 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
1128 | pBkmklist->erase(ind); | 1617 | pBkmklist->erase(ind); |
1129 | m_fBkmksChanged = true; | 1618 | m_fBkmksChanged = true; |
1130 | break; | 1619 | // pBkmklist->sort(); |
1131 | case cRmBkmkFile: | 1620 | break; |
1132 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); | 1621 | case cRmBkmkFile: |
1133 | break; | 1622 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); |
1623 | break; | ||
1134 | } | 1624 | } |
@@ -1156,5 +1646,5 @@ void QTReaderApp::do_jump(const QString& lcn) | |||
1156 | if (ok) | 1646 | if (ok) |
1157 | reader->locate(ulcn); | 1647 | reader->locate(ulcn); |
1158 | else | 1648 | else |
1159 | QMessageBox::information(this, "QTReader", "Must be a number"); | 1649 | QMessageBox::information(this, "QTReader", "Must be a number"); |
1160 | } | 1650 | } |
@@ -1168,19 +1658,19 @@ void QTReaderApp::do_regaction() | |||
1168 | case cAutoGen: | 1658 | case cAutoGen: |
1169 | do_autogen(regEdit->text()); | 1659 | do_autogen(regEdit->text()); |
1170 | break; | 1660 | break; |
1171 | case cAddBkmk: | 1661 | case cAddBkmk: |
1172 | do_addbkmk(regEdit->text()); | 1662 | do_addbkmk(regEdit->text()); |
1173 | break; | 1663 | break; |
1174 | case cJump: | 1664 | case cJump: |
1175 | do_jump(regEdit->text()); | 1665 | do_jump(regEdit->text()); |
1176 | break; | 1666 | break; |
1177 | case cMonoSpace: | 1667 | case cMonoSpace: |
1178 | do_mono(regEdit->text()); | 1668 | do_mono(regEdit->text()); |
1179 | break; | 1669 | break; |
1180 | case cOverlap: | 1670 | case cOverlap: |
1181 | do_overlap(regEdit->text()); | 1671 | do_overlap(regEdit->text()); |
1182 | break; | 1672 | break; |
1183 | case cSetTarget: | 1673 | case cSetTarget: |
1184 | do_settarget(regEdit->text()); | 1674 | do_settarget(regEdit->text()); |
1185 | break; | 1675 | break; |
1186 | } | 1676 | } |
@@ -1196,5 +1686,5 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
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 | } |
@@ -1202,4 +1692,4 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
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 | } |
@@ -1211,7 +1701,7 @@ void QTReaderApp::setfont() | |||
1211 | { | 1701 | { |
1212 | if (m_fontSelector->text(i) == reader->m_fontname) | 1702 | if (m_fontSelector->text(i) == reader->m_fontname) |
1213 | { | 1703 | { |
1214 | m_fontSelector->setCurrentItem(i); | 1704 | m_fontSelector->setCurrentItem(i); |
1215 | break; | 1705 | break; |
1216 | } | 1706 | } |
1217 | } | 1707 | } |
@@ -1221,4 +1711,5 @@ void QTReaderApp::setfont() | |||
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*/); |
@@ -1227,4 +1718,8 @@ void QTReaderApp::do_setfont(const QString& lcn) | |||
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(); |
@@ -1235,2 +1730,7 @@ void QTReaderApp::do_setfont(const QString& lcn) | |||
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) |
@@ -1261,5 +1761,5 @@ pbar->resize(width(), editBar->height()); | |||
1261 | pbar->setProgress(pc); | 1761 | pbar->setProgress(pc); |
1262 | qApp->processEvents(); | 1762 | qApp->processEvents(); |
1263 | if (reader->locate() != lcn) reader->jumpto(lcn); | 1763 | if (reader->locate() != lcn) reader->jumpto(lcn); |
1264 | reader->setFocus(); | 1764 | reader->setFocus(); |
1265 | lastpc = pc; | 1765 | lastpc = pc; |
@@ -1272,4 +1772,5 @@ pbar->resize(width(), editBar->height()); | |||
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); |
@@ -1288,2 +1789,4 @@ void QTReaderApp::saveprefs() | |||
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 ); |
@@ -1294,4 +1797,3 @@ void QTReaderApp::saveprefs() | |||
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); |
@@ -1305,4 +1807,12 @@ void QTReaderApp::saveprefs() | |||
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 | } |
@@ -1336,14 +1846,14 @@ void info_cb(Fl_Widget* o, void* _data) | |||
1336 | { | 1846 | { |
1337 | 1847 | ||
1338 | infowin = new Fl_Window(160,240); | 1848 | infowin = new Fl_Window(160,240); |
1339 | filename = new Fl_Output(45,5,110,14,"Filename"); | 1849 | filename = new Fl_Output(45,5,110,14,"Filename"); |
1340 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 1850 | filesize = new Fl_Output(45,25,110,14,"Filesize"); |
1341 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 1851 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
1342 | comprat = new CBar(45,65,110,14,"Ratio %"); | 1852 | comprat = new CBar(45,65,110,14,"Ratio %"); |
1343 | posn = new Fl_Output(45,85,110,14,"Location"); | 1853 | posn = new Fl_Output(45,85,110,14,"Location"); |
1344 | frcn = new CBar(45,105,110,14,"% Read"); | 1854 | frcn = new CBar(45,105,110,14,"% Read"); |
1345 | about = new Fl_Multiline_Output(5,125,150,90); | 1855 | about = new Fl_Multiline_Output(5,125,150,90); |
1346 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 1856 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
1347 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 1857 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
1348 | infowin->set_modal(); | 1858 | infowin->set_modal(); |
1349 | } | 1859 | } |
@@ -1351,21 +1861,21 @@ void info_cb(Fl_Widget* o, void* _data) | |||
1351 | { | 1861 | { |
1352 | unsigned long fs,ts; | 1862 | unsigned long fs,ts; |
1353 | tchar sz[20]; | 1863 | tchar sz[20]; |
1354 | ((reader_ui *)_data)->input->sizes(fs,ts); | 1864 | ((reader_ui *)_data)->input->sizes(fs,ts); |
1355 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 1865 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
1356 | 1866 | ||
1357 | filename->value(((reader_ui *)_data)->g_filename); | 1867 | filename->value(((reader_ui *)_data)->g_filename); |
1358 | 1868 | ||
1359 | sprintf(sz,"%u",fs); | 1869 | sprintf(sz,"%u",fs); |
1360 | filesize->value(sz); | 1870 | filesize->value(sz); |
1361 | 1871 | ||
1362 | sprintf(sz,"%u",ts); | 1872 | sprintf(sz,"%u",ts); |
1363 | textsize->value(sz); | 1873 | textsize->value(sz); |
1364 | 1874 | ||
1365 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 1875 | comprat->value(100-(100*fs + (ts >> 1))/ts); |
1366 | 1876 | ||
1367 | sprintf(sz,"%u",pl); | 1877 | sprintf(sz,"%u",pl); |
1368 | posn->value(sz); | 1878 | posn->value(sz); |
1369 | 1879 | ||
1370 | frcn->value((100*pl + (ts >> 1))/ts); | 1880 | frcn->value((100*pl + (ts >> 1))/ts); |
1371 | } | 1881 | } |
@@ -1379,6 +1889,6 @@ void QTReaderApp::savebkmks() | |||
1379 | { | 1889 | { |
1380 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); | 1890 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); |
1381 | bf.write(*pBkmklist); | 1891 | bf.write(*pBkmklist); |
1382 | } | 1892 | } |
1383 | m_fBkmksChanged = false; | 1893 | m_fBkmksChanged = false; |
1384 | } | 1894 | } |
@@ -1389,3 +1899,3 @@ void QTReaderApp::readbkmks() | |||
1389 | { | 1899 | { |
1390 | delete pBkmklist; | 1900 | delete pBkmklist; |
1391 | } | 1901 | } |
@@ -1393,9 +1903,9 @@ void QTReaderApp::readbkmks() | |||
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 | { |
1397 | pBkmklist = reader->getbkmklist(); | 1907 | pBkmklist = reader->getbkmklist(); |
1398 | } | 1908 | } |
1399 | if (pBkmklist != NULL) | 1909 | if (pBkmklist != NULL) |
1400 | pBkmklist->sort(); | 1910 | pBkmklist->sort(); |
1401 | } | 1911 | } |
@@ -1411,23 +1921,109 @@ void QTReaderApp::do_addbkmk(const QString& text) | |||
1411 | { | 1921 | { |
1412 | if (text.isEmpty()) | 1922 | if (text.isEmpty()) |
1413 | { | 1923 | { |
1414 | QMessageBox::information(this, "QTReader", "Need a name for the bookmark\nSelect add again", 1); | 1924 | QMessageBox::information(this, "QTReader", "Need a name for the bookmark\nSelect add again", 1); |
1415 | } | 1925 | } |
1416 | else | 1926 | else |
1417 | { | 1927 | { |
1418 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 1928 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; |
1419 | #ifdef _UNICODE | 1929 | #ifdef _UNICODE |
1420 | CBuffer buff; | 1930 | CBuffer buff; |
1421 | int i = 0; | 1931 | int i = 0; |
1422 | for (i = 0; i < text.length(); i++) | 1932 | for (i = 0; i < text.length(); i++) |
1423 | { | 1933 | { |
1424 | buff[i] = text[i].unicode(); | 1934 | buff[i] = text[i].unicode(); |
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; |
1432 | } | 1942 | pBkmklist->sort(); |
1943 | } | ||
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 | } | ||
1433 | } | 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(); } | ||