author | leseb <leseb> | 2002-07-15 23:22:50 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-07-15 23:22:50 (UTC) |
commit | 72eb74051ed8f1b7696041e241ab99df3af5b08d (patch) (unidiff) | |
tree | bf9beee9469bc4384cb8178fbd6565cf161b4708 /noncore/apps/opie-write/qrichtext_p.cpp | |
parent | dcea0e50a00ed9efb988ded5abf5d39de1bea393 (diff) | |
download | opie-72eb74051ed8f1b7696041e241ab99df3af5b08d.zip opie-72eb74051ed8f1b7696041e241ab99df3af5b08d.tar.gz opie-72eb74051ed8f1b7696041e241ab99df3af5b08d.tar.bz2 |
Sync with Qt 3.0.5
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 | 301 |
1 files changed, 99 insertions, 202 deletions
diff --git a/noncore/apps/opie-write/qrichtext_p.cpp b/noncore/apps/opie-write/qrichtext_p.cpp index fb20730..6783e0b 100644 --- a/noncore/apps/opie-write/qrichtext_p.cpp +++ b/noncore/apps/opie-write/qrichtext_p.cpp | |||
@@ -58,26 +58,25 @@ QString QTextCustomItem::richText() const { return QString::null; } | |||
58 | 58 | ||
59 | bool QTextCustomItem::enter( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy, bool atEnd ) | 59 | bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool ) |
60 | { | 60 | { |
61 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; Q_UNUSED( atEnd ) return TRUE; | 61 | return TRUE; |
62 | |||
63 | } | 62 | } |
64 | bool QTextCustomItem::enterAt( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy, const QPoint & ) | 63 | bool QTextCustomItem::enterAt( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int &, const QPoint & ) |
65 | { | 64 | { |
66 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 65 | return TRUE; |
67 | } | 66 | } |
68 | bool QTextCustomItem::next( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ) | 67 | bool QTextCustomItem::next( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) |
69 | { | 68 | { |
70 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 69 | return TRUE; |
71 | } | 70 | } |
72 | bool QTextCustomItem::prev( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ) | 71 | bool QTextCustomItem::prev( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) |
73 | { | 72 | { |
74 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 73 | return TRUE; |
75 | } | 74 | } |
76 | bool QTextCustomItem::down( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ) | 75 | bool QTextCustomItem::down( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) |
77 | { | 76 | { |
78 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 77 | return TRUE; |
79 | } | 78 | } |
80 | bool QTextCustomItem::up( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ) | 79 | bool QTextCustomItem::up( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) |
81 | { | 80 | { |
82 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 81 | return TRUE; |
83 | } | 82 | } |
@@ -91,4 +90,4 @@ void QTextTable::invalidate() { cachewidth = -1; } | |||
91 | 90 | ||
92 | QTextParagData::~QTextParagData() {} | 91 | QTextParagraphData::~QTextParagraphData() {} |
93 | void QTextParagData::join( QTextParagData * ) {} | 92 | void QTextParagraphData::join( QTextParagraphData * ) {} |
94 | 93 | ||
@@ -102,3 +101,3 @@ int QTextCursor::x() const | |||
102 | { | 101 | { |
103 | QTextStringChar *c = string->at( idx ); | 102 | QTextStringChar *c = para->at( idx ); |
104 | int curx = c->x; | 103 | int curx = c->x; |
@@ -107,6 +106,7 @@ int QTextCursor::x() const | |||
107 | idx > 0 && | 106 | idx > 0 && |
108 | ( string->alignment() & Qt3::AlignJustify ) == Qt3::AlignJustify ) | 107 | !c->lineStart && |
109 | curx = string->at( idx - 1 )->x + string->string()->width( idx - 1 ); | 108 | ( para->alignment() & Qt3::AlignJustify ) == Qt3::AlignJustify ) |
109 | curx = para->at( idx - 1 )->x + para->string()->width( idx - 1 ); | ||
110 | if ( c->rightToLeft ) | 110 | if ( c->rightToLeft ) |
111 | curx += string->string()->width( idx ); | 111 | curx += para->string()->width( idx ); |
112 | return curx; | 112 | return curx; |
@@ -117,4 +117,31 @@ int QTextCursor::y() const | |||
117 | int dummy, line; | 117 | int dummy, line; |
118 | string->lineStartOfChar( idx, &dummy, &line ); | 118 | para->lineStartOfChar( idx, &dummy, &line ); |
119 | return string->lineY( line ); | 119 | return para->lineY( line ); |
120 | } | ||
121 | |||
122 | int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); } | ||
123 | int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); } | ||
124 | |||
125 | QTextDocument *QTextCursor::document() const | ||
126 | { | ||
127 | return para ? para->document() : 0; | ||
128 | } | ||
129 | |||
130 | void QTextCursor::gotoPosition( QTextParagraph* p, int index ) | ||
131 | { | ||
132 | if ( para && p != para ) { | ||
133 | while ( para->document() != p->document() && !indices.isEmpty() ) | ||
134 | pop(); | ||
135 | Q_ASSERT( indices.isEmpty() || para->document() == p->document() ); | ||
136 | } | ||
137 | para = p; | ||
138 | if ( index < 0 || index >= para->length() ) { | ||
139 | #if defined(QT_CHECK_RANGE) | ||
140 | qWarning( "QTextCursor::gotoParagraph Index: %d out of range", index ); | ||
141 | #endif | ||
142 | index = index < 0 ? 0 : para->length() - 1; | ||
143 | } | ||
144 | |||
145 | tmpIndex = -1; | ||
146 | idx = index; | ||
120 | } | 147 | } |
@@ -129,7 +156,7 @@ bool QTextDocument::hasSelection( int id, bool visible ) const | |||
129 | 156 | ||
130 | void QTextDocument::setSelectionStart( int id, QTextCursor *cursor ) | 157 | void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor ) |
131 | { | 158 | { |
132 | QTextDocumentSelection sel; | 159 | QTextDocumentSelection sel; |
133 | sel.startCursor = *cursor; | 160 | sel.startCursor = cursor; |
134 | sel.endCursor = *cursor; | 161 | sel.endCursor = cursor; |
135 | sel.swapped = FALSE; | 162 | sel.swapped = FALSE; |
@@ -138,5 +165,5 @@ void QTextDocument::setSelectionStart( int id, QTextCursor *cursor ) | |||
138 | 165 | ||
139 | QTextParag *QTextDocument::paragAt( int i ) const | 166 | QTextParagraph *QTextDocument::paragAt( int i ) const |
140 | { | 167 | { |
141 | QTextParag* p = curParag; | 168 | QTextParagraph* p = curParag; |
142 | if ( !p || p->paragId() > i ) | 169 | if ( !p || p->paragId() > i ) |
@@ -155,4 +182,3 @@ QTextFormat::~QTextFormat() | |||
155 | QTextFormat::QTextFormat() | 182 | QTextFormat::QTextFormat() |
156 | : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ), | 183 | : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ) |
157 | different( NoFlags ) | ||
158 | { | 184 | { |
@@ -172,4 +198,3 @@ QTextFormat::QTextFormat() | |||
172 | QTextFormat::QTextFormat( const QStyleSheetItem *style ) | 198 | QTextFormat::QTextFormat( const QStyleSheetItem *style ) |
173 | : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ), | 199 | : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ) |
174 | different( NoFlags ) | ||
175 | { | 200 | { |
@@ -183,3 +208,2 @@ QTextFormat::QTextFormat( const QStyleSheetItem *style ) | |||
183 | 208 | ||
184 | this->style = style->name(); | ||
185 | missp = FALSE; | 209 | missp = FALSE; |
@@ -192,2 +216,3 @@ QTextFormat::QTextFormat( const QStyleSheetItem *style ) | |||
192 | fn.setUnderline( style->fontUnderline() ); | 216 | fn.setUnderline( style->fontUnderline() ); |
217 | fn.setStrikeOut( style->fontStrikeOut() ); | ||
193 | col = style->color(); | 218 | col = style->color(); |
@@ -204,3 +229,2 @@ QTextFormat::QTextFormat( const QStyleSheetItem *style ) | |||
204 | addRef(); | 229 | addRef(); |
205 | updateStyleFlags(); | ||
206 | } | 230 | } |
@@ -209,3 +233,3 @@ QTextFormat::QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection | |||
209 | : fn( f ), col( c ), fm( QFontMetrics( f ) ), linkColor( TRUE ), | 233 | : fn( f ), col( c ), fm( QFontMetrics( f ) ), linkColor( TRUE ), |
210 | logicalFontSize( 3 ), stdSize( f.pointSize() ), different( NoFlags ) | 234 | logicalFontSize( 3 ), stdSize( f.pointSize() ) |
211 | { | 235 | { |
@@ -228,3 +252,2 @@ QTextFormat::QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection | |||
228 | addRef(); | 252 | addRef(); |
229 | updateStyleFlags(); | ||
230 | } | 253 | } |
@@ -251,4 +274,2 @@ QTextFormat::QTextFormat( const QTextFormat &f ) | |||
251 | linkColor = f.linkColor; | 274 | linkColor = f.linkColor; |
252 | style = f.style; | ||
253 | different = f.different; | ||
254 | addRef(); | 275 | addRef(); |
@@ -276,4 +297,2 @@ QTextFormat& QTextFormat::operator=( const QTextFormat &f ) | |||
276 | linkColor = f.linkColor; | 297 | linkColor = f.linkColor; |
277 | style = f.style; | ||
278 | different = f.different; | ||
279 | addRef(); | 298 | addRef(); |
@@ -292,3 +311,2 @@ void QTextFormat::update() | |||
292 | generateKey(); | 311 | generateKey(); |
293 | updateStyleFlags(); | ||
294 | } | 312 | } |
@@ -374,48 +392,2 @@ QString QTextFormat::getKey( const QFont &fn, const QColor &col, bool misspelled | |||
374 | 392 | ||
375 | void QTextFormat::updateStyle() | ||
376 | { | ||
377 | if ( !collection || !collection->styleSheet() ) | ||
378 | return; | ||
379 | QStyleSheetItem *item = collection->styleSheet()->item( style ); | ||
380 | if ( !item ) | ||
381 | return; | ||
382 | if ( !( different & Color ) && item->color().isValid() ) | ||
383 | col = item->color(); | ||
384 | if ( !( different & Size ) && item->fontSize() != -1 ) | ||
385 | fn.setPointSize( item->fontSize() ); | ||
386 | if ( !( different & Family ) && !item->fontFamily().isEmpty() ) | ||
387 | fn.setFamily( item->fontFamily() ); | ||
388 | if ( !( different & Bold ) && item->fontWeight() != -1 ) | ||
389 | fn.setWeight( item->fontWeight() ); | ||
390 | if ( !( different & Italic ) && item->definesFontItalic() ) | ||
391 | fn.setItalic( item->fontItalic() ); | ||
392 | if ( !( different & Underline ) && item->definesFontUnderline() ) | ||
393 | fn.setUnderline( item->fontUnderline() ); | ||
394 | generateKey(); | ||
395 | update(); | ||
396 | |||
397 | } | ||
398 | |||
399 | void QTextFormat::updateStyleFlags() | ||
400 | { | ||
401 | different = NoFlags; | ||
402 | if ( !collection || !collection->styleSheet() ) | ||
403 | return; | ||
404 | QStyleSheetItem *item = collection->styleSheet()->item( style ); | ||
405 | if ( !item ) | ||
406 | return; | ||
407 | if ( item->color() != col ) | ||
408 | different |= Color; | ||
409 | if ( item->fontSize() != fn.pointSize() ) | ||
410 | different |= Size; | ||
411 | if ( item->fontFamily() != fn.family() ) | ||
412 | different |= Family; | ||
413 | if ( item->fontItalic() != fn.italic() ) | ||
414 | different |= Italic; | ||
415 | if ( item->fontUnderline() != fn.underline() ) | ||
416 | different |= Underline; | ||
417 | if ( item->fontWeight() != fn.weight() ) | ||
418 | different |= Bold; | ||
419 | } | ||
420 | |||
421 | QString QTextString::toString( const QMemArray<QTextStringChar> &data ) | 393 | QString QTextString::toString( const QMemArray<QTextStringChar> &data ) |
@@ -445,5 +417,5 @@ QString QTextString::toString() const | |||
445 | 417 | ||
446 | void QTextParag::setSelection( int id, int start, int end ) | 418 | void QTextParagraph::setSelection( int id, int start, int end ) |
447 | { | 419 | { |
448 | QMap<int, QTextParagSelection>::ConstIterator it = selections().find( id ); | 420 | QMap<int, QTextParagraphSelection>::ConstIterator it = selections().find( id ); |
449 | if ( it != mSelections->end() ) { | 421 | if ( it != mSelections->end() ) { |
@@ -453,3 +425,3 @@ void QTextParag::setSelection( int id, int start, int end ) | |||
453 | 425 | ||
454 | QTextParagSelection sel; | 426 | QTextParagraphSelection sel; |
455 | sel.start = start; | 427 | sel.start = start; |
@@ -460,3 +432,3 @@ void QTextParag::setSelection( int id, int start, int end ) | |||
460 | 432 | ||
461 | void QTextParag::removeSelection( int id ) | 433 | void QTextParagraph::removeSelection( int id ) |
462 | { | 434 | { |
@@ -469,3 +441,3 @@ void QTextParag::removeSelection( int id ) | |||
469 | 441 | ||
470 | int QTextParag::selectionStart( int id ) const | 442 | int QTextParagraph::selectionStart( int id ) const |
471 | { | 443 | { |
@@ -473,3 +445,3 @@ int QTextParag::selectionStart( int id ) const | |||
473 | return -1; | 445 | return -1; |
474 | QMap<int, QTextParagSelection>::ConstIterator it = mSelections->find( id ); | 446 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); |
475 | if ( it == mSelections->end() ) | 447 | if ( it == mSelections->end() ) |
@@ -479,3 +451,3 @@ int QTextParag::selectionStart( int id ) const | |||
479 | 451 | ||
480 | int QTextParag::selectionEnd( int id ) const | 452 | int QTextParagraph::selectionEnd( int id ) const |
481 | { | 453 | { |
@@ -483,3 +455,3 @@ int QTextParag::selectionEnd( int id ) const | |||
483 | return -1; | 455 | return -1; |
484 | QMap<int, QTextParagSelection>::ConstIterator it = mSelections->find( id ); | 456 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); |
485 | if ( it == mSelections->end() ) | 457 | if ( it == mSelections->end() ) |
@@ -489,13 +461,8 @@ int QTextParag::selectionEnd( int id ) const | |||
489 | 461 | ||
490 | bool QTextParag::hasSelection( int id ) const | 462 | bool QTextParagraph::hasSelection( int id ) const |
491 | { | 463 | { |
492 | if ( !mSelections ) | 464 | return mSelections ? mSelections->contains( id ) : FALSE; |
493 | return FALSE; | ||
494 | QMap<int, QTextParagSelection>::ConstIterator it = mSelections->find( id ); | ||
495 | if ( it == mSelections->end() ) | ||
496 | return FALSE; | ||
497 | return ( *it ).start != ( *it ).end || length() == 1; | ||
498 | } | 465 | } |
499 | 466 | ||
500 | bool QTextParag::fullSelected( int id ) const | 467 | bool QTextParagraph::fullSelected( int id ) const |
501 | { | 468 | { |
@@ -503,3 +470,3 @@ bool QTextParag::fullSelected( int id ) const | |||
503 | return FALSE; | 470 | return FALSE; |
504 | QMap<int, QTextParagSelection>::ConstIterator it = mSelections->find( id ); | 471 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); |
505 | if ( it == mSelections->end() ) | 472 | if ( it == mSelections->end() ) |
@@ -509,6 +476,6 @@ bool QTextParag::fullSelected( int id ) const | |||
509 | 476 | ||
510 | int QTextParag::lineY( int l ) const | 477 | int QTextParagraph::lineY( int l ) const |
511 | { | 478 | { |
512 | if ( l > (int)lineStarts.count() - 1 ) { | 479 | if ( l > (int)lineStarts.count() - 1 ) { |
513 | qWarning( "QTextParag::lineY: line %d out of range!", l ); | 480 | qWarning( "QTextParagraph::lineY: line %d out of range!", l ); |
514 | return 0; | 481 | return 0; |
@@ -517,5 +484,5 @@ int QTextParag::lineY( int l ) const | |||
517 | if ( !isValid() ) | 484 | if ( !isValid() ) |
518 | ( (QTextParag*)this )->format(); | 485 | ( (QTextParagraph*)this )->format(); |
519 | 486 | ||
520 | QMap<int, QTextParagLineStart*>::ConstIterator it = lineStarts.begin(); | 487 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
521 | while ( l-- > 0 ) | 488 | while ( l-- > 0 ) |
@@ -525,6 +492,6 @@ int QTextParag::lineY( int l ) const | |||
525 | 492 | ||
526 | int QTextParag::lineBaseLine( int l ) const | 493 | int QTextParagraph::lineBaseLine( int l ) const |
527 | { | 494 | { |
528 | if ( l > (int)lineStarts.count() - 1 ) { | 495 | if ( l > (int)lineStarts.count() - 1 ) { |
529 | qWarning( "QTextParag::lineBaseLine: line %d out of range!", l ); | 496 | qWarning( "QTextParagraph::lineBaseLine: line %d out of range!", l ); |
530 | return 10; | 497 | return 10; |
@@ -533,5 +500,5 @@ int QTextParag::lineBaseLine( int l ) const | |||
533 | if ( !isValid() ) | 500 | if ( !isValid() ) |
534 | ( (QTextParag*)this )->format(); | 501 | ( (QTextParagraph*)this )->format(); |
535 | 502 | ||
536 | QMap<int, QTextParagLineStart*>::ConstIterator it = lineStarts.begin(); | 503 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
537 | while ( l-- > 0 ) | 504 | while ( l-- > 0 ) |
@@ -541,6 +508,6 @@ int QTextParag::lineBaseLine( int l ) const | |||
541 | 508 | ||
542 | int QTextParag::lineHeight( int l ) const | 509 | int QTextParagraph::lineHeight( int l ) const |
543 | { | 510 | { |
544 | if ( l > (int)lineStarts.count() - 1 ) { | 511 | if ( l > (int)lineStarts.count() - 1 ) { |
545 | qWarning( "QTextParag::lineHeight: line %d out of range!", l ); | 512 | qWarning( "QTextParagraph::lineHeight: line %d out of range!", l ); |
546 | return 15; | 513 | return 15; |
@@ -549,5 +516,5 @@ int QTextParag::lineHeight( int l ) const | |||
549 | if ( !isValid() ) | 516 | if ( !isValid() ) |
550 | ( (QTextParag*)this )->format(); | 517 | ( (QTextParagraph*)this )->format(); |
551 | 518 | ||
552 | QMap<int, QTextParagLineStart*>::ConstIterator it = lineStarts.begin(); | 519 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
553 | while ( l-- > 0 ) | 520 | while ( l-- > 0 ) |
@@ -557,6 +524,6 @@ int QTextParag::lineHeight( int l ) const | |||
557 | 524 | ||
558 | void QTextParag::lineInfo( int l, int &y, int &h, int &bl ) const | 525 | void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const |
559 | { | 526 | { |
560 | if ( l > (int)lineStarts.count() - 1 ) { | 527 | if ( l > (int)lineStarts.count() - 1 ) { |
561 | qWarning( "QTextParag::lineInfo: line %d out of range!", l ); | 528 | qWarning( "QTextParagraph::lineInfo: line %d out of range!", l ); |
562 | qDebug( "%d %d", (int)lineStarts.count() - 1, l ); | 529 | qDebug( "%d %d", (int)lineStarts.count() - 1, l ); |
@@ -569,5 +536,5 @@ void QTextParag::lineInfo( int l, int &y, int &h, int &bl ) const | |||
569 | if ( !isValid() ) | 536 | if ( !isValid() ) |
570 | ( (QTextParag*)this )->format(); | 537 | ( (QTextParagraph*)this )->format(); |
571 | 538 | ||
572 | QMap<int, QTextParagLineStart*>::ConstIterator it = lineStarts.begin(); | 539 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
573 | while ( l-- > 0 ) | 540 | while ( l-- > 0 ) |
@@ -579,76 +546,12 @@ void QTextParag::lineInfo( int l, int &y, int &h, int &bl ) const | |||
579 | 546 | ||
580 | int QTextParag::alignment() const | ||
581 | { | ||
582 | if ( align != -1 ) | ||
583 | return align; | ||
584 | QStyleSheetItem *item = style(); | ||
585 | if ( !item ) | ||
586 | return Qt3::AlignAuto; | ||
587 | if ( mStyleSheetItemsVec ) { | ||
588 | for ( int i = 0; i < (int)mStyleSheetItemsVec->size(); ++i ) { | ||
589 | item = (*mStyleSheetItemsVec)[ i ]; | ||
590 | if ( item->alignment() != QStyleSheetItem::Undefined ) | ||
591 | return item->alignment(); | ||
592 | } | ||
593 | } | ||
594 | return Qt3::AlignAuto; | ||
595 | } | ||
596 | |||
597 | QPtrVector<QStyleSheetItem> QTextParag::styleSheetItems() const | ||
598 | { | ||
599 | QPtrVector<QStyleSheetItem> vec; | ||
600 | if ( mStyleSheetItemsVec ) { | ||
601 | vec.resize( mStyleSheetItemsVec->size() ); | ||
602 | for ( int i = 0; i < (int)vec.size(); ++i ) | ||
603 | vec.insert( i, (*mStyleSheetItemsVec)[ i ] ); | ||
604 | } | ||
605 | return vec; | ||
606 | } | ||
607 | 547 | ||
608 | QStyleSheetItem *QTextParag::style() const | 548 | void QTextParagraph::setAlignment( int a ) |
609 | { | 549 | { |
610 | if ( !mStyleSheetItemsVec || mStyleSheetItemsVec->size() == 0 ) | 550 | if ( a == (int)align ) |
611 | return 0; | ||
612 | return (*mStyleSheetItemsVec)[ mStyleSheetItemsVec->size() - 1 ]; | ||
613 | } | ||
614 | |||
615 | int QTextParag::numberOfSubParagraph() const | ||
616 | { | ||
617 | if ( list_val != -1 ) | ||
618 | return list_val; | ||
619 | if ( numSubParag != -1 ) | ||
620 | return numSubParag; | ||
621 | int n = 0; | ||
622 | QTextParag *p = (QTextParag*)this; | ||
623 | while ( p && ( styleSheetItemsVec().size() >= p->styleSheetItemsVec().size() && | ||
624 | styleSheetItemsVec()[ (int)p->styleSheetItemsVec().size() - 1 ] == p->style() || | ||
625 | p->styleSheetItemsVec().size() >= styleSheetItemsVec().size() && | ||
626 | p->styleSheetItemsVec()[ (int)styleSheetItemsVec().size() - 1 ] == style() ) ) { | ||
627 | if ( p->style() == style() && listStyle() != p->listStyle() | ||
628 | && p->styleSheetItemsVec().size() == styleSheetItemsVec().size() ) | ||
629 | break; | ||
630 | if ( p->style()->displayMode() == QStyleSheetItem::DisplayListItem | ||
631 | && p->style() != style() || styleSheetItemsVec().size() == p->styleSheetItemsVec().size() ) | ||
632 | ++n; | ||
633 | p = p->prev(); | ||
634 | } | ||
635 | ( (QTextParag*)this )->numSubParag = n; | ||
636 | return n; | ||
637 | } | ||
638 | |||
639 | void QTextParag::setFormat( QTextFormat *fm ) | ||
640 | { | ||
641 | bool doUpdate = FALSE; | ||
642 | if (defFormat && (defFormat != formatCollection()->defaultFormat())) | ||
643 | doUpdate = TRUE; | ||
644 | defFormat = formatCollection()->format( fm ); | ||
645 | if ( !doUpdate ) | ||
646 | return; | 551 | return; |
647 | for ( int i = 0; i < length(); ++i ) { | 552 | align = a; |
648 | if ( at( i )->format()->styleName() == defFormat->styleName() ) | 553 | invalidate( 0 ); |
649 | at( i )->format()->updateStyle(); | ||
650 | } | ||
651 | } | 554 | } |
652 | 555 | ||
653 | QTextFormatter *QTextParag::formatter() const | 556 | QTextFormatter *QTextParagraph::formatter() const |
654 | { | 557 | { |
@@ -658,6 +561,6 @@ QTextFormatter *QTextParag::formatter() const | |||
658 | return pseudoDocument()->pFormatter; | 561 | return pseudoDocument()->pFormatter; |
659 | return ( ( (QTextParag*)this )->pseudoDocument()->pFormatter = new QTextFormatterBreakWords ); | 562 | return ( ( (QTextParagraph*)this )->pseudoDocument()->pFormatter = new QTextFormatterBreakWords ); |
660 | } | 563 | } |
661 | 564 | ||
662 | void QTextParag::setTabArray( int *a ) | 565 | void QTextParagraph::setTabArray( int *a ) |
663 | { | 566 | { |
@@ -667,3 +570,3 @@ void QTextParag::setTabArray( int *a ) | |||
667 | 570 | ||
668 | void QTextParag::setTabStops( int tw ) | 571 | void QTextParagraph::setTabStops( int tw ) |
669 | { | 572 | { |
@@ -675,6 +578,6 @@ void QTextParag::setTabStops( int tw ) | |||
675 | 578 | ||
676 | QMap<int, QTextParagSelection> &QTextParag::selections() const | 579 | QMap<int, QTextParagraphSelection> &QTextParagraph::selections() const |
677 | { | 580 | { |
678 | if ( !mSelections ) | 581 | if ( !mSelections ) |
679 | ((QTextParag *)this)->mSelections = new QMap<int, QTextParagSelection>; | 582 | ((QTextParagraph *)this)->mSelections = new QMap<int, QTextParagraphSelection>; |
680 | return *mSelections; | 583 | return *mSelections; |
@@ -682,13 +585,7 @@ QMap<int, QTextParagSelection> &QTextParag::selections() const | |||
682 | 585 | ||
683 | QPtrVector<QStyleSheetItem> &QTextParag::styleSheetItemsVec() const | ||
684 | { | ||
685 | if ( !mStyleSheetItemsVec ) | ||
686 | ((QTextParag *)this)->mStyleSheetItemsVec = new QPtrVector<QStyleSheetItem>; | ||
687 | return *mStyleSheetItemsVec; | ||
688 | } | ||
689 | 586 | ||
690 | QPtrList<QTextCustomItem> &QTextParag::floatingItems() const | 587 | QPtrList<QTextCustomItem> &QTextParagraph::floatingItems() const |
691 | { | 588 | { |
692 | if ( !mFloatingItems ) | 589 | if ( !mFloatingItems ) |
693 | ((QTextParag *)this)->mFloatingItems = new QPtrList<QTextCustomItem>; | 590 | ((QTextParagraph *)this)->mFloatingItems = new QPtrList<QTextCustomItem>; |
694 | return *mFloatingItems; | 591 | return *mFloatingItems; |
@@ -704,3 +601,3 @@ QTextStringChar::~QTextStringChar() | |||
704 | 601 | ||
705 | QTextParagPseudoDocument::QTextParagPseudoDocument():pFormatter(0),commandHistory(0), minw(0),wused(0){} | 602 | QTextParagraphPseudoDocument::QTextParagraphPseudoDocument():pFormatter(0),commandHistory(0), minw(0),wused(0){} |
706 | QTextParagPseudoDocument::~QTextParagPseudoDocument(){ delete pFormatter; delete commandHistory; } | 603 | QTextParagraphPseudoDocument::~QTextParagraphPseudoDocument(){ delete pFormatter; delete commandHistory; } |