author | llornkcor <llornkcor> | 2002-09-14 02:19:09 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-09-14 02:19:09 (UTC) |
commit | 2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975 (patch) (unidiff) | |
tree | eeed16b5f80dd5883991a7a06133f5f7a6936256 /noncore/apps/opie-reader/QTReaderApp.cpp | |
parent | 5a95ed6a000a56849b8f093deea500214856c626 (diff) | |
download | opie-2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975.zip opie-2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975.tar.gz opie-2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975.tar.bz2 |
update by Tim
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 | |||
@@ -18,6 +18,7 @@ | |||
18 | ** | 18 | ** |
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> |
23 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
@@ -38,10 +39,14 @@ | |||
38 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
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 | ||
47 | #include <qpe/resource.h> | 52 | #include <qpe/resource.h> |
@@ -49,6 +54,7 @@ | |||
49 | 54 | ||
50 | #include "QTReaderApp.h" | 55 | #include "QTReaderApp.h" |
51 | #include "fileBrowser.h" | 56 | #include "fileBrowser.h" |
57 | #include "CDrawBuffer.h" | ||
52 | 58 | ||
53 | 59 | ||
54 | unsigned long QTReaderApp::m_uid = 0; | 60 | unsigned long QTReaderApp::m_uid = 0; |
@@ -68,28 +74,28 @@ void QTReaderApp::listBkmkFiles() | |||
68 | 74 | ||
69 | while(1) | 75 | while(1) |
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 | } |
82 | 88 | ||
83 | closedir(d); | 89 | closedir(d); |
84 | 90 | ||
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(); |
90 | if (regVisible) regBar->hide(); | 96 | if (regVisible) regBar->hide(); |
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 ); |
94 | } | 100 | } |
95 | else | 101 | else |
@@ -97,7 +103,7 @@ void QTReaderApp::listBkmkFiles() | |||
97 | } | 103 | } |
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()); |
103 | // qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 109 | // qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
@@ -105,11 +111,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
105 | pBkmklist = NULL; | 111 | pBkmklist = NULL; |
106 | doc = 0; | 112 | doc = 0; |
107 | 113 | ||
108 | m_fBkmksChanged = false; | 114 | m_fBkmksChanged = false; |
109 | 115 | ||
110 | QString lang = getenv( "LANG" ); | 116 | QString lang = getenv( "LANG" ); |
111 | 117 | ||
112 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 118 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
113 | setToolBarsMovable( FALSE ); | 119 | setToolBarsMovable( FALSE ); |
114 | 120 | ||
115 | setIcon( Resource::loadPixmap( "uqtreader" ) ); | 121 | setIcon( Resource::loadPixmap( "uqtreader" ) ); |
@@ -117,7 +123,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
117 | QPEToolBar *bar = new QPEToolBar( this ); | 123 | QPEToolBar *bar = new QPEToolBar( this ); |
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 ); |
123 | QPopupMenu *file = new QPopupMenu( this ); | 129 | QPopupMenu *file = new QPopupMenu( this ); |
@@ -144,6 +150,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
144 | pbar = new QProgressBar(this); | 150 | pbar = new QProgressBar(this); |
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()); |
149 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 160 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
@@ -166,18 +177,23 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
166 | */ | 177 | */ |
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 ); |
176 | reader->brepara = config.readBoolEntry( "Repara", false ); | 193 | reader->brepara = config.readBoolEntry( "Repara", false ); |
177 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 194 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
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 ); |
183 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 199 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
@@ -187,9 +203,21 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
187 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 203 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
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 | ||
195 | QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 223 | QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
@@ -212,16 +240,22 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
212 | connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 240 | connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
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); | ||
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() ) ); |
226 | a->setOn(false); | 260 | a->setOn(false); |
227 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 261 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
@@ -242,7 +276,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
242 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); | 276 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); |
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); |
248 | a->addTo( file ); | 282 | a->addTo( file ); |
@@ -251,10 +285,37 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
251 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); | 285 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); |
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 ); |
260 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); | 321 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); |
@@ -276,56 +337,95 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
276 | a->addTo( edit ); | 337 | a->addTo( edit ); |
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 ); | ||
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 | ||
330 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 430 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
331 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 431 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
@@ -346,11 +446,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
346 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 446 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
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 ); |
356 | 456 | ||
@@ -379,6 +479,10 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
379 | connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 479 | connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
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() ) ); |
384 | a->addTo( marks ); | 488 | a->addTo( marks ); |
@@ -405,25 +509,38 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
405 | marks->insertSeparator(); | 509 | marks->insertSeparator(); |
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 ); |
410 | mb->insertItem( tr( "Format" ), format ); | 524 | mb->insertItem( tr( "Format" ), format ); |
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 & ) ), |
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 |
428 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 545 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
429 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 546 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
@@ -435,7 +552,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
435 | 552 | ||
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 ); |
441 | 559 | ||
@@ -445,7 +563,7 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
445 | regBar->setStretchableWidget( regEdit ); | 563 | regBar->setStretchableWidget( regEdit ); |
446 | 564 | ||
447 | connect( regEdit, SIGNAL( returnPressed( ) ), | 565 | connect( regEdit, SIGNAL( returnPressed( ) ), |
448 | this, SLOT( do_regaction() ) ); | 566 | this, SLOT( do_regaction() ) ); |
449 | 567 | ||
450 | a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 568 | a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
451 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 569 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
@@ -464,25 +582,40 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
464 | m_fontSelector = new QComboBox(false, m_fontBar); | 582 | m_fontSelector = new QComboBox(false, m_fontBar); |
465 | m_fontBar->setStretchableWidget( m_fontSelector ); | 583 | m_fontBar->setStretchableWidget( m_fontSelector ); |
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 | ||
473 | m_fontBar->hide(); | 604 | m_fontBar->hide(); |
474 | m_fontVisible = false; | 605 | m_fontVisible = false; |
475 | 606 | ||
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); |
487 | } | 620 | } |
488 | 621 | ||
@@ -495,22 +628,259 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
495 | QDataStream stream( _data, IO_ReadOnly ); | 628 | QDataStream stream( _data, IO_ReadOnly ); |
496 | if ( msg == "info(QString)" ) | 629 | if ( msg == "info(QString)" ) |
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 | } |
507 | } | 868 | } |
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) |
510 | { | 880 | { |
511 | for (int i = 0; i < MAX_ENCODING; i++) | 881 | for (int i = 0; i < MAX_ENCODING; i++) |
512 | { | 882 | { |
513 | if (m_EncodingAction[i]->text() == _enc) return i; | 883 | if (m_EncodingAction[i]->text() == _enc) return i; |
514 | } | 884 | } |
515 | return 0; | 885 | return 0; |
516 | /* | 886 | /* |
@@ -527,6 +897,12 @@ void QTReaderApp::encodingSelected(QAction* _a) | |||
527 | reader->setencoding(EncNameToInt(_a->text())); | 897 | reader->setencoding(EncNameToInt(_a->text())); |
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 | { |
532 | } | 908 | } |
@@ -548,9 +924,9 @@ void QTReaderApp::TBDzoom() | |||
548 | 924 | ||
549 | void QTReaderApp::clearBkmkList() | 925 | 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 | } |
555 | 931 | ||
556 | void QTReaderApp::fileOpen() | 932 | void QTReaderApp::fileOpen() |
@@ -563,14 +939,14 @@ void QTReaderApp::fileOpen() | |||
563 | */ | 939 | */ |
564 | if (pBkmklist != NULL) | 940 | if (pBkmklist != NULL) |
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 | } |
575 | reader->disableAutoscroll(); | 951 | reader->disableAutoscroll(); |
576 | /* | 952 | /* |
@@ -578,17 +954,18 @@ void QTReaderApp::fileOpen() | |||
578 | fileSelector->reread(); | 954 | fileSelector->reread(); |
579 | */ | 955 | */ |
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 | ||
585 | if (fb->exec()) | 961 | if (fb->exec()) |
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 | } |
593 | 970 | ||
594 | void QTReaderApp::showinfo() | 971 | void QTReaderApp::showinfo() |
@@ -596,19 +973,120 @@ void QTReaderApp::showinfo() | |||
596 | unsigned long fs, ts, pl; | 973 | unsigned long fs, ts, pl; |
597 | if (reader->empty()) | 974 | if (reader->empty()) |
598 | { | 975 | { |
599 | QMessageBox::information(this, "QTReader", "No file loaded", 1); | 976 | QMessageBox::information(this, "QTReader", "No file loaded", 1); |
600 | } | 977 | } |
601 | else | 978 | else |
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 | } |
613 | } | 1091 | } |
614 | 1092 | ||
@@ -638,25 +1116,18 @@ void QTReaderApp::editMark() | |||
638 | 1116 | ||
639 | void QTReaderApp::editCopy() | 1117 | 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 | } |
661 | 1132 | ||
662 | void QTReaderApp::pageup() | 1133 | void QTReaderApp::pageup() |
@@ -673,6 +1144,26 @@ void QTReaderApp::stripcr(bool _b) | |||
673 | { | 1144 | { |
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 | { |
678 | reader->setstriphtml(_b); | 1169 | reader->setstriphtml(_b); |
@@ -689,12 +1180,6 @@ void QTReaderApp::repara(bool _b) | |||
689 | { | 1180 | { |
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 | { |
700 | reader->setdblspce(_b); | 1185 | reader->setdblspce(_b); |
@@ -730,9 +1215,9 @@ void QTReaderApp::setoverlap() | |||
730 | void QTReaderApp::settarget() | 1215 | 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(); |
738 | } | 1223 | } |
@@ -743,10 +1228,10 @@ void QTReaderApp::do_overlap(const QString& lcn) | |||
743 | unsigned long ulcn = lcn.toULong(&ok); | 1228 | unsigned long ulcn = lcn.toULong(&ok); |
744 | if (ok) | 1229 | if (ok) |
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 | } |
751 | 1236 | ||
752 | void QTReaderApp::do_mono(const QString& lcn) | 1237 | void QTReaderApp::do_mono(const QString& lcn) |
@@ -755,11 +1240,13 @@ void QTReaderApp::do_mono(const QString& lcn) | |||
755 | unsigned long ulcn = lcn.toULong(&ok); | 1240 | unsigned long ulcn = lcn.toULong(&ok); |
756 | if (ok) | 1241 | if (ok) |
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 | } |
764 | 1251 | ||
765 | /* | 1252 | /* |
@@ -793,7 +1280,7 @@ void QTReaderApp::findNext() | |||
793 | #else | 1280 | #else |
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); |
799 | reader->buffdoc.getline(&test,reader->width()); | 1286 | reader->buffdoc.getline(&test,reader->width()); |
@@ -825,13 +1312,13 @@ void QTReaderApp::regClose() | |||
825 | } | 1312 | } |
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 |
837 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 1324 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
@@ -845,15 +1332,15 @@ bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg) | |||
845 | { | 1332 | { |
846 | pos = reader->locate(); | 1333 | pos = reader->locate(); |
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 | } |
858 | reader->locate(pos); | 1345 | reader->locate(pos); |
859 | return ret; | 1346 | return ret; |
@@ -895,11 +1382,7 @@ void QTReaderApp::search(const QString & arg) | |||
895 | #else | 1382 | #else |
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 |
905 | 1388 | ||
@@ -937,20 +1420,20 @@ void QTReaderApp::openFile( const DocLnk &f ) | |||
937 | { | 1420 | { |
938 | QMessageBox::information(this, "QTReader", "File does not exist"); | 1421 | QMessageBox::information(this, "QTReader", "File does not exist"); |
939 | } | 1422 | } |
940 | 1423 | ||
941 | } | 1424 | } |
942 | 1425 | ||
943 | void QTReaderApp::showEditTools() | 1426 | void QTReaderApp::showEditTools() |
944 | { | 1427 | { |
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(); |
955 | 1438 | ||
956 | updateCaption(); | 1439 | updateCaption(); |
@@ -961,27 +1444,27 @@ void QTReaderApp::showEditTools() | |||
961 | void QTReaderApp::save() | 1444 | void QTReaderApp::save() |
962 | { | 1445 | { |
963 | if ( !doc ) | 1446 | if ( !doc ) |
964 | return; | 1447 | return; |
965 | if ( !editor->edited() ) | 1448 | if ( !editor->edited() ) |
966 | return; | 1449 | return; |
967 | 1450 | ||
968 | QString rt = editor->text(); | 1451 | QString rt = editor->text(); |
969 | QString pt = rt; | 1452 | QString pt = rt; |
970 | 1453 | ||
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 | } |
986 | FileManager fm; | 1469 | FileManager fm; |
987 | fm.saveFile( *doc, rt ); | 1470 | fm.saveFile( *doc, rt ); |
@@ -993,9 +1476,9 @@ void QTReaderApp::clear() | |||
993 | if (doc != 0) | 1476 | if (doc != 0) |
994 | { | 1477 | { |
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 | } |
1000 | reader->clear(); | 1483 | reader->clear(); |
1001 | } | 1484 | } |
@@ -1003,12 +1486,12 @@ void QTReaderApp::clear() | |||
1003 | void QTReaderApp::updateCaption() | 1486 | 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 | } |
1014 | 1497 | ||
@@ -1022,40 +1505,47 @@ void QTReaderApp::setDocument(const QString& fileref) | |||
1022 | 1505 | ||
1023 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 1506 | 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 | } |
1056 | else | 1512 | else |
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 | } |
1060 | } | 1550 | } |
1061 | 1551 | ||
@@ -1077,20 +1567,19 @@ void QTReaderApp::listbkmk() | |||
1077 | int cnt = 0; | 1567 | int cnt = 0; |
1078 | if (pBkmklist != NULL) | 1568 | if (pBkmklist != NULL) |
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 | } |
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(); |
1096 | if (regVisible) regBar->hide(); | 1585 | if (regVisible) regBar->hide(); |
@@ -1120,17 +1609,18 @@ void QTReaderApp::gotobkmk(int ind) | |||
1120 | { | 1609 | { |
1121 | switch (m_nRegAction) | 1610 | switch (m_nRegAction) |
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 | } |
1135 | showEditTools(); | 1625 | showEditTools(); |
1136 | } | 1626 | } |
@@ -1154,9 +1644,9 @@ void QTReaderApp::do_jump(const QString& lcn) | |||
1154 | bool ok; | 1644 | bool ok; |
1155 | unsigned long ulcn = lcn.toULong(&ok); | 1645 | unsigned long ulcn = lcn.toULong(&ok); |
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 | } |
1161 | 1651 | ||
1162 | void QTReaderApp::do_regaction() | 1652 | void QTReaderApp::do_regaction() |
@@ -1166,23 +1656,23 @@ void QTReaderApp::do_regaction() | |||
1166 | switch(m_nRegAction) | 1656 | switch(m_nRegAction) |
1167 | { | 1657 | { |
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 | } |
1187 | reader->restore(); | 1677 | reader->restore(); |
1188 | // editBar->show(); | 1678 | // editBar->show(); |
@@ -1194,14 +1684,14 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
1194 | int ind = _txt.find('/'); | 1684 | int ind = _txt.find('/'); |
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 | } |
1207 | 1697 | ||
@@ -1209,30 +1699,40 @@ void QTReaderApp::setfont() | |||
1209 | { | 1699 | { |
1210 | for (int i = 1; i <= m_fontSelector->count(); i++) | 1700 | for (int i = 1; i <= m_fontSelector->count(); i++) |
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 | } |
1218 | m_fontBar->show(); | 1708 | m_fontBar->show(); |
1219 | m_fontVisible = true; | 1709 | m_fontVisible = true; |
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(); |
1232 | m_fontVisible = false; | 1727 | m_fontVisible = false; |
1233 | showEditTools(); | 1728 | showEditTools(); |
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 | { |
1238 | unsigned long fs, ts; | 1738 | unsigned long fs, ts; |
@@ -1259,9 +1759,9 @@ pbar->resize(width(), editBar->height()); | |||
1259 | if (pc != lastpc) | 1759 | if (pc != lastpc) |
1260 | { | 1760 | { |
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; |
1266 | } | 1766 | } |
1267 | i = reader->buffdoc.getpara(buff); | 1767 | i = reader->buffdoc.getpara(buff); |
@@ -1270,8 +1770,9 @@ pbar->resize(width(), editBar->height()); | |||
1270 | #else | 1770 | #else |
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(); |
1277 | pbar->hide(); | 1778 | pbar->hide(); |
@@ -1286,14 +1787,15 @@ void QTReaderApp::saveprefs() | |||
1286 | reader->m_lastposn = reader->pagelocate(); | 1787 | reader->m_lastposn = reader->pagelocate(); |
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 ); |
1291 | config.writeEntry( "Unindent", reader->bunindent ); | 1794 | config.writeEntry( "Unindent", reader->bunindent ); |
1292 | config.writeEntry( "Repara", reader->brepara ); | 1795 | config.writeEntry( "Repara", reader->brepara ); |
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 ); |
1299 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 1801 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
@@ -1303,8 +1805,16 @@ void QTReaderApp::saveprefs() | |||
1303 | config.writeEntry( "Encoding", reader->m_encd ); | 1805 | config.writeEntry( "Encoding", reader->m_encd ); |
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 | ||
1310 | void QTReaderApp::indentplus() | 1820 | void QTReaderApp::indentplus() |
@@ -1334,40 +1844,40 @@ void info_cb(Fl_Widget* o, void* _data) | |||
1334 | 1844 | ||
1335 | if (infowin == NULL) | 1845 | if (infowin == NULL) |
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 | } |
1350 | if (((reader_ui *)_data)->g_filename[0] != '\0') | 1860 | if (((reader_ui *)_data)->g_filename[0] != '\0') |
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 | } |
1372 | infowin->show(); | 1882 | infowin->show(); |
1373 | } | 1883 | } |
@@ -1377,27 +1887,27 @@ void QTReaderApp::savebkmks() | |||
1377 | { | 1887 | { |
1378 | if (pBkmklist != NULL) | 1888 | if (pBkmklist != NULL) |
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 | } |
1385 | 1895 | ||
1386 | void QTReaderApp::readbkmks() | 1896 | void QTReaderApp::readbkmks() |
1387 | { | 1897 | { |
1388 | if (pBkmklist != NULL) | 1898 | if (pBkmklist != NULL) |
1389 | { | 1899 | { |
1390 | delete pBkmklist; | 1900 | delete pBkmklist; |
1391 | } | 1901 | } |
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 | { |
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 | } |
1402 | 1912 | ||
1403 | void QTReaderApp::addbkmk() | 1913 | void QTReaderApp::addbkmk() |
@@ -1409,25 +1919,111 @@ void QTReaderApp::addbkmk() | |||
1409 | 1919 | ||
1410 | void QTReaderApp::do_addbkmk(const QString& text) | 1920 | 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(); } | ||