author | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
commit | 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (unidiff) | |
tree | 96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps/opie-reader/QTReader.cpp | |
parent | 279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff) | |
download | opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2 |
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
Diffstat (limited to 'noncore/apps/opie-reader/QTReader.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReader.cpp | 1301 |
1 files changed, 904 insertions, 397 deletions
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index 33884a0..0c56dd4 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -33,5 +33,8 @@ const int _SBARHEIGHT = 3; | |||
33 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include "TableDialog.h" | ||
36 | #include "outputcodec.h" | ||
35 | 37 | ||
38 | /* | ||
36 | #ifdef _UNICODE | 39 | #ifdef _UNICODE |
37 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | 40 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; |
@@ -39,4 +42,5 @@ const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | |||
39 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | 42 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; |
40 | #endif | 43 | #endif |
44 | */ | ||
41 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; | 45 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; |
42 | 46 | ||
@@ -50,7 +54,7 @@ tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>' | |||
50 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 54 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
51 | 55 | ||
52 | |||
53 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | 56 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : |
54 | QWidget(parent, name, f), | 57 | QWidget(parent, name, f | WRepaintNoErase | WResizeNoErase), |
58 | m_outofdate(true), | ||
55 | m_default_fg(0,0,0), | 59 | m_default_fg(0,0,0), |
56 | m_default_bg(255,255,255), | 60 | m_default_bg(255,255,255), |
@@ -90,14 +94,10 @@ QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | |||
90 | m_currentlink(-1) | 94 | m_currentlink(-1) |
91 | { | 95 | { |
96 | m_output = NULL; | ||
92 | m_overlap = 1; | 97 | m_overlap = 1; |
93 | setKeyCompression ( true ); | 98 | setKeyCompression ( true ); |
94 | #ifdef DOUBLEBUFFER | ||
95 | dbuff = new QPixmap(); | ||
96 | dbp = new QPainter(); | ||
97 | // if (painter->isActive()) painter->end(); | ||
98 | // painter->begin(frame); | ||
99 | #endif | ||
100 | // init(); | ||
101 | 99 | ||
100 | dbuff = NULL; | ||
101 | dbp = NULL; | ||
102 | } | 102 | } |
103 | 103 | ||
@@ -118,5 +118,5 @@ QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *nam | |||
118 | { | 118 | { |
119 | init(); | 119 | init(); |
120 | // // qDebug("Load_file(1)"); | 120 | // // qDeb2ug("Load_file(1)"); |
121 | load_file((const tchar*)filename); | 121 | load_file((const tchar*)filename); |
122 | } | 122 | } |
@@ -139,5 +139,6 @@ long QTReader::real_delay() | |||
139 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 139 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
140 | { | 140 | { |
141 | buffdoc.unsuspend(); | 141 | m_drageligible = false; |
142 | qDebug("Mouse pressed at (%u, %u)", _e->x(), _e->y()); | ||
142 | int x, y, ht, wh; | 143 | int x, y, ht, wh; |
143 | if (m_rotated) | 144 | if (m_rotated) |
@@ -155,25 +156,169 @@ void QTReader::mousePressEvent( QMouseEvent* _e ) | |||
155 | wh = width(); | 156 | wh = width(); |
156 | } | 157 | } |
157 | if (_e->button() == RightButton) | 158 | if (x >= m_left_border && x <= wh - m_right_border && y >= m_topmargin && y <= ht-m_bottommargin) |
158 | { | 159 | { |
159 | //qDebug("MousePress"); | 160 | if (_e->button() == RightButton) |
160 | mouseUpOn = false; | ||
161 | if (m_swapmouse) | ||
162 | { | 161 | { |
163 | int lineno = 0; | 162 | //qDebug("MousePress"); |
164 | /* | 163 | mouseUpOn = false; |
164 | if (m_swapmouse) | ||
165 | { | ||
166 | int lineno = 0; | ||
167 | /* | ||
165 | int hgt = textarray[0]->lineSpacing(); | 168 | int hgt = textarray[0]->lineSpacing(); |
166 | while ((hgt < y) && (lineno < numlines)) | 169 | while ((hgt < y) && (lineno < numlines)) |
167 | { | 170 | { |
168 | hgt += textarray[++lineno]->lineSpacing(); | 171 | hgt += textarray[++lineno]->lineSpacing(); |
169 | } | 172 | } |
170 | */ | 173 | */ |
171 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 174 | size_t startpos, startoffset, tgt, tgtoffset, pictgt, tabtgt; |
172 | QImage* img; | 175 | QImage* img; |
173 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 176 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img, tabtgt); |
174 | processmousewordevent(startpos, startoffset, _e, lineno); | 177 | processmousewordevent(startpos, startoffset, _e, lineno); |
178 | } | ||
179 | else | ||
180 | { | ||
181 | processmousepositionevent(_e); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | int ln = -1; | ||
188 | int mp; | ||
189 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | ||
190 | switch (m_scrollpos) | ||
191 | { | ||
192 | case 1: | ||
193 | { | ||
194 | if (m_rotated) | ||
195 | { | ||
196 | if (_e->x() < m_bottommargin) | ||
197 | { | ||
198 | ln = height(); | ||
199 | mp = _e->y(); | ||
200 | } | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | if (_e->y() > height()-m_bottommargin) | ||
205 | { | ||
206 | ln = width(); | ||
207 | mp = _e->x(); | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | break; | ||
212 | case 2: | ||
213 | { | ||
214 | if (m_rotated) | ||
215 | { | ||
216 | if (_e->y() > height() - m_right_border) | ||
217 | { | ||
218 | ln = width(); | ||
219 | mp = width()-_e->x(); | ||
220 | } | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | if (_e->x() > width() - m_right_border) | ||
225 | { | ||
226 | ln = height(); | ||
227 | mp = _e->y(); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | break; | ||
232 | case 3: | ||
233 | { | ||
234 | if (m_rotated) | ||
235 | { | ||
236 | if (_e->y() < m_left_border) | ||
237 | { | ||
238 | ln = width(); | ||
239 | mp = width()-_e->x(); | ||
240 | } | ||
241 | } | ||
242 | else | ||
243 | { | ||
244 | if (_e->x() < m_left_border) | ||
245 | { | ||
246 | ln = height(); | ||
247 | mp = _e->y(); | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | break; | ||
252 | case 0: | ||
253 | default: | ||
254 | ln = -1; | ||
255 | break; | ||
256 | } | ||
257 | if (ln >= 0) | ||
258 | { | ||
259 | int dp = (sectionsize*mp+ln/2)/ln + buffdoc.startSection(); | ||
260 | int winsize = locnarray[numlines]-locnarray[0]; | ||
261 | int slidersize = 10*(sectionsize+ln/2)/ln; | ||
262 | if (slidersize > winsize) | ||
263 | { | ||
264 | int mid = (locnarray[0] + locnarray[numlines])/2; | ||
265 | slidersize /= 2; | ||
266 | if (dp < mid-slidersize) | ||
267 | { | ||
268 | dopageup(); | ||
269 | } | ||
270 | else if (dp > mid+slidersize) | ||
271 | { | ||
272 | dopagedn(); | ||
273 | } | ||
274 | //if (mid-slidersize < dp && dp < mid+slidersize) | ||
275 | else | ||
276 | { | ||
277 | m_drageligible = true; | ||
278 | } | ||
279 | } | ||
280 | else | ||
281 | { | ||
282 | if (dp < locnarray[0]) | ||
283 | { | ||
284 | dopageup(); | ||
285 | } | ||
286 | else if (dp > locnarray[numlines]) | ||
287 | { | ||
288 | dopagedn(); | ||
289 | } | ||
290 | //if (locnarray[0] < dp && dp < locnarray[numlines]) | ||
291 | else | ||
292 | { | ||
293 | m_drageligible = true; | ||
294 | } | ||
295 | } | ||
296 | qDebug("Drag eligible:%s", (m_drageligible) ? "true" : "false"); | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | if (m_scrollpos == 1) | ||
301 | { | ||
302 | if (x < m_left_border) | ||
303 | { | ||
304 | lineUp(); | ||
305 | } | ||
306 | if (y > ht - m_bottommargin) | ||
307 | { | ||
308 | lineDown(); | ||
309 | } | ||
310 | } | ||
311 | else if (m_scrollpos != 0) | ||
312 | { | ||
313 | if (y < m_topmargin) | ||
314 | { | ||
315 | lineUp(); | ||
316 | } | ||
317 | if (y > ht - m_bottommargin) | ||
318 | { | ||
319 | lineDown(); | ||
320 | } | ||
321 | } | ||
175 | } | 322 | } |
176 | else | ||
177 | processmousepositionevent(_e); | ||
178 | } | 323 | } |
179 | } | 324 | } |
@@ -296,5 +441,5 @@ void QTReader::goForward() | |||
296 | } | 441 | } |
297 | 442 | ||
298 | linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img) | 443 | linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img, size_t& tabtgt) |
299 | { | 444 | { |
300 | int ht; | 445 | int ht; |
@@ -341,5 +486,5 @@ linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t | |||
341 | offset = i; | 486 | offset = i; |
342 | } | 487 | } |
343 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img); | 488 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img, tabtgt); |
344 | } | 489 | } |
345 | 490 | ||
@@ -355,4 +500,36 @@ void QTReader::suspend() | |||
355 | } | 500 | } |
356 | 501 | ||
502 | void QTReader::setDoubleBuffer(bool _b) | ||
503 | { | ||
504 | m_doubleBuffered = _b; | ||
505 | if (_b || m_rotated) | ||
506 | { | ||
507 | if (dbuff == NULL) | ||
508 | { | ||
509 | dbuff = new QPixmap(); | ||
510 | dbp = new QPainter(); | ||
511 | } | ||
512 | if (m_rotated) | ||
513 | { | ||
514 | dbuff->resize(height(), width()); | ||
515 | } | ||
516 | else | ||
517 | { | ||
518 | dbuff->resize(width(), height()); | ||
519 | } | ||
520 | m_outofdate = true; | ||
521 | } | ||
522 | else | ||
523 | { | ||
524 | if (dbuff != NULL) | ||
525 | { | ||
526 | delete dbuff; | ||
527 | delete dbp; | ||
528 | } | ||
529 | dbuff = NULL; | ||
530 | dbp = NULL; | ||
531 | } | ||
532 | } | ||
533 | |||
357 | void QTReader::setTwoTouch(bool _b) | 534 | void QTReader::setTwoTouch(bool _b) |
358 | { | 535 | { |
@@ -363,5 +540,4 @@ void QTReader::setTwoTouch(bool _b) | |||
363 | void QTReader::setContinuous(bool _b) | 540 | void QTReader::setContinuous(bool _b) |
364 | { | 541 | { |
365 | buffdoc.unsuspend(); | ||
366 | buffdoc.setContinuous(m_continuousDocument = _b); | 542 | buffdoc.setContinuous(m_continuousDocument = _b); |
367 | } | 543 | } |
@@ -456,5 +632,5 @@ void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouse | |||
456 | if (!wrd.isEmpty()) | 632 | if (!wrd.isEmpty()) |
457 | { | 633 | { |
458 | qDebug("Selecteed:%s", (const char*)wrd); | 634 | qDebug("Selected:%s", (const char*)wrd); |
459 | if (m_twotouch) | 635 | if (m_twotouch) |
460 | { | 636 | { |
@@ -469,202 +645,338 @@ void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouse | |||
469 | } | 645 | } |
470 | 646 | ||
471 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | 647 | #ifdef USETIMER |
648 | void QTReader::actionDrag() | ||
472 | { | 649 | { |
473 | buffdoc.unsuspend(); | 650 | if (m_drageligible) |
474 | int x, y, ht, wh; | ||
475 | if (m_rotated) | ||
476 | { | 651 | { |
477 | x = _e->y(); | 652 | int fivepages = 5*((2*width()+m_textsize/2)/m_textsize)*((height()+m_textsize/2)/m_textsize); |
478 | y = width()-_e->x(); | 653 | if (m_dragtarget > fivepages && locnarray[numlines] < m_dragtarget - fivepages) |
479 | ht = width(); | 654 | { |
480 | wh = height(); | 655 | int tgt = m_dragtarget - fivepages/2; |
656 | //qDebug("Jumping to %u (%u)", tgt, fivepages); | ||
657 | if (tgt < buffdoc.startSection()) | ||
658 | { | ||
659 | tgt = buffdoc.startSection(); | ||
660 | } | ||
661 | locate(tgt); | ||
662 | drawFonts(); | ||
663 | } | ||
664 | else if (locnarray[0] > m_dragtarget+fivepages) | ||
665 | { | ||
666 | int tgt = m_dragtarget + fivepages/2; | ||
667 | //qDebug("Jumping to %u (%u)", tgt, fivepages); | ||
668 | if (tgt > buffdoc.endSection()) | ||
669 | { | ||
670 | dopageup(); | ||
671 | } | ||
672 | else | ||
673 | { | ||
674 | locate(tgt); | ||
675 | drawFonts(); | ||
676 | } | ||
677 | } | ||
678 | else if (locnarray[numlines] <= m_dragtarget) | ||
679 | { | ||
680 | dopagedn(); | ||
681 | } | ||
682 | else if (locnarray[0] > m_dragtarget) | ||
683 | { | ||
684 | dopageup(); | ||
685 | } | ||
481 | } | 686 | } |
482 | else | 687 | else |
483 | { | 688 | { |
484 | x = _e->x(); | 689 | m_dragtimer->stop(); |
485 | y = _e->y(); | ||
486 | ht = height(); | ||
487 | wh = width(); | ||
488 | } | 690 | } |
489 | if (_e->button() == LeftButton) | 691 | } |
692 | #endif | ||
693 | |||
694 | void QTReader::mouseMoveEvent( QMouseEvent* _e ) | ||
695 | { | ||
696 | if (m_drageligible) | ||
490 | { | 697 | { |
491 | if (mouseUpOn) | 698 | int ht; |
699 | int mp; | ||
700 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | ||
701 | //qDebug("Mouse moved to (%u, %u)", _e->x(), _e->y()); | ||
702 | switch (m_scrollpos) | ||
492 | { | 703 | { |
493 | // qDebug("MouseRelease"); | 704 | case 1: |
494 | switch(m_scrollpos) | 705 | { |
706 | if (m_rotated) | ||
707 | { | ||
708 | ht = height(); | ||
709 | mp = _e->y(); | ||
710 | } | ||
711 | else | ||
712 | { | ||
713 | ht = width(); | ||
714 | mp = _e->x(); | ||
715 | } | ||
716 | } | ||
717 | break; | ||
718 | case 2: | ||
719 | case 3: | ||
720 | { | ||
721 | if (m_rotated) | ||
722 | { | ||
723 | ht = width(); | ||
724 | mp = width()-_e->x(); | ||
725 | } | ||
726 | else | ||
727 | { | ||
728 | ht = height(); | ||
729 | mp = _e->y(); | ||
730 | } | ||
731 | } | ||
732 | break; | ||
733 | case 0: | ||
734 | default: | ||
735 | ht = -1; | ||
736 | break; | ||
737 | } | ||
738 | if (ht >= 0) | ||
739 | { | ||
740 | #ifdef USETIMER | ||
741 | m_dragtarget = (sectionsize*mp+ht/2)/ht + buffdoc.startSection(); | ||
742 | if (!m_dragtimer->isActive()) | ||
495 | { | 743 | { |
496 | case 1: // Bottom | 744 | m_dragtimer->start(0, false); |
497 | if (y > ht - 5) | ||
498 | { | ||
499 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); | ||
500 | return; | ||
501 | } | ||
502 | break; | ||
503 | case 2: // right | ||
504 | if (x > wh - m_right_border) | ||
505 | { | ||
506 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); | ||
507 | return; | ||
508 | } | ||
509 | break; | ||
510 | case 3: // left | ||
511 | if (x < m_left_border) | ||
512 | { | ||
513 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); | ||
514 | return; | ||
515 | } | ||
516 | break; | ||
517 | case 0: | ||
518 | default: | ||
519 | break; | ||
520 | } | 745 | } |
521 | if (textarray[0] != NULL) | 746 | #else |
747 | int dp = (sectionsize*mp+ht/2)/ht + buffdoc.startSection(); | ||
748 | locate(dp); | ||
749 | #endif | ||
750 | } | ||
751 | } | ||
752 | } | ||
753 | |||
754 | void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | ||
755 | { | ||
756 | qDebug("Mouse released at (%u, %u)", _e->x(), _e->y()); | ||
757 | if (m_drageligible) | ||
758 | { | ||
759 | m_drageligible = false; | ||
760 | } | ||
761 | else | ||
762 | { | ||
763 | int x, y, ht, wh; | ||
764 | if (m_rotated) | ||
765 | { | ||
766 | x = _e->y(); | ||
767 | y = width()-_e->x(); | ||
768 | ht = width(); | ||
769 | wh = height(); | ||
770 | } | ||
771 | else | ||
772 | { | ||
773 | x = _e->x(); | ||
774 | y = _e->y(); | ||
775 | ht = height(); | ||
776 | wh = width(); | ||
777 | } | ||
778 | if (_e->button() == LeftButton) | ||
779 | { | ||
780 | if (mouseUpOn) | ||
522 | { | 781 | { |
523 | QString line; | 782 | // qDebug("MouseRelease"); |
524 | // int lineno = _e->y()/m_linespacing; | 783 | /* |
525 | int lineno = 0; | 784 | switch(m_scrollpos) |
526 | /* | ||
527 | int ht = textarray[0]->lineSpacing(); | ||
528 | while ((ht < y) && (lineno < numlines)) | ||
529 | { | 785 | { |
530 | ht += textarray[++lineno]->lineSpacing(); | 786 | case 1: // Bottom |
787 | if (y > ht - 5) | ||
788 | { | ||
789 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); | ||
790 | return; | ||
531 | } | 791 | } |
532 | */ | 792 | break; |
533 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 793 | case 2: // right |
534 | QImage* img; | 794 | if (x > wh - m_right_border) |
535 | if (m_currentlinkstyle != NULL) | 795 | { |
536 | { | 796 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); |
537 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); | 797 | return; |
538 | m_currentlinkstyle = NULL; | 798 | } |
539 | m_currentlink = -1; | 799 | break; |
540 | m_currentlinkoffset = -1; | 800 | case 3: // left |
541 | } | 801 | if (x < m_left_border) |
542 | linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 802 | { |
543 | if ((glt & eLink) != 0) | 803 | locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); |
544 | { | 804 | return; |
545 | if ((glt & ePicture) != 0) | 805 | } |
546 | { | 806 | break; |
547 | qDebug("Big Picture:%x", pictgt); | 807 | case 0: |
548 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | 808 | default: |
549 | { | 809 | break; |
550 | QImage* pm = buffdoc.getPicture(pictgt); | 810 | } |
551 | if (pm != NULL) | 811 | */ |
552 | { | 812 | if (textarray[0] != NULL) |
553 | emit OnShowPicture(*pm); | 813 | { |
554 | delete pm; | 814 | QString line; |
555 | return; | 815 | // int lineno = _e->y()/m_linespacing; |
556 | } | 816 | int lineno = 0; |
557 | } | 817 | /* |
558 | } | 818 | int ht = textarray[0]->lineSpacing(); |
559 | else if (img != NULL) | 819 | while ((ht < y) && (lineno < numlines)) |
560 | { | 820 | { |
561 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | 821 | ht += textarray[++lineno]->lineSpacing(); |
562 | { | 822 | } |
563 | emit OnShowPicture(*img); | 823 | */ |
564 | return; | 824 | size_t startpos, startoffset, tgt, tgtoffset, pictgt, tabtgt; |
565 | } | 825 | QImage* img; |
566 | } | 826 | if (m_currentlinkstyle != NULL) |
567 | size_t saveposn = pagelocate(); | 827 | { |
568 | QString href, nm; | 828 | textarray[m_currentlink]->invertLink(m_currentlinkoffset); |
569 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); | 829 | m_currentlinkstyle = NULL; |
570 | qDebug("URL(1):%s", (const char*)href); | 830 | m_currentlink = -1; |
571 | if ((lt & eFile) != 0) | 831 | m_currentlinkoffset = -1; |
572 | { | 832 | } |
573 | buffdoc.saveposn(m_lastfile, saveposn); | 833 | linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img, tabtgt); |
834 | if (bNoInlineTables && ((glt & eTable) != 0)) | ||
835 | { | ||
836 | size_t currentpos = locate(); | ||
837 | QString tabtext = buffdoc.getTableAsHtml(tabtgt); | ||
838 | qDebug("TABLE:%u:%u:%s", currentpos, tabtgt, (const char*)tabtext); | ||
839 | QFont f(m_fontname, m_fontControl.currentsize()); | ||
574 | #ifdef USEQPE | 840 | #ifdef USEQPE |
841 | CTableDialog td(f, tabtext, true, this); | ||
842 | #else | ||
843 | CTableDialog td(f, tabtext, false, this); | ||
844 | #endif | ||
845 | td.exec(); | ||
846 | jumpto(currentpos); | ||
847 | } | ||
848 | if ((glt & eLink) != 0) | ||
849 | { | ||
850 | if ((glt & ePicture) != 0) | ||
575 | { | 851 | { |
576 | QCopEnvelope e("QPE/System", "busy()"); | 852 | qDebug("Big Picture:%x", pictgt); |
853 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) | ||
854 | { | ||
855 | QImage* pm = buffdoc.getPicture(pictgt); | ||
856 | if (pm != NULL) | ||
857 | { | ||
858 | emit OnShowPicture(*pm); | ||
859 | delete pm; | ||
860 | return; | ||
861 | } | ||
862 | } | ||
577 | } | 863 | } |
578 | #endif | 864 | else if (img != NULL) |
579 | ResetScroll(); | ||
580 | if (!href.isEmpty()) | ||
581 | { | ||
582 | if (!buffdoc.getFile(href)) | ||
583 | { | ||
584 | emit NewFileRequest(href); | ||
585 | } | ||
586 | else | ||
587 | { | ||
588 | ResetScroll(); | ||
589 | fillbuffer(); | ||
590 | update(); | ||
591 | } | ||
592 | } | ||
593 | if (!nm.isEmpty()) | ||
594 | { | ||
595 | qDebug("QTReader:Finding %s", (const char*)nm); | ||
596 | if (buffdoc.findanchor(nm)) | ||
597 | { | ||
598 | fillbuffer(); | ||
599 | update(); | ||
600 | } | ||
601 | } | ||
602 | //fillbuffer(); | ||
603 | //update(); | ||
604 | #ifdef USEQPE | ||
605 | { | 865 | { |
606 | QCopEnvelope e("QPE/System", "notBusy()"); | 866 | if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) |
867 | { | ||
868 | emit OnShowPicture(*img); | ||
869 | return; | ||
870 | } | ||
607 | } | 871 | } |
608 | #endif | 872 | size_t saveposn = pagelocate(); |
609 | } | 873 | QString href, nm; |
610 | else if ((lt & eLink) != 0) | 874 | linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); |
611 | { | 875 | qDebug("URL(1):%s", (const char*)href); |
612 | buffdoc.saveposn(m_lastfile, saveposn); | 876 | if ((lt & eFile) != 0) |
613 | ResetScroll(); | 877 | { |
614 | fillbuffer(); | 878 | buffdoc.saveposn(m_lastfile, saveposn); |
615 | update(); | 879 | #ifdef USEQPE |
616 | } | ||
617 | else | ||
618 | { | ||
619 | if ((lt & ePicture) != 0) | ||
620 | { | 880 | { |
621 | QImage* pm = buffdoc.getPicture(tgt); | 881 | QCopEnvelope e("QPE/System", "busy()"); |
622 | if (pm != NULL) | ||
623 | { | ||
624 | emit OnShowPicture(*pm); | ||
625 | delete pm; | ||
626 | } | ||
627 | } | 882 | } |
628 | else | 883 | #endif |
884 | ResetScroll(); | ||
885 | if (!href.isEmpty()) | ||
886 | { | ||
887 | if (!buffdoc.getFile(href, nm)) | ||
888 | { | ||
889 | emit NewFileRequest(href); | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | qDebug("BEFORE:%u", pagelocate()); | ||
894 | buffdoc.resetPos(); | ||
895 | ResetScroll(); | ||
896 | fillbuffer(); | ||
897 | qDebug("AFTER:%u", pagelocate()); | ||
898 | m_outofdate = true; | ||
899 | update(); | ||
900 | } | ||
901 | } | ||
902 | if (!nm.isEmpty()) | ||
903 | { | ||
904 | qDebug("QTReader:Finding %s", (const char*)nm); | ||
905 | if (buffdoc.findanchor(nm)) | ||
906 | { | ||
907 | buffdoc.resetPos(); | ||
908 | fillbuffer(); | ||
909 | m_outofdate = true; | ||
910 | update(); | ||
911 | } | ||
912 | } | ||
913 | //fillbuffer(); | ||
914 | //update(); | ||
915 | #ifdef USEQPE | ||
629 | { | 916 | { |
630 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); | 917 | QCopEnvelope e("QPE/System", "notBusy()"); |
631 | if (!href.isEmpty()) | ||
632 | { | ||
633 | emit OnURLSelected(href, tgt); | ||
634 | } | ||
635 | } | 918 | } |
636 | locate(pagelocate()); | 919 | #endif |
637 | } | 920 | } |
638 | return; | 921 | else if ((lt & eLink) != 0) |
639 | } | 922 | { |
640 | else if ((glt & ePicture) != 0) | 923 | buffdoc.saveposn(m_lastfile, saveposn); |
641 | { | 924 | ResetScroll(); |
642 | qDebug("Big Picture:%x", pictgt); | 925 | fillbuffer(); |
643 | QImage* pm = buffdoc.getPicture(pictgt); | 926 | m_outofdate = true; |
644 | if (pm != NULL) | 927 | update(); |
645 | { | 928 | } |
646 | emit OnShowPicture(*pm); | 929 | else |
647 | delete pm; | 930 | { |
648 | } | 931 | if ((lt & ePicture) != 0) |
649 | else | 932 | { |
650 | { | 933 | QImage* pm = buffdoc.getPicture(tgt); |
651 | locate(pagelocate()); | 934 | if (pm != NULL) |
652 | } | 935 | { |
653 | return; | 936 | emit OnShowPicture(*pm); |
654 | } | 937 | delete pm; |
655 | else if (img != NULL) | 938 | } |
656 | { | 939 | } |
657 | emit OnShowPicture(*img); | 940 | else |
658 | return; | 941 | { |
659 | } | 942 | // QString anchortext = textarray[lineno]->getanchortext(startoffset); |
660 | if (m_swapmouse) | 943 | if (!href.isEmpty()) |
944 | { | ||
945 | emit OnURLSelected(href, tgt); | ||
946 | } | ||
947 | } | ||
948 | } | ||
949 | return; | ||
950 | } | ||
951 | else if ((glt & ePicture) != 0) | ||
952 | { | ||
953 | qDebug("Big Picture:%x", pictgt); | ||
954 | QImage* pm = buffdoc.getPicture(pictgt); | ||
955 | if (pm != NULL) | ||
956 | { | ||
957 | emit OnShowPicture(*pm); | ||
958 | delete pm; | ||
959 | } | ||
960 | else | ||
961 | { | ||
962 | update(); | ||
963 | } | ||
964 | return; | ||
965 | } | ||
966 | else if (img != NULL) | ||
967 | { | ||
968 | emit OnShowPicture(*img); | ||
969 | return; | ||
970 | } | ||
971 | if (m_swapmouse) | ||
661 | processmousepositionevent(_e); | 972 | processmousepositionevent(_e); |
662 | else | 973 | else |
663 | processmousewordevent(startpos, startoffset, _e, lineno); | 974 | processmousewordevent(startpos, startoffset, _e, lineno); |
975 | } | ||
976 | } | ||
977 | else | ||
978 | { | ||
979 | mouseUpOn = true; | ||
664 | } | 980 | } |
665 | } | ||
666 | else | ||
667 | { | ||
668 | mouseUpOn = true; | ||
669 | } | 981 | } |
670 | } | 982 | } |
@@ -673,5 +985,5 @@ void QTReader::mouseReleaseEvent( QMouseEvent* _e ) | |||
673 | void QTReader::focusInEvent(QFocusEvent* e) | 985 | void QTReader::focusInEvent(QFocusEvent* e) |
674 | { | 986 | { |
675 | if (m_autoScroll) timer->start(real_delay(), false); | 987 | if (m_autoScroll && (m_scrolltype != 4)) timer->start(real_delay(), false); |
676 | update(); | 988 | update(); |
677 | } | 989 | } |
@@ -681,5 +993,12 @@ void QTReader::focusOutEvent(QFocusEvent* e) | |||
681 | if (m_autoScroll) | 993 | if (m_autoScroll) |
682 | { | 994 | { |
683 | timer->stop(); | 995 | if (m_scrolltype != 4) |
996 | { | ||
997 | timer->stop(); | ||
998 | } | ||
999 | else | ||
1000 | { | ||
1001 | m_autoScroll = false; | ||
1002 | } | ||
684 | //m_scrolldy1 = m_scrolldy2 = 0; | 1003 | //m_scrolldy1 = m_scrolldy2 = 0; |
685 | } | 1004 | } |
@@ -718,5 +1037,4 @@ void QTReader::goUp() | |||
718 | void QTReader::NavUp() | 1037 | void QTReader::NavUp() |
719 | { | 1038 | { |
720 | buffdoc.unsuspend(); | ||
721 | if (buffdoc.hasnavigation()) | 1039 | if (buffdoc.hasnavigation()) |
722 | { | 1040 | { |
@@ -738,5 +1056,4 @@ void QTReader::NavUp() | |||
738 | void QTReader::NavDown() | 1056 | void QTReader::NavDown() |
739 | { | 1057 | { |
740 | buffdoc.unsuspend(); | ||
741 | if (buffdoc.hasnavigation()) | 1058 | if (buffdoc.hasnavigation()) |
742 | { | 1059 | { |
@@ -763,6 +1080,5 @@ void QTReader::zoomin() | |||
763 | setautoscroll(false); | 1080 | setautoscroll(false); |
764 | setfont(); | 1081 | setfont(); |
765 | locate(pagelocate()); | 1082 | refresh(); |
766 | repaint(); | ||
767 | setautoscroll(sc); | 1083 | setautoscroll(sc); |
768 | } | 1084 | } |
@@ -776,6 +1092,5 @@ void QTReader::zoomout() | |||
776 | setautoscroll(false); | 1092 | setautoscroll(false); |
777 | setfont(); | 1093 | setfont(); |
778 | locate(pagelocate()); | 1094 | refresh(); |
779 | repaint(); | ||
780 | setautoscroll(sc); | 1095 | setautoscroll(sc); |
781 | } | 1096 | } |
@@ -810,6 +1125,5 @@ void QTReader::increaseScroll() | |||
810 | void QTReader::keyPressEvent(QKeyEvent* e) | 1125 | void QTReader::keyPressEvent(QKeyEvent* e) |
811 | { | 1126 | { |
812 | buffdoc.unsuspend(); | 1127 | |
813 | |||
814 | //((QTReaderApp*)parent()->parent())->handlekey(e); | 1128 | //((QTReaderApp*)parent()->parent())->handlekey(e); |
815 | emit HandleKeyRequest(e); | 1129 | emit HandleKeyRequest(e); |
@@ -907,4 +1221,5 @@ void QTReader::CalculateScrollParameters() | |||
907 | void QTReader::setautoscroll(bool _sc) | 1221 | void QTReader::setautoscroll(bool _sc) |
908 | { | 1222 | { |
1223 | m_outofdate = true; | ||
909 | if (_sc == m_autoScroll) return; | 1224 | if (_sc == m_autoScroll) return; |
910 | if (m_autoScroll) | 1225 | if (m_autoScroll) |
@@ -928,4 +1243,7 @@ void QTReader::setautoscroll(bool _sc) | |||
928 | CDrawBuffer* reusebuffer = textarray[numlines]; | 1243 | CDrawBuffer* reusebuffer = textarray[numlines]; |
929 | if (reusebuffer == NULL || reusebuffer->eof()) return; | 1244 | if (reusebuffer == NULL || reusebuffer->eof()) return; |
1245 | #ifndef __STATIC | ||
1246 | if ((m_scrolltype == 4) && !checkoutput()) return; | ||
1247 | #endif | ||
930 | m_autoScroll = true; | 1248 | m_autoScroll = true; |
931 | CalculateScrollParameters(); | 1249 | CalculateScrollParameters(); |
@@ -948,5 +1266,4 @@ void QTReader::setautoscroll(bool _sc) | |||
948 | bool QTReader::getline(CDrawBuffer *buff) | 1266 | bool QTReader::getline(CDrawBuffer *buff) |
949 | { | 1267 | { |
950 | buffdoc.unsuspend(); | ||
951 | bool bRet; | 1268 | bool bRet; |
952 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 1269 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
@@ -1066,22 +1383,4 @@ void QTReader::doinplacescroll() | |||
1066 | if (!ch) | 1383 | if (!ch) |
1067 | { | 1384 | { |
1068 | /* | ||
1069 | if (m_rotated) | ||
1070 | { | ||
1071 | blitRot2(0,0,height(),width()-m_scrolldy,NULL); | ||
1072 | // blitRot2(0,0,0,height(),width()-m_scrolldy,NULL); | ||
1073 | } | ||
1074 | else | ||
1075 | { | ||
1076 | if (m_bgpm.isNull()) | ||
1077 | { | ||
1078 | p.fillRect(0,m_scrolldy,width(),height()-m_scrolldy,m_bg); | ||
1079 | } | ||
1080 | else | ||
1081 | { | ||
1082 | bitBlt(this, 0, m_scrolldy, dbuff, 0, m_scrolldy, width(), height()-m_scrolldy); | ||
1083 | } | ||
1084 | } | ||
1085 | */ | ||
1086 | m_scrolldy = m_topmargin; | 1385 | m_scrolldy = m_topmargin; |
1087 | m_autoScroll = false; | 1386 | m_autoScroll = false; |
@@ -1100,5 +1399,4 @@ void QTReader::doinplacescroll() | |||
1100 | } | 1399 | } |
1101 | #endif | 1400 | #endif |
1102 | //((QTReaderApp*)parent()->parent())->setScrollState(m_autoScroll); | ||
1103 | emit SetScrollState(m_autoScroll); | 1401 | emit SetScrollState(m_autoScroll); |
1104 | #ifdef USEQPE | 1402 | #ifdef USEQPE |
@@ -1495,7 +1793,18 @@ void QTReader::redrawScroll(QPainter* p) | |||
1495 | void QTReader::autoscroll() | 1793 | void QTReader::autoscroll() |
1496 | { | 1794 | { |
1497 | drawBackground(); | 1795 | if (m_scrolltype == 4) |
1498 | dbp->end(); | 1796 | { |
1499 | timer->start(real_delay(), false); | 1797 | readAloud(); |
1798 | } | ||
1799 | else | ||
1800 | { | ||
1801 | if (dbuff != NULL) | ||
1802 | { | ||
1803 | dbp->begin(dbuff); | ||
1804 | drawBackground(dbp); | ||
1805 | dbp->end(); | ||
1806 | } | ||
1807 | timer->start(real_delay(), false); | ||
1808 | } | ||
1500 | } | 1809 | } |
1501 | 1810 | ||
@@ -1558,37 +1867,47 @@ void QTReader::redrawall() | |||
1558 | if (m_rotated) | 1867 | if (m_rotated) |
1559 | { | 1868 | { |
1560 | #ifdef DOUBLEBUFFER | 1869 | if (dbuff != NULL) |
1561 | drawBackground(); | 1870 | { |
1562 | DrawStraight(dbp, height(), width()); | 1871 | dbp->begin(dbuff); |
1563 | dbp->end(); | 1872 | drawBackground(dbp); |
1564 | 1873 | DrawStraight(dbp, height(), width()); | |
1565 | QWMatrix m; | 1874 | dbp->end(); |
1566 | m.rotate(90); | 1875 | |
1567 | QPixmap rp = dbuff->xForm(m); | 1876 | QWMatrix m; |
1568 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | 1877 | m.rotate(90); |
1569 | #else | 1878 | QPixmap rp = dbuff->xForm(m); |
1570 | QPixmap dbuff(height(), width()); | 1879 | bitBlt(this, 0,0,&rp,0,0,-1,-1); |
1571 | QPainter dbp(&dbuff); | 1880 | } |
1572 | // dbp.setBackgroundMode(OpaqueMode); | 1881 | else |
1573 | dbp.fillRect(dbuff.rect(), m_bg); | 1882 | { |
1574 | 1883 | qDebug("This shouldn't happen but it doesn't matter if it does (rotated == double buffered)"); | |
1575 | DrawStraight(&dbp, height(), width()); | 1884 | QPixmap dbuff(height(), width()); |
1576 | 1885 | QPainter dbp(&dbuff); | |
1577 | QWMatrix m; | 1886 | |
1578 | m.rotate(90); | 1887 | drawBackground(&dbp); |
1579 | QPixmap rp = dbuff.xForm(m); | 1888 | DrawStraight(&dbp, height(), width()); |
1580 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | 1889 | |
1581 | #endif | 1890 | QWMatrix m; |
1891 | m.rotate(90); | ||
1892 | QPixmap rp = dbuff.xForm(m); | ||
1893 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | ||
1894 | } | ||
1582 | } | 1895 | } |
1583 | else | 1896 | else |
1584 | { | 1897 | { |
1585 | #ifdef DOUBLEBUFFER | 1898 | if (dbuff != NULL) |
1586 | drawBackground(); | 1899 | { |
1587 | DrawStraight(dbp, width(), height()); | 1900 | dbp->begin(dbuff); |
1588 | dbp->end(); | 1901 | drawBackground(dbp); |
1589 | bitBlt(this, 0,0,dbuff,0,0,-1,-1); | 1902 | DrawStraight(dbp, width(), height()); |
1590 | #else | 1903 | dbp->end(); |
1591 | DrawStraight(p, width(), height()); | 1904 | bitBlt(this, 0,0,dbuff,0,0,-1,-1); |
1592 | #endif | 1905 | } |
1906 | else | ||
1907 | { | ||
1908 | QPainter p(this); | ||
1909 | drawBackground(&p); | ||
1910 | DrawStraight(&p, width(), height()); | ||
1911 | } | ||
1593 | } | 1912 | } |
1594 | } | 1913 | } |
@@ -1601,8 +1920,34 @@ void QTReader::drawFonts() | |||
1601 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 1920 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
1602 | //qDebug("How refreshing..."); | 1921 | //qDebug("How refreshing..."); |
1603 | if (buffdoc.empty()) return; | 1922 | if (buffdoc.empty()) |
1923 | { | ||
1924 | if (dbuff != NULL) | ||
1925 | { | ||
1926 | dbp->begin(dbuff); | ||
1927 | drawBackground(dbp); | ||
1928 | dbp->end(); | ||
1929 | } | ||
1930 | else | ||
1931 | { | ||
1932 | QPainter p(this); | ||
1933 | drawBackground(&p); | ||
1934 | } | ||
1935 | return; | ||
1936 | } | ||
1604 | setfont(); | 1937 | setfont(); |
1605 | //if (!m_autoScroll) m_scrolldy1 = 0; | 1938 | //if (!m_autoScroll) m_scrolldy1 = 0; |
1606 | #ifdef ROTATION_ENABLED | 1939 | if (dbuff != NULL && (dbuff->width() != width() || dbuff->height() != height())) |
1940 | { | ||
1941 | qDebug("Oh no! A resize event was missed..."); | ||
1942 | if (m_rotated) | ||
1943 | { | ||
1944 | dbuff->resize(height(), width()); | ||
1945 | } | ||
1946 | else | ||
1947 | { | ||
1948 | dbuff->resize(width(), height()); | ||
1949 | } | ||
1950 | m_lastwidth = 0; | ||
1951 | } | ||
1607 | if (m_lastwidth != ((m_rotated) ? height() : width())) | 1952 | if (m_lastwidth != ((m_rotated) ? height() : width())) |
1608 | { | 1953 | { |
@@ -1612,5 +1957,7 @@ void QTReader::drawFonts() | |||
1612 | m_lastheight = ((m_rotated) ? width() : height()); | 1957 | m_lastheight = ((m_rotated) ? width() : height()); |
1613 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | 1958 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); |
1614 | locate(pagelocate()); | 1959 | buffdoc.locate(pagelocate()); |
1960 | fillbuffer(); | ||
1961 | redrawall(); | ||
1615 | // qDebug("Not Optimised %d", m_lastwidth); | 1962 | // qDebug("Not Optimised %d", m_lastwidth); |
1616 | } | 1963 | } |
@@ -1652,61 +1999,4 @@ void QTReader::drawFonts() | |||
1652 | } | 1999 | } |
1653 | } | 2000 | } |
1654 | #else | ||
1655 | if (m_lastwidth != width()) | ||
1656 | { | ||
1657 | // qDebug("Not Optimised %d", m_lastwidth); | ||
1658 | m_lastwidth = width(); | ||
1659 | m_lastheight = height(); | ||
1660 | buffdoc.setwidth(m_lastwidth-(m_left_border+m_right_border)); | ||
1661 | locate(pagelocate()); | ||
1662 | // qDebug("Not Optimised %d", m_lastwidth); | ||
1663 | } | ||
1664 | else | ||
1665 | { | ||
1666 | int newht = height(); | ||
1667 | if (m_lastheight > newht) | ||
1668 | { | ||
1669 | // qDebug("Optimised < %d %d %d", numlines, m_lastheight, newht); | ||
1670 | int ypos = m_topmargin; | ||
1671 | for (int i = 0; i < numlines; i++) | ||
1672 | { | ||
1673 | if ((ypos += textarray[i]->lineSpacing()) > newht - hmargin) | ||
1674 | { | ||
1675 | numlines = i; | ||
1676 | jumpto(mylastpos = locnarray[i+1]); | ||
1677 | break; | ||
1678 | } | ||
1679 | } | ||
1680 | // qDebug("Optimised < %d", numlines); | ||
1681 | m_lastheight = newht; | ||
1682 | } | ||
1683 | else if (m_lastheight < newht) | ||
1684 | { | ||
1685 | // qDebug("Optimised > %d", numlines); | ||
1686 | int ypos = m_topmargin; | ||
1687 | for (int i = 0; i <= numlines; i++) | ||
1688 | { | ||
1689 | ypos += textarray[i]->lineSpacing(); | ||
1690 | } | ||
1691 | fillbuffer(numlines+1, ypos, newht); | ||
1692 | // qDebug("Optimised > %d", numlines); | ||
1693 | } | ||
1694 | if (numlines > 0) | ||
1695 | { | ||
1696 | int ypos = textarray[0]->ascent()+m_topmargin; | ||
1697 | textarray[0]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | ||
1698 | // int last = (m_showlast) ? numlines : numlines-1; | ||
1699 | // for (int i = 1; i <= last; i++) | ||
1700 | for (int i = 1; i < numlines; i++) | ||
1701 | { | ||
1702 | // ypos += (textarray[i-1]->lineSpacing() + textarray[i]->lineSpacing())/2; | ||
1703 | ypos += (textarray[i-1]->descent() + textarray[i]->ascent())+ | ||
1704 | (textarray[i-1]->lineExtraSpacing() + textarray[i]->lineExtraSpacing())/2; | ||
1705 | textarray[i]->render( p, ypos, m_bMonoSpaced, m_charWidth, width(), m_left_border, m_right_border, m_bg, height()-m_topmargin-m_bottommargin); | ||
1706 | } | ||
1707 | // mylastpos = locate(); | ||
1708 | } | ||
1709 | } | ||
1710 | #endif | ||
1711 | emitRedraw(); | 2001 | emitRedraw(); |
1712 | } | 2002 | } |
@@ -1929,5 +2219,4 @@ bool QTReader::ChangeFont(int tgt) | |||
1929 | void QTReader::init() | 2219 | void QTReader::init() |
1930 | { | 2220 | { |
1931 | buffdoc.unsuspend(); | ||
1932 | setBackgroundColor( m_bg ); | 2221 | setBackgroundColor( m_bg ); |
1933 | buffdoc.setfilter(getfilter()); | 2222 | buffdoc.setfilter(getfilter()); |
@@ -1936,4 +2225,8 @@ void QTReader::init() | |||
1936 | timer = new QTimer(this); | 2225 | timer = new QTimer(this); |
1937 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); | 2226 | connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); |
2227 | #ifdef USETIMER | ||
2228 | m_dragtimer = new QTimer(this); | ||
2229 | connect(m_dragtimer, SIGNAL(timeout()), this, SLOT(actionDrag())); | ||
2230 | #endif | ||
1938 | // QMessageBox::information(this, "init", m_lastfile, 1); | 2231 | // QMessageBox::information(this, "init", m_lastfile, 1); |
1939 | setfont(); | 2232 | setfont(); |
@@ -1945,8 +2238,13 @@ void QTReader::init() | |||
1945 | QTReader::~QTReader() | 2238 | QTReader::~QTReader() |
1946 | { | 2239 | { |
1947 | #ifdef DOUBLEBUFFER | 2240 | if (m_output != NULL) |
1948 | delete dbuff; | 2241 | { |
1949 | delete dbp; | 2242 | delete m_output; |
1950 | #endif | 2243 | } |
2244 | if (dbuff != NULL) | ||
2245 | { | ||
2246 | delete dbuff; | ||
2247 | delete dbp; | ||
2248 | } | ||
1951 | #ifdef USEQPE | 2249 | #ifdef USEQPE |
1952 | if (m_autoScroll) | 2250 | if (m_autoScroll) |
@@ -1983,7 +2281,45 @@ void QTReader::printIt() | |||
1983 | // | 2281 | // |
1984 | 2282 | ||
1985 | void QTReader::paintEvent( QPaintEvent * ) | 2283 | void QTReader::paintEvent( QPaintEvent * p ) |
1986 | { | 2284 | { |
1987 | drawFonts(); | 2285 | if ((dbuff != NULL) && !m_outofdate) |
2286 | { | ||
2287 | if (m_rotated) | ||
2288 | { | ||
2289 | if ((p->rect().width() != width()) || (p->rect().height() != height())) | ||
2290 | { | ||
2291 | qDebug("Partial paint"); | ||
2292 | QRect r; | ||
2293 | r.setTop(width()-p->rect().right()-1); | ||
2294 | r.setLeft(p->rect().top()); | ||
2295 | r.setHeight(p->rect().width()); | ||
2296 | r.setWidth(p->rect().height()); | ||
2297 | QPixmap p1(r.width(), r.height()); | ||
2298 | bitBlt(&p1, QPoint(0, 0), dbuff, r); | ||
2299 | QWMatrix m; | ||
2300 | m.rotate(90); | ||
2301 | QPixmap p2 = p1.xForm(m); | ||
2302 | bitBlt(this, p->rect().left(), p->rect().top(), &p2, 0, 0, -1, -1); | ||
2303 | } | ||
2304 | else | ||
2305 | { | ||
2306 | qDebug("Full paint"); | ||
2307 | QWMatrix m; | ||
2308 | m.rotate(90); | ||
2309 | QPixmap rp = dbuff->xForm(m); | ||
2310 | bitBlt(this, 0,0,&rp,0,0,-1,-1); | ||
2311 | } | ||
2312 | } | ||
2313 | else | ||
2314 | { | ||
2315 | //bitBlt(this, 0,0,dbuff,0,0,-1,-1); | ||
2316 | bitBlt(this,p->rect().topLeft(),dbuff,p->rect()); | ||
2317 | } | ||
2318 | } | ||
2319 | else | ||
2320 | { | ||
2321 | drawFonts(); | ||
2322 | } | ||
2323 | m_outofdate = false; | ||
1988 | } | 2324 | } |
1989 | 2325 | ||
@@ -2017,11 +2353,21 @@ int main( int argc, tchar **argv ) | |||
2017 | 2353 | ||
2018 | 2354 | ||
2355 | bool QTReader::locate(unsigned long n) | ||
2356 | { | ||
2357 | m_outofdate = true; | ||
2358 | m_lastwidth = 0; | ||
2359 | locnarray[0] = n; | ||
2360 | ResetScroll(); | ||
2361 | update(); | ||
2362 | return true; | ||
2363 | } | ||
2364 | /* | ||
2019 | bool QTReader::locate(unsigned long n) { | 2365 | bool QTReader::locate(unsigned long n) { |
2020 | //printf("Locate\n"); | 2366 | //printf("Locate\n"); |
2021 | buffdoc.unsuspend(); | ||
2022 | buffdoc.locate(n); | 2367 | buffdoc.locate(n); |
2023 | // // qDebug("&buffdoc.located"); | 2368 | // // qDebug("&buffdoc.located"); |
2024 | ResetScroll(); | 2369 | ResetScroll(); |
2025 | fillbuffer(); | 2370 | fillbuffer(); |
2371 | m_outofdate = true; | ||
2026 | // // qDebug("&Buffer filled"); | 2372 | // // qDebug("&Buffer filled"); |
2027 | update(); | 2373 | update(); |
@@ -2030,5 +2376,5 @@ bool QTReader::locate(unsigned long n) { | |||
2030 | return true; | 2376 | return true; |
2031 | } | 2377 | } |
2032 | 2378 | */ | |
2033 | unsigned int QTReader::screenlines() | 2379 | unsigned int QTReader::screenlines() |
2034 | { | 2380 | { |
@@ -2040,5 +2386,4 @@ unsigned int QTReader::screenlines() | |||
2040 | bool QTReader::fillbuffer(int reuse, int ht, int newht) | 2386 | bool QTReader::fillbuffer(int reuse, int ht, int newht) |
2041 | { | 2387 | { |
2042 | buffdoc.unsuspend(); | ||
2043 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); | 2388 | int hmargin = ((m_scrollpos == 1) ? _SBARHEIGHT : 0); |
2044 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; | 2389 | if (hmargin < m_bottommargin) hmargin = m_bottommargin; |
@@ -2064,12 +2409,21 @@ bool QTReader::fillbuffer(int reuse, int ht, int newht) | |||
2064 | int ch = getline(textarray[numlines]); | 2409 | int ch = getline(textarray[numlines]); |
2065 | ypos += textarray[numlines]->lineSpacing(); | 2410 | ypos += textarray[numlines]->lineSpacing(); |
2411 | /* | ||
2412 | QString tmp = toQString(textarray[numlines]->data()); | ||
2413 | printf("[%u, %u, %u](%s):%s\n", lastypos, m_lastheight-hmargin, ypos, | ||
2414 | ((textarray[numlines]->showPartial()) ? "TRUE" : "FALSE"), | ||
2415 | (const char*)tmp); | ||
2416 | */ | ||
2066 | numlines++; | 2417 | numlines++; |
2067 | if (!ch) | 2418 | if (!ch) |
2068 | { | 2419 | { |
2069 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) | 2420 | if (numlines - reuse == 1 /*&& locnarray[numlines] == buffdoc.locate()*/) |
2070 | { | 2421 | { |
2071 | qDebug("FALSE"); | 2422 | qDebug("FALSE"); |
2423 | if (oldpagepos < buffdoc.endSection()) | ||
2072 | locate(oldpagepos); | 2424 | locate(oldpagepos); |
2073 | return false; | 2425 | else |
2426 | dopageup(buffdoc.endSection()); | ||
2427 | return false; | ||
2074 | } | 2428 | } |
2075 | else | 2429 | else |
@@ -2102,5 +2456,4 @@ void QTReader::dopagedn() | |||
2102 | { | 2456 | { |
2103 | // qDebug("HEIGHT(2):%d", m_lastheight); | 2457 | // qDebug("HEIGHT(2):%d", m_lastheight); |
2104 | buffdoc.unsuspend(); | ||
2105 | ResetScroll(); | 2458 | ResetScroll(); |
2106 | int skip = 0, ypos = m_topmargin; | 2459 | int skip = 0, ypos = m_topmargin; |
@@ -2151,6 +2504,8 @@ bool QTReader::synch(size_t start, size_t end) | |||
2151 | tchar ch = getch(); | 2504 | tchar ch = getch(); |
2152 | if (ch == 10) return true; | 2505 | if (ch == 10) return true; |
2153 | if (ch == UEOF) return false; | 2506 | if ((ch == UEOF) || (ch == 6)) |
2154 | if (ch == 6) return false; | 2507 | { |
2508 | return false; | ||
2509 | } | ||
2155 | } | 2510 | } |
2156 | return false; | 2511 | return false; |
@@ -2159,10 +2514,9 @@ bool QTReader::synch(size_t start, size_t end) | |||
2159 | void QTReader::dopageup(unsigned int target) | 2514 | void QTReader::dopageup(unsigned int target) |
2160 | { | 2515 | { |
2161 | buffdoc.unsuspend(); | ||
2162 | ResetScroll(); | 2516 | ResetScroll(); |
2163 | CBufferFace<CDrawBuffer*> buff; | 2517 | CBufferFace<CDrawBuffer*> buff; |
2164 | CBufferFace<size_t> loc; | 2518 | CBufferFace<size_t> loc; |
2165 | |||
2166 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; | 2519 | size_t delta, guess = 2*(locate()-pagelocate()), lastdelta = 0; |
2520 | qDebug("dopageup:: locate():%u pagelocate():%u guess:%u", locate(), pagelocate(), guess); | ||
2167 | bool ch = true; | 2521 | bool ch = true; |
2168 | int nbfl, ypos = m_topmargin; | 2522 | int nbfl, ypos = m_topmargin; |
@@ -2181,4 +2535,5 @@ void QTReader::dopageup(unsigned int target) | |||
2181 | { | 2535 | { |
2182 | delta = 0; // 0 is a flag to say don't guess any more | 2536 | delta = 0; // 0 is a flag to say don't guess any more |
2537 | qDebug("Jumping to startsection:%d", buffdoc.startSection()); | ||
2183 | jumpto(buffdoc.startSection()); | 2538 | jumpto(buffdoc.startSection()); |
2184 | } | 2539 | } |
@@ -2188,13 +2543,13 @@ void QTReader::dopageup(unsigned int target) | |||
2188 | if (!synch(target-delta, target-lastdelta)) | 2543 | if (!synch(target-delta, target-lastdelta)) |
2189 | { | 2544 | { |
2190 | lastdelta = delta; | 2545 | lastdelta = delta; |
2191 | if (guess < 4000) | 2546 | if (guess < 4000) |
2192 | { | 2547 | { |
2193 | guess <<= 1; | 2548 | guess <<= 1; |
2194 | continue; | 2549 | continue; |
2195 | } | 2550 | } |
2196 | else | 2551 | else |
2197 | { | 2552 | { |
2198 | jumpto(target-delta); | 2553 | jumpto(target-delta); |
2199 | } | 2554 | } |
2200 | } | 2555 | } |
@@ -2294,6 +2649,7 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn) | |||
2294 | bool bRC = false; | 2649 | bool bRC = false; |
2295 | unsigned int lcn = _lcn; | 2650 | unsigned int lcn = _lcn; |
2651 | bDoUpdates = false; | ||
2296 | ResetScroll(); | 2652 | ResetScroll(); |
2297 | if (m_lastfile == newfile) | 2653 | if (m_lastfile == newfile && lcn == 0) |
2298 | { | 2654 | { |
2299 | lcn = m_lastposn; | 2655 | lcn = m_lastposn; |
@@ -2317,9 +2673,9 @@ bool QTReader::load_file(const char *newfile, unsigned int _lcn) | |||
2317 | buffdoc.setContinuous(m_continuousDocument); | 2673 | buffdoc.setContinuous(m_continuousDocument); |
2318 | qDebug("buffdoc.openfile done"); | 2674 | qDebug("buffdoc.openfile done"); |
2319 | locate(lcn); | ||
2320 | qDebug("buffdoc.locate done"); | ||
2321 | } | 2675 | } |
2322 | setfilter(getfilter()); | 2676 | setfilter(getfilter()); |
2323 | qDebug("Updated"); | 2677 | qDebug("Updated"); |
2678 | bDoUpdates = true; | ||
2679 | locate(lcn); | ||
2324 | return bRC; | 2680 | return bRC; |
2325 | } | 2681 | } |
@@ -2359,4 +2715,5 @@ void QTReader::lineDown() | |||
2359 | getline(textarray[numlines]); | 2715 | getline(textarray[numlines]); |
2360 | mylastpos = locate(); | 2716 | mylastpos = locate(); |
2717 | m_outofdate = true; | ||
2361 | update(); | 2718 | update(); |
2362 | } | 2719 | } |
@@ -2573,14 +2930,19 @@ MarkupType QTReader::PreferredMarkup() | |||
2573 | return m; | 2930 | return m; |
2574 | } | 2931 | } |
2575 | #ifdef DOUBLEBUFFER | 2932 | |
2576 | void QTReader::resizeEvent( QResizeEvent * p ) | 2933 | void QTReader::resizeEvent( QResizeEvent * p ) |
2577 | { | 2934 | { |
2578 | if (m_rotated) | 2935 | qDebug("Resizing"); |
2579 | { | 2936 | m_outofdate = true; |
2580 | dbuff->resize(p->size().height(),p->size().width()); | 2937 | if (dbuff != NULL) |
2581 | } | ||
2582 | else | ||
2583 | { | 2938 | { |
2584 | dbuff->resize(p->size()); | 2939 | if (m_rotated) |
2940 | { | ||
2941 | dbuff->resize(p->size().height(),p->size().width()); | ||
2942 | } | ||
2943 | else | ||
2944 | { | ||
2945 | dbuff->resize(p->size()); | ||
2946 | } | ||
2585 | } | 2947 | } |
2586 | m_bgIsScaled = false; | 2948 | m_bgIsScaled = false; |
@@ -2606,27 +2968,21 @@ void QTReader::resizeEvent( QResizeEvent * p ) | |||
2606 | m_left_border = (w*m_absleft_border+500)/1000; | 2968 | m_left_border = (w*m_absleft_border+500)/1000; |
2607 | m_right_border = (w*m_absright_border+500)/1000; | 2969 | m_right_border = (w*m_absright_border+500)/1000; |
2608 | |||
2609 | qDebug("Top margin:%u", m_topmargin ); | ||
2610 | qDebug("Bottom margin:%u", m_bottommargin ); | ||
2611 | qDebug("Left margin:%u", m_left_border ); | ||
2612 | qDebug("Right margin:%u", m_right_border ); | ||
2613 | } | 2970 | } |
2971 | if (dbuff != NULL && buffdoc.empty()) | ||
2972 | { | ||
2973 | dbp->begin(dbuff); | ||
2974 | drawBackground(dbp); | ||
2975 | dbp->end(); | ||
2976 | } | ||
2614 | } | 2977 | } |
2615 | #endif | ||
2616 | 2978 | ||
2617 | void QTReader::setrotated(bool sfs) | 2979 | void QTReader::setrotated(bool sfs) |
2618 | { | 2980 | { |
2981 | qDebug("Rotating"); | ||
2619 | m_rotated = sfs; | 2982 | m_rotated = sfs; |
2620 | #ifdef DOUBLEBUFFER | 2983 | setDoubleBuffer(m_doubleBuffered); |
2621 | if (m_rotated) | ||
2622 | { | ||
2623 | dbuff->resize(height(), width()); | ||
2624 | } | ||
2625 | else | ||
2626 | { | ||
2627 | dbuff->resize(width(), height()); | ||
2628 | } | ||
2629 | m_bgIsScaled = false; | 2984 | m_bgIsScaled = false; |
2630 | #endif | 2985 | m_outofdate = true; |
2986 | /* | ||
2631 | int h, w; | 2987 | int h, w; |
2632 | if (m_rotated) | 2988 | if (m_rotated) |
@@ -2649,36 +3005,55 @@ void QTReader::setrotated(bool sfs) | |||
2649 | qDebug("Left margin:%u", m_left_border ); | 3005 | qDebug("Left margin:%u", m_left_border ); |
2650 | qDebug("Right margin:%u", m_right_border ); | 3006 | qDebug("Right margin:%u", m_right_border ); |
3007 | */ | ||
2651 | } | 3008 | } |
2652 | 3009 | ||
2653 | void QTReader::drawBackground() | 3010 | void QTReader::drawBackground(QPainter *p) |
2654 | { | 3011 | { |
2655 | dbp->begin(dbuff); | 3012 | // p->setBackgroundMode(OpaqueMode); |
2656 | // dbp->setBackgroundMode(OpaqueMode); | 3013 | p->setBackgroundColor(m_bg); |
2657 | dbp->setBackgroundColor(m_bg); | 3014 | if (dbuff != NULL) |
2658 | dbp->eraseRect(dbuff->rect()); | 3015 | { |
3016 | p->eraseRect(dbuff->rect()); | ||
3017 | } | ||
3018 | else | ||
3019 | { | ||
3020 | if (m_rotated) | ||
3021 | { | ||
3022 | p->eraseRect(0,0,height(),width()); | ||
3023 | } | ||
3024 | else | ||
3025 | { | ||
3026 | p->eraseRect(rect()); | ||
3027 | } | ||
3028 | } | ||
2659 | if (!m_bgpm.isNull()) | 3029 | if (!m_bgpm.isNull()) |
2660 | { | 3030 | { |
2661 | // dbp->setBackgroundMode(TransparentMode); | 3031 | // p->setBackgroundMode(TransparentMode); |
2662 | switch (m_bgtype) | 3032 | switch (m_bgtype) |
2663 | { | 3033 | { |
2664 | case bgCentred: | 3034 | case bgCentred: |
2665 | { | 3035 | { |
2666 | int w = (dbuff->rect().width()-m_bgpm.width())/2; | 3036 | if (dbuff == NULL) |
2667 | int h = (dbuff->rect().height()-m_bgpm.height())/2; | 3037 | { |
2668 | dbp->drawPixmap(w,h,m_bgpm); | 3038 | p->drawPixmap(width(),height(),m_bgpm); |
3039 | } | ||
3040 | else | ||
3041 | { | ||
3042 | int w = (dbuff->rect().width()-m_bgpm.width())/2; | ||
3043 | int h = (dbuff->rect().height()-m_bgpm.height())/2; | ||
3044 | p->drawPixmap(w,h,m_bgpm); | ||
3045 | } | ||
2669 | } | 3046 | } |
2670 | break; | 3047 | break; |
2671 | case bgTiled: | 3048 | case bgTiled: |
2672 | { | 3049 | { |
2673 | dbp->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm); | 3050 | if (dbuff == NULL) |
2674 | /* | ||
2675 | for (int h = 0; h < dbuff->rect().height(); h += m_bgpm.height()) | ||
2676 | { | 3051 | { |
2677 | for (int w = 0; w < dbuff->rect().width(); w += m_bgpm.width()) | 3052 | p->drawTiledPixmap(0,0,width(),height(),m_bgpm); |
2678 | { | 3053 | } |
2679 | dbp->drawPixmap(w,h,m_bgpm); | 3054 | else |
2680 | } | 3055 | { |
3056 | p->drawTiledPixmap(0,0,dbuff->rect().width(),dbuff->rect().height(),m_bgpm); | ||
2681 | } | 3057 | } |
2682 | */ | ||
2683 | } | 3058 | } |
2684 | break; | 3059 | break; |
@@ -2689,7 +3064,14 @@ void QTReader::drawBackground() | |||
2689 | m_bgIsScaled = true; | 3064 | m_bgIsScaled = true; |
2690 | QImage im = m_bgpm.convertToImage(); | 3065 | QImage im = m_bgpm.convertToImage(); |
2691 | m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height())); | 3066 | if (dbuff == NULL) |
3067 | { | ||
3068 | m_bgpm.convertFromImage(im.smoothScale(width(),height())); | ||
3069 | } | ||
3070 | else | ||
3071 | { | ||
3072 | m_bgpm.convertFromImage(im.smoothScale(dbuff->rect().width(), dbuff->rect().height())); | ||
3073 | } | ||
2692 | } | 3074 | } |
2693 | dbp->drawPixmap(0,0,m_bgpm); | 3075 | p->drawPixmap(0,0,m_bgpm); |
2694 | } | 3076 | } |
2695 | break; | 3077 | break; |
@@ -2697,5 +3079,5 @@ void QTReader::drawBackground() | |||
2697 | qDebug("Unknown background type"); | 3079 | qDebug("Unknown background type"); |
2698 | } | 3080 | } |
2699 | // dbp->setBackgroundMode(OpaqueMode); | 3081 | // p->setBackgroundMode(OpaqueMode); |
2700 | } | 3082 | } |
2701 | } | 3083 | } |
@@ -2760,5 +3142,10 @@ void QTReader::blitRot(int dx, int dy, int sw, int sh, CDrawBuffer* txt) | |||
2760 | QString QTReader::about() | 3142 | QString QTReader::about() |
2761 | { | 3143 | { |
2762 | return QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka"; | 3144 | QString ab = QString("QTReader widget (c) Tim Wentford\n")+buffdoc.about() + "\nMini-scrollbar by Markus Gritsch\nNavigation History fixes by Frantisek Dufka"; |
3145 | if (m_output != NULL) | ||
3146 | { | ||
3147 | ab += QString("\n") + m_output->about(); | ||
3148 | } | ||
3149 | return ab; | ||
2763 | } | 3150 | } |
2764 | 3151 | ||
@@ -2898,5 +3285,5 @@ void QTReader::gotoLink() | |||
2898 | if (!href.isEmpty()) | 3285 | if (!href.isEmpty()) |
2899 | { | 3286 | { |
2900 | if (!buffdoc.getFile(href)) | 3287 | if (!buffdoc.getFile(href, nm)) |
2901 | { | 3288 | { |
2902 | emit NewFileRequest(href); | 3289 | emit NewFileRequest(href); |
@@ -2906,4 +3293,5 @@ void QTReader::gotoLink() | |||
2906 | ResetScroll(); | 3293 | ResetScroll(); |
2907 | fillbuffer(); | 3294 | fillbuffer(); |
3295 | m_outofdate = true; | ||
2908 | update(); | 3296 | update(); |
2909 | } | 3297 | } |
@@ -2914,5 +3302,7 @@ void QTReader::gotoLink() | |||
2914 | if (buffdoc.findanchor(nm)) | 3302 | if (buffdoc.findanchor(nm)) |
2915 | { | 3303 | { |
3304 | buffdoc.resetPos(); | ||
2916 | fillbuffer(); | 3305 | fillbuffer(); |
3306 | m_outofdate = true; | ||
2917 | update(); | 3307 | update(); |
2918 | } | 3308 | } |
@@ -2931,4 +3321,5 @@ void QTReader::gotoLink() | |||
2931 | ResetScroll(); | 3321 | ResetScroll(); |
2932 | fillbuffer(); | 3322 | fillbuffer(); |
3323 | m_outofdate = true; | ||
2933 | update(); | 3324 | update(); |
2934 | } | 3325 | } |
@@ -2950,7 +3341,7 @@ void QTReader::gotoLink() | |||
2950 | { | 3341 | { |
2951 | emit OnURLSelected(href, tgt); | 3342 | emit OnURLSelected(href, tgt); |
3343 | refresh(); | ||
2952 | } | 3344 | } |
2953 | } | 3345 | } |
2954 | locate(pagelocate()); | ||
2955 | } | 3346 | } |
2956 | m_currentlinkstyle = NULL; | 3347 | m_currentlinkstyle = NULL; |
@@ -2961,4 +3352,5 @@ void QTReader::gotoLink() | |||
2961 | void QTReader::refresh(bool full) | 3352 | void QTReader::refresh(bool full) |
2962 | { | 3353 | { |
3354 | qDebug("Refreshing"); | ||
2963 | int h, w; | 3355 | int h, w; |
2964 | if (m_rotated) | 3356 | if (m_rotated) |
@@ -2982,4 +3374,119 @@ void QTReader::refresh(bool full) | |||
2982 | qDebug("Right margin:%u", m_right_border ); | 3374 | qDebug("Right margin:%u", m_right_border ); |
2983 | if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate()); | 3375 | if (full && m_highlightfilter) m_highlightfilter->refresh(pagelocate()); |
3376 | m_outofdate = true; | ||
2984 | locate(pagelocate()); | 3377 | locate(pagelocate()); |
2985 | } | 3378 | } |
3379 | |||
3380 | #include "striphtml.h" | ||
3381 | |||
3382 | CFilterChain* QTReader::getfilter() | ||
3383 | { | ||
3384 | CFilterChain * filt = new CFilterChain(getencoding()); | ||
3385 | if (bstripcr) filt->addfilter(new stripcr); | ||
3386 | |||
3387 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | ||
3388 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | ||
3389 | // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
3390 | |||
3391 | #ifdef __STATIC | ||
3392 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
3393 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
3394 | { | ||
3395 | striphtml* f = new striphtml(m_lastfile); | ||
3396 | f->setchm(true); | ||
3397 | filt->addfilter(f); | ||
3398 | } | ||
3399 | #else | ||
3400 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); | ||
3401 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
3402 | { | ||
3403 | ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); | ||
3404 | ((striphtml*)f->filter())->setchm(true); | ||
3405 | filt->addfilter(f); | ||
3406 | } | ||
3407 | #endif | ||
3408 | m_highlightfilter = new HighlightFilter(this); | ||
3409 | filt->addfilter(m_highlightfilter); | ||
3410 | |||
3411 | if (bdehyphen) filt->addfilter(new dehyphen); | ||
3412 | if (bunindent) filt->addfilter(new unindent); | ||
3413 | if (brepara) filt->addfilter(new repara(m_reparastring)); | ||
3414 | if (bonespace) filt->addfilter(new OnePara); | ||
3415 | if (bindenter) filt->addfilter(new indenter(bindenter)); | ||
3416 | if (bdblspce) filt->addfilter(new dblspce); | ||
3417 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | ||
3418 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | ||
3419 | if (brepalm) filt->addfilter(new repalm); | ||
3420 | if (bunderlineLink) filt->addfilter(new underlineLink); | ||
3421 | if (bkern) filt->addfilter(new kern); | ||
3422 | if (bremap) filt->addfilter(new remap); | ||
3423 | if (bmakebold) filt->addfilter(new embolden); | ||
3424 | if (bfulljust) filt->addfilter(new FullJust); | ||
3425 | int r,g,b; | ||
3426 | m_default_bg.rgb(&r, &g, &b); | ||
3427 | if (r != 255 || g != 255 || b != 255) | ||
3428 | filt->addfilter(new setbg(r,g,b)); | ||
3429 | m_default_fg.rgb(&r, &g, &b); | ||
3430 | if (r != 0 || g != 0 || b != 0) | ||
3431 | filt->addfilter(new setfg(r,g,b)); | ||
3432 | // if (bNegative) filt->addfilter(new makeNegative); | ||
3433 | if (bInverse) filt->addfilter(new makeInverse); | ||
3434 | if (bNoInlineTables) filt->addfilter(new tableLink); | ||
3435 | return filt; | ||
3436 | } | ||
3437 | |||
3438 | void QTReader::readAloud() | ||
3439 | { | ||
3440 | #ifdef __STATIC | ||
3441 | return; | ||
3442 | #else | ||
3443 | CBuffer para; | ||
3444 | jumpto(pagelocate()); | ||
3445 | while (m_autoScroll && (buffdoc.getpara(para) != -1)) | ||
3446 | { | ||
3447 | if (para.length() > 0) | ||
3448 | { | ||
3449 | unsigned long lastpos = buffdoc.explocate(); | ||
3450 | while (lastpos > mylastpos) | ||
3451 | { | ||
3452 | dopagedn(); | ||
3453 | qApp->processEvents(); | ||
3454 | } | ||
3455 | jumpto(lastpos); | ||
3456 | QString txt = toQString(para.data()); | ||
3457 | |||
3458 | doOutput(txt); | ||
3459 | } | ||
3460 | qApp->processEvents(); | ||
3461 | } | ||
3462 | #endif | ||
3463 | } | ||
3464 | |||
3465 | bool QTReader::doOutput(const QString& wrd) | ||
3466 | { | ||
3467 | if (m_output != NULL) | ||
3468 | { | ||
3469 | m_output->output(wrd); | ||
3470 | return true; | ||
3471 | } | ||
3472 | else | ||
3473 | { | ||
3474 | return false; | ||
3475 | } | ||
3476 | } | ||
3477 | |||
3478 | bool QTReader::checkoutput() | ||
3479 | { | ||
3480 | if (m_output == NULL) | ||
3481 | { | ||
3482 | m_output = new outputcodec(m_outputName); | ||
3483 | if (reinterpret_cast<outputcodec*>(m_output)->getStatus() != 0) | ||
3484 | { | ||
3485 | delete m_output; | ||
3486 | m_output = NULL; | ||
3487 | QMessageBox::warning(this, PROGNAME, QString("Couldn't find output codec\n")+m_outputName); | ||
3488 | return false; | ||
3489 | } | ||
3490 | } | ||
3491 | return true; | ||
3492 | } | ||