Diffstat (limited to 'noncore/apps/opie-write/qrichtext_p.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qrichtext_p.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/noncore/apps/opie-write/qrichtext_p.cpp b/noncore/apps/opie-write/qrichtext_p.cpp index 6783e0b..2e8b09c 100644 --- a/noncore/apps/opie-write/qrichtext_p.cpp +++ b/noncore/apps/opie-write/qrichtext_p.cpp | |||
@@ -14,48 +14,51 @@ | |||
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | 37 | ||
38 | #include <opie2/odebug.h> | ||
39 | using namespace Opie::Core; | ||
40 | |||
38 | #include "qrichtext_p.h" | 41 | #include "qrichtext_p.h" |
39 | 42 | ||
40 | using namespace Qt3; | 43 | using namespace Qt3; |
41 | 44 | ||
42 | QTextCommand::~QTextCommand() {} | 45 | QTextCommand::~QTextCommand() {} |
43 | QTextCommand::Commands QTextCommand::type() const { return Invalid; } | 46 | QTextCommand::Commands QTextCommand::type() const { return Invalid; } |
44 | 47 | ||
45 | 48 | ||
46 | QTextCustomItem::~QTextCustomItem() {} | 49 | QTextCustomItem::~QTextCustomItem() {} |
47 | void QTextCustomItem::adjustToPainter( QPainter* p){ if ( p ) width = 0; } | 50 | void QTextCustomItem::adjustToPainter( QPainter* p){ if ( p ) width = 0; } |
48 | QTextCustomItem::Placement QTextCustomItem::placement() const { return PlaceInline; } | 51 | QTextCustomItem::Placement QTextCustomItem::placement() const { return PlaceInline; } |
49 | 52 | ||
50 | bool QTextCustomItem::ownLine() const { return FALSE; } | 53 | bool QTextCustomItem::ownLine() const { return FALSE; } |
51 | void QTextCustomItem::resize( int nwidth ){ width = nwidth; } | 54 | void QTextCustomItem::resize( int nwidth ){ width = nwidth; } |
52 | void QTextCustomItem::invalidate() {} | 55 | void QTextCustomItem::invalidate() {} |
53 | 56 | ||
54 | bool QTextCustomItem::isNested() const { return FALSE; } | 57 | bool QTextCustomItem::isNested() const { return FALSE; } |
55 | int QTextCustomItem::minimumWidth() const { return 0; } | 58 | int QTextCustomItem::minimumWidth() const { return 0; } |
56 | 59 | ||
57 | QString QTextCustomItem::richText() const { return QString::null; } | 60 | QString QTextCustomItem::richText() const { return QString::null; } |
58 | 61 | ||
59 | bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool ) | 62 | bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool ) |
60 | { | 63 | { |
61 | return TRUE; | 64 | return TRUE; |
@@ -116,49 +119,49 @@ int QTextCursor::y() const | |||
116 | { | 119 | { |
117 | int dummy, line; | 120 | int dummy, line; |
118 | para->lineStartOfChar( idx, &dummy, &line ); | 121 | para->lineStartOfChar( idx, &dummy, &line ); |
119 | return para->lineY( line ); | 122 | return para->lineY( line ); |
120 | } | 123 | } |
121 | 124 | ||
122 | int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); } | 125 | int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); } |
123 | int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); } | 126 | int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); } |
124 | 127 | ||
125 | QTextDocument *QTextCursor::document() const | 128 | QTextDocument *QTextCursor::document() const |
126 | { | 129 | { |
127 | return para ? para->document() : 0; | 130 | return para ? para->document() : 0; |
128 | } | 131 | } |
129 | 132 | ||
130 | void QTextCursor::gotoPosition( QTextParagraph* p, int index ) | 133 | void QTextCursor::gotoPosition( QTextParagraph* p, int index ) |
131 | { | 134 | { |
132 | if ( para && p != para ) { | 135 | if ( para && p != para ) { |
133 | while ( para->document() != p->document() && !indices.isEmpty() ) | 136 | while ( para->document() != p->document() && !indices.isEmpty() ) |
134 | pop(); | 137 | pop(); |
135 | Q_ASSERT( indices.isEmpty() || para->document() == p->document() ); | 138 | Q_ASSERT( indices.isEmpty() || para->document() == p->document() ); |
136 | } | 139 | } |
137 | para = p; | 140 | para = p; |
138 | if ( index < 0 || index >= para->length() ) { | 141 | if ( index < 0 || index >= para->length() ) { |
139 | #if defined(QT_CHECK_RANGE) | 142 | #if defined(QT_CHECK_RANGE) |
140 | qWarning( "QTextCursor::gotoParagraph Index: %d out of range", index ); | 143 | owarn << "QTextCursor::gotoParagraph Index: " << index << " out of range" << oendl; |
141 | #endif | 144 | #endif |
142 | index = index < 0 ? 0 : para->length() - 1; | 145 | index = index < 0 ? 0 : para->length() - 1; |
143 | } | 146 | } |
144 | 147 | ||
145 | tmpIndex = -1; | 148 | tmpIndex = -1; |
146 | idx = index; | 149 | idx = index; |
147 | } | 150 | } |
148 | 151 | ||
149 | bool QTextDocument::hasSelection( int id, bool visible ) const | 152 | bool QTextDocument::hasSelection( int id, bool visible ) const |
150 | { | 153 | { |
151 | return ( selections.find( id ) != selections.end() && | 154 | return ( selections.find( id ) != selections.end() && |
152 | ( !visible || | 155 | ( !visible || |
153 | ( (QTextDocument*)this )->selectionStartCursor( id ) != | 156 | ( (QTextDocument*)this )->selectionStartCursor( id ) != |
154 | ( (QTextDocument*)this )->selectionEndCursor( id ) ) ); | 157 | ( (QTextDocument*)this )->selectionEndCursor( id ) ) ); |
155 | } | 158 | } |
156 | 159 | ||
157 | void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor ) | 160 | void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor ) |
158 | { | 161 | { |
159 | QTextDocumentSelection sel; | 162 | QTextDocumentSelection sel; |
160 | sel.startCursor = cursor; | 163 | sel.startCursor = cursor; |
161 | sel.endCursor = cursor; | 164 | sel.endCursor = cursor; |
162 | sel.swapped = FALSE; | 165 | sel.swapped = FALSE; |
163 | selections[ id ] = sel; | 166 | selections[ id ] = sel; |
164 | } | 167 | } |
@@ -456,98 +459,98 @@ int QTextParagraph::selectionEnd( int id ) const | |||
456 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); | 459 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); |
457 | if ( it == mSelections->end() ) | 460 | if ( it == mSelections->end() ) |
458 | return -1; | 461 | return -1; |
459 | return ( *it ).end; | 462 | return ( *it ).end; |
460 | } | 463 | } |
461 | 464 | ||
462 | bool QTextParagraph::hasSelection( int id ) const | 465 | bool QTextParagraph::hasSelection( int id ) const |
463 | { | 466 | { |
464 | return mSelections ? mSelections->contains( id ) : FALSE; | 467 | return mSelections ? mSelections->contains( id ) : FALSE; |
465 | } | 468 | } |
466 | 469 | ||
467 | bool QTextParagraph::fullSelected( int id ) const | 470 | bool QTextParagraph::fullSelected( int id ) const |
468 | { | 471 | { |
469 | if ( !mSelections ) | 472 | if ( !mSelections ) |
470 | return FALSE; | 473 | return FALSE; |
471 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); | 474 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); |
472 | if ( it == mSelections->end() ) | 475 | if ( it == mSelections->end() ) |
473 | return FALSE; | 476 | return FALSE; |
474 | return ( *it ).start == 0 && ( *it ).end == str->length() - 1; | 477 | return ( *it ).start == 0 && ( *it ).end == str->length() - 1; |
475 | } | 478 | } |
476 | 479 | ||
477 | int QTextParagraph::lineY( int l ) const | 480 | int QTextParagraph::lineY( int l ) const |
478 | { | 481 | { |
479 | if ( l > (int)lineStarts.count() - 1 ) { | 482 | if ( l > (int)lineStarts.count() - 1 ) { |
480 | qWarning( "QTextParagraph::lineY: line %d out of range!", l ); | 483 | owarn << "QTextParagraph::lineY: line " << l << " out of range!" << oendl; |
481 | return 0; | 484 | return 0; |
482 | } | 485 | } |
483 | 486 | ||
484 | if ( !isValid() ) | 487 | if ( !isValid() ) |
485 | ( (QTextParagraph*)this )->format(); | 488 | ( (QTextParagraph*)this )->format(); |
486 | 489 | ||
487 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); | 490 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
488 | while ( l-- > 0 ) | 491 | while ( l-- > 0 ) |
489 | ++it; | 492 | ++it; |
490 | return ( *it )->y; | 493 | return ( *it )->y; |
491 | } | 494 | } |
492 | 495 | ||
493 | int QTextParagraph::lineBaseLine( int l ) const | 496 | int QTextParagraph::lineBaseLine( int l ) const |
494 | { | 497 | { |
495 | if ( l > (int)lineStarts.count() - 1 ) { | 498 | if ( l > (int)lineStarts.count() - 1 ) { |
496 | qWarning( "QTextParagraph::lineBaseLine: line %d out of range!", l ); | 499 | owarn << "QTextParagraph::lineBaseLine: line " << l << " out of range!" << oendl; |
497 | return 10; | 500 | return 10; |
498 | } | 501 | } |
499 | 502 | ||
500 | if ( !isValid() ) | 503 | if ( !isValid() ) |
501 | ( (QTextParagraph*)this )->format(); | 504 | ( (QTextParagraph*)this )->format(); |
502 | 505 | ||
503 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); | 506 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
504 | while ( l-- > 0 ) | 507 | while ( l-- > 0 ) |
505 | ++it; | 508 | ++it; |
506 | return ( *it )->baseLine; | 509 | return ( *it )->baseLine; |
507 | } | 510 | } |
508 | 511 | ||
509 | int QTextParagraph::lineHeight( int l ) const | 512 | int QTextParagraph::lineHeight( int l ) const |
510 | { | 513 | { |
511 | if ( l > (int)lineStarts.count() - 1 ) { | 514 | if ( l > (int)lineStarts.count() - 1 ) { |
512 | qWarning( "QTextParagraph::lineHeight: line %d out of range!", l ); | 515 | owarn << "QTextParagraph::lineHeight: line " << l << " out of range!" << oendl; |
513 | return 15; | 516 | return 15; |
514 | } | 517 | } |
515 | 518 | ||
516 | if ( !isValid() ) | 519 | if ( !isValid() ) |
517 | ( (QTextParagraph*)this )->format(); | 520 | ( (QTextParagraph*)this )->format(); |
518 | 521 | ||
519 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); | 522 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
520 | while ( l-- > 0 ) | 523 | while ( l-- > 0 ) |
521 | ++it; | 524 | ++it; |
522 | return ( *it )->h; | 525 | return ( *it )->h; |
523 | } | 526 | } |
524 | 527 | ||
525 | void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const | 528 | void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const |
526 | { | 529 | { |
527 | if ( l > (int)lineStarts.count() - 1 ) { | 530 | if ( l > (int)lineStarts.count() - 1 ) { |
528 | qWarning( "QTextParagraph::lineInfo: line %d out of range!", l ); | 531 | owarn << "QTextParagraph::lineInfo: line " << l << " out of range!" << oendl; |
529 | qDebug( "%d %d", (int)lineStarts.count() - 1, l ); | 532 | odebug << "" << (int)lineStarts.count() - 1 << " " << l << "" << oendl; |
530 | y = 0; | 533 | y = 0; |
531 | h = 15; | 534 | h = 15; |
532 | bl = 10; | 535 | bl = 10; |
533 | return; | 536 | return; |
534 | } | 537 | } |
535 | 538 | ||
536 | if ( !isValid() ) | 539 | if ( !isValid() ) |
537 | ( (QTextParagraph*)this )->format(); | 540 | ( (QTextParagraph*)this )->format(); |
538 | 541 | ||
539 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); | 542 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
540 | while ( l-- > 0 ) | 543 | while ( l-- > 0 ) |
541 | ++it; | 544 | ++it; |
542 | y = ( *it )->y; | 545 | y = ( *it )->y; |
543 | h = ( *it )->h; | 546 | h = ( *it )->h; |
544 | bl = ( *it )->baseLine; | 547 | bl = ( *it )->baseLine; |
545 | } | 548 | } |
546 | 549 | ||
547 | 550 | ||
548 | void QTextParagraph::setAlignment( int a ) | 551 | void QTextParagraph::setAlignment( int a ) |
549 | { | 552 | { |
550 | if ( a == (int)align ) | 553 | if ( a == (int)align ) |
551 | return; | 554 | return; |
552 | align = a; | 555 | align = a; |
553 | invalidate( 0 ); | 556 | invalidate( 0 ); |