summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-write/qstylesheet.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-write/qstylesheet.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-write/qstylesheet.cpp750
1 files changed, 419 insertions, 331 deletions
diff --git a/noncore/apps/opie-write/qstylesheet.cpp b/noncore/apps/opie-write/qstylesheet.cpp
index 7ab9ec6..67cd828 100644
--- a/noncore/apps/opie-write/qstylesheet.cpp
+++ b/noncore/apps/opie-write/qstylesheet.cpp
@@ -54,6 +54,7 @@ public:
54 QStyleSheetItem::DisplayMode disp; 54 QStyleSheetItem::DisplayMode disp;
55 int fontitalic; 55 int fontitalic;
56 int fontunderline; 56 int fontunderline;
57 int fontstrikeout;
57 int fontweight; 58 int fontweight;
58 int fontsize; 59 int fontsize;
59 int fontsizelog; 60 int fontsizelog;
@@ -79,34 +80,39 @@ public:
79 80
80/*! 81/*!
81 \class QStyleSheetItem qstylesheet.h 82 \class QStyleSheetItem qstylesheet.h
82 \ingroup text
83 \brief The QStyleSheetItem class provides an encapsulation of a set of text styles. 83 \brief The QStyleSheetItem class provides an encapsulation of a set of text styles.
84 84
85 \ingroup text
86
85 A style sheet item consists of a name and a set of attributes that 87 A style sheet item consists of a name and a set of attributes that
86 specifiy its font, color, etc. When used in a \link QStyleSheet 88 specifiy its font, color, etc. When used in a \link QStyleSheet
87 style sheet\endlink (see styleSheet()), items define the name() of a 89 style sheet\endlink (see styleSheet()), items define the name() of
88 rich text tag and the display property changes associated with it. 90 a rich text tag and the display property changes associated with
91 it.
89 92
90 The \link QStyleSheetItem::DisplayMode display mode\endlink 93 The \link QStyleSheetItem::DisplayMode display mode\endlink
91 attribute indicates whether the item is a block, an inline element 94 attribute indicates whether the item is a block, an inline element
92 or a list element; see setDisplayMode(). The treatment of whitespace 95 or a list element; see setDisplayMode(). The treatment of
93 is controlled by the \link QStyleSheetItem::WhiteSpaceMode white 96 whitespace is controlled by the \link
94 space mode\endlink; see setWhiteSpaceMode(). An item's margins are 97 QStyleSheetItem::WhiteSpaceMode white space mode\endlink; see
95 set with setMargin(), and line spacing is set with setLineSpacing(). 98 setWhiteSpaceMode(). An item's margins are set with setMargin(),
96 In the case of list items, the list style is set with 99 In the case of list items, the list style is set with
97 setListStyle(). An item may be a hypertext link anchor; see 100 setListStyle(). An item may be a hypertext link anchor; see
98 setAnchor(). Other attributes are set with setAlignment(), 101 setAnchor(). Other attributes are set with setAlignment(),
99 setVerticalAlignment(), setFontFamily(), setFontSize(), 102 setVerticalAlignment(), setFontFamily(), setFontSize(),
100 setFontWeight(), setFontItalic(), setFontUnderline() and setColor(). 103 setFontWeight(), setFontItalic(), setFontUnderline(),
104 setFontStrikeOut and setColor().
101*/ 105*/
102 106
103/*! \enum QStyleSheetItem::AdditionalStyleValues 107/*! \enum QStyleSheetItem::AdditionalStyleValues
104 \internal 108 \internal
105*/ 109*/
106 110
107/*! \enum QStyleSheetItem::WhiteSpaceMode 111/*!
112 \enum QStyleSheetItem::WhiteSpaceMode
108 113
109 This enum defines the ways in which QStyleSheet can treat whitespace. There are three values at present: 114 This enum defines the ways in which QStyleSheet can treat
115 whitespace.
110 116
111 \value WhiteSpaceNormal any sequence of whitespace (including 117 \value WhiteSpaceNormal any sequence of whitespace (including
112 line-breaks) is equivalent to a single space. 118 line-breaks) is equivalent to a single space.
@@ -115,12 +121,13 @@ public:
115 in the input. 121 in the input.
116 122
117 \value WhiteSpaceNoWrap multiple spaces are collapsed as with 123 \value WhiteSpaceNoWrap multiple spaces are collapsed as with
118 WhiteSpaceNormal, but no automatic line-breaks occur. To break lines manually, 124 WhiteSpaceNormal, but no automatic line-breaks occur. To break
119 use the \c{<br>} tag. 125 lines manually, use the \c{<br>} tag.
120 126
121*/ 127*/
122 128
123/*! \enum QStyleSheetItem::Margin 129/*!
130 \enum QStyleSheetItem::Margin
124 131
125 \value MarginLeft left margin 132 \value MarginLeft left margin
126 \value MarginRight right margin 133 \value MarginRight right margin
@@ -129,15 +136,17 @@ public:
129 \value MarginAll all margins (left, right, top and bottom) 136 \value MarginAll all margins (left, right, top and bottom)
130 \value MarginVertical top and bottom margins 137 \value MarginVertical top and bottom margins
131 \value MarginHorizontal left and right margins 138 \value MarginHorizontal left and right margins
132 \value MarginFirstLine margin (indentation) of the first line of a paragarph (in addition to the MarginLeft of the paragraph) 139 \value MarginFirstLine margin (indentation) of the first line of
140 a paragarph (in addition to the MarginLeft of the paragraph)
133*/ 141*/
134 142
135/*! 143/*!
136 Constructs a new style named \a name for the stylesheet \a parent. 144 Constructs a new style called \a name for the stylesheet \a
145 parent.
137 146
138 All properties in QStyleSheetItem are initially in the "do not change" state, 147 All properties in QStyleSheetItem are initially in the "do not
139 except \link QStyleSheetItem::DisplayMode display mode\endlink, which defaults 148 change" state, except \link QStyleSheetItem::DisplayMode display
140 to \c DisplayInline. 149 mode\endlink, which defaults to \c DisplayInline.
141*/ 150*/
142QStyleSheetItem::QStyleSheetItem( QStyleSheet* parent, const QString& name ) 151QStyleSheetItem::QStyleSheetItem( QStyleSheet* parent, const QString& name )
143{ 152{
@@ -150,8 +159,8 @@ QStyleSheetItem::QStyleSheetItem( QStyleSheet* parent, const QString& name )
150} 159}
151 160
152/*! 161/*!
153 Copy constructor. Constructs a copy of \a other that is 162 Copy constructor. Constructs a copy of \a other that is not bound
154 not bound to any style sheet. 163 to any style sheet.
155 */ 164 */
156QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other ) 165QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other )
157{ 166{
@@ -161,8 +170,8 @@ QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other )
161 170
162 171
163/*! 172/*!
164 Destroys the style. Note that QStyleSheetItem objects become owned 173 Destroys the style. Note that QStyleSheetItem objects become
165 by QStyleSheet when they are created. 174 owned by QStyleSheet when they are created.
166 */ 175 */
167QStyleSheetItem::~QStyleSheetItem() 176QStyleSheetItem::~QStyleSheetItem()
168{ 177{
@@ -181,6 +190,7 @@ QStyleSheet* QStyleSheetItem::styleSheet()
181 190
182/*! 191/*!
183 \overload 192 \overload
193
184 Returns the style sheet this item is in. 194 Returns the style sheet this item is in.
185 */ 195 */
186const QStyleSheet* QStyleSheetItem::styleSheet() const 196const QStyleSheet* QStyleSheetItem::styleSheet() const
@@ -198,6 +208,7 @@ void QStyleSheetItem::init()
198 208
199 d->fontitalic = Undefined; 209 d->fontitalic = Undefined;
200 d->fontunderline = Undefined; 210 d->fontunderline = Undefined;
211 d->fontstrikeout = Undefined;
201 d->fontweight = Undefined; 212 d->fontweight = Undefined;
202 d->fontsize = Undefined; 213 d->fontsize = Undefined;
203 d->fontsizelog = Undefined; 214 d->fontsizelog = Undefined;
@@ -212,8 +223,8 @@ void QStyleSheetItem::init()
212 d->margin[2] = Undefined; 223 d->margin[2] = Undefined;
213 d->margin[3] = Undefined; 224 d->margin[3] = Undefined;
214 d->margin[4] = Undefined; 225 d->margin[4] = Undefined;
215 d->list = QStyleSheetItem::ListDisc; 226 d->list = (ListStyle) Undefined;
216 d->whitespacemode = QStyleSheetItem::WhiteSpaceNormal; 227 d->whitespacemode = (WhiteSpaceMode) Undefined;
217 d->selfnest = TRUE; 228 d->selfnest = TRUE;
218 d->lineSpacing = Undefined; 229 d->lineSpacing = Undefined;
219} 230}
@@ -227,8 +238,8 @@ QString QStyleSheetItem::name() const
227} 238}
228 239
229/*! 240/*!
230 Returns the \link QStyleSheetItem::DisplayMode display mode\endlink 241 Returns the \link QStyleSheetItem::DisplayMode display
231 of the style. 242 mode\endlink of the style.
232 243
233 \sa setDisplayMode() 244 \sa setDisplayMode()
234 */ 245 */
@@ -237,18 +248,19 @@ QStyleSheetItem::DisplayMode QStyleSheetItem::displayMode() const
237 return d->disp; 248 return d->disp;
238} 249}
239 250
240/*! \enum QStyleSheetItem::DisplayMode 251/*!
252 \enum QStyleSheetItem::DisplayMode
241 253
242 This enum type defines the way adjacent elements are displayed. The possible values are: 254 This enum type defines the way adjacent elements are displayed.
243 255
244 \value DisplayBlock elements are displayed as a rectangular block 256 \value DisplayBlock elements are displayed as a rectangular block
245 (e.g. \c{<p>...</p>}). 257 (e.g. \c{<p>...</p>}).
246 258
247 \value DisplayInline elements are displayed in a horizontally flowing 259 \value DisplayInline elements are displayed in a horizontally
248 sequence (e.g. \c{<em>...</em>}). 260 flowing sequence (e.g. \c{<em>...</em>}).
249 261
250 \value DisplayListItem elements are displayed in a vertical sequence 262 \value DisplayListItem elements are displayed in a vertical
251 (e.g. \c{<li>...</li>}). 263 sequence (e.g. \c{<li>...</li>}).
252 264
253 \value DisplayNone elements are not displayed at all. 265 \value DisplayNone elements are not displayed at all.
254*/ 266*/
@@ -265,8 +277,9 @@ void QStyleSheetItem::setDisplayMode(DisplayMode m)
265 277
266 278
267/*! 279/*!
268 Returns the alignment of this style. Possible values are AlignAuto, AlignLeft, 280 Returns the alignment of this style. Possible values are \c
269 AlignRight, AlignCenter and AlignJustify. 281 AlignAuto, \c AlignLeft, \c AlignRight, \c AlignCenter or \c
282 AlignJustify.
270 283
271 \sa setAlignment(), Qt::AlignmentFlags 284 \sa setAlignment(), Qt::AlignmentFlags
272 */ 285 */
@@ -276,10 +289,10 @@ int QStyleSheetItem::alignment() const
276} 289}
277 290
278/*! 291/*!
279 Sets the alignment to \a f. This only makes sense for styles with a 292 Sets the alignment to \a f. This only makes sense for styles with
280 \link QStyleSheetItem::DisplayMode display mode\endlink of 293 a \link QStyleSheetItem::DisplayMode display mode\endlink of
281 DisplayBlock. Possible values are AlignAuto, AlignLeft, AlignRight, 294 DisplayBlock. Possible values are \c AlignAuto, \c AlignLeft,
282 AlignCenter and AlignJustify. 295 \c AlignRight, \c AlignCenter or \c AlignJustify.
283 296
284 \sa alignment(), displayMode(), Qt::AlignmentFlags 297 \sa alignment(), displayMode(), Qt::AlignmentFlags
285 */ 298 */
@@ -291,23 +304,24 @@ void QStyleSheetItem::setAlignment( int f )
291 304
292/*! 305/*!
293 Returns the vertical alignment of the style. Possible values are 306 Returns the vertical alignment of the style. Possible values are
294 VAlignBaseline, VAlignSub and VAlignSuper. 307 \c VAlignBaseline, \c VAlignSub or \c VAlignSuper.
295 308
296 psa setVerticalAlignment() 309 \sa setVerticalAlignment()
297 */ 310 */
298QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const 311QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const
299{ 312{
300 return d->valign; 313 return d->valign;
301} 314}
302 315
303/*! \enum QStyleSheetItem::VerticalAlignment 316/*!
317 \enum QStyleSheetItem::VerticalAlignment
304 318
305 This enum type defines the way elements are aligned vertically. This 319 This enum type defines the way elements are aligned vertically.
306 is supported for text elements only. The possible values are: 320 This is only supported for text elements.
307 321
308 \value VAlignBaseline align the baseline of the element (or the 322 \value VAlignBaseline align the baseline of the element (or the
309 bottom, if the element doesn't have a baseline) with the baseline of 323 bottom, if the element doesn't have a baseline) with the
310 the parent 324 baseline of the parent
311 325
312 \value VAlignSub subscript the element 326 \value VAlignSub subscript the element
313 327
@@ -318,7 +332,7 @@ QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const
318 332
319/*! 333/*!
320 Sets the vertical alignment to \a valign. Possible values are 334 Sets the vertical alignment to \a valign. Possible values are
321 VAlignBaseline, VAlignSub and VAlignSuper. 335 \c VAlignBaseline, \c VAlignSub or \c VAlignSuper.
322 336
323 The vertical alignment property is not inherited. 337 The vertical alignment property is not inherited.
324 338
@@ -331,7 +345,8 @@ void QStyleSheetItem::setVerticalAlignment( VerticalAlignment valign )
331 345
332 346
333/*! 347/*!
334 Returns TRUE if the style sets an italic font; otherwise returns FALSE. 348 Returns TRUE if the style sets an italic font; otherwise returns
349 FALSE.
335 350
336 \sa setFontItalic(), definesFontItalic() 351 \sa setFontItalic(), definesFontItalic()
337 */ 352 */
@@ -352,8 +367,9 @@ void QStyleSheetItem::setFontItalic(bool italic)
352} 367}
353 368
354/*! 369/*!
355 Returns whether the style defines a font shape. A style 370 Returns TRUE if the style defines a font shape; otherwise returns
356 does not define any shape until setFontItalic() is called. 371 FALSE. A style does not define any shape until setFontItalic() is
372 called.
357 373
358 \sa setFontItalic(), fontItalic() 374 \sa setFontItalic(), fontItalic()
359 */ 375 */
@@ -363,7 +379,8 @@ bool QStyleSheetItem::definesFontItalic() const
363} 379}
364 380
365/*! 381/*!
366 Returns TRUE if the style sets an underlined font; otherwise returns FALSE. 382 Returns TRUE if the style sets an underlined font; otherwise
383 returns FALSE.
367 384
368 \sa setFontUnderline(), definesFontUnderline() 385 \sa setFontUnderline(), definesFontUnderline()
369 */ 386 */
@@ -373,8 +390,8 @@ bool QStyleSheetItem::fontUnderline() const
373} 390}
374 391
375/*! 392/*!
376 If \a underline is TRUE sets underline for the style; otherwise sets 393 If \a underline is TRUE, sets underline for the style; otherwise
377 no underline. 394 sets no underline.
378 395
379 \sa fontUnderline(), definesFontUnderline() 396 \sa fontUnderline(), definesFontUnderline()
380 */ 397 */
@@ -384,11 +401,12 @@ void QStyleSheetItem::setFontUnderline(bool underline)
384} 401}
385 402
386/*! 403/*!
387 Returns whether the style defines a setting for the underline 404 Returns TRUE if the style defines a setting for the underline
388 property of the font. A style does not define this until 405 property of the font; otherwise returns FALSE. A style does not
389 setFontUnderline() is called. 406 define this until setFontUnderline() is called.
390 407
391 \sa setFontUnderline(), fontUnderline() */ 408 \sa setFontUnderline(), fontUnderline()
409*/
392bool QStyleSheetItem::definesFontUnderline() const 410bool QStyleSheetItem::definesFontUnderline() const
393{ 411{
394 return d->fontunderline != Undefined; 412 return d->fontunderline != Undefined;
@@ -396,8 +414,43 @@ bool QStyleSheetItem::definesFontUnderline() const
396 414
397 415
398/*! 416/*!
417 Returns TRUE if the style sets a strike out font; otherwise
418 returns FALSE.
419
420 \sa setFontStrikeOut(), definesFontStrikeOut()
421*/
422bool QStyleSheetItem::fontStrikeOut() const
423{
424 return d->fontstrikeout > 0;
425}
426
427/*!
428 If \a strikeOut is TRUE, sets strike out for the style; otherwise
429 sets no strike out.
430
431 \sa fontStrikeOut(), definesFontStrikeOut()
432*/
433void QStyleSheetItem::setFontStrikeOut(bool strikeOut)
434{
435 d->fontstrikeout = strikeOut?1:0;
436}
437
438/*!
439 Returns TRUE if the style defines a setting for the strikeOut
440 property of the font; otherwise returns FALSE. A style does not
441 define this until setFontStrikeOut() is called.
442
443 \sa setFontStrikeOut(), fontStrikeOut()
444*/
445bool QStyleSheetItem::definesFontStrikeOut() const
446{
447 return d->fontstrikeout != Undefined;
448}
449
450
451/*!
399 Returns the font weight setting of the style. This is either a 452 Returns the font weight setting of the style. This is either a
400 valid QFont::Weight or the value QStyleSheetItem::Undefined. 453 valid \c QFont::Weight or the value \c QStyleSheetItem::Undefined.
401 454
402 \sa setFontWeight(), QFont 455 \sa setFontWeight(), QFont
403 */ 456 */
@@ -407,8 +460,8 @@ int QStyleSheetItem::fontWeight() const
407} 460}
408 461
409/*! 462/*!
410 Sets the font weight setting of the style to \a w. Valid values are 463 Sets the font weight setting of the style to \a w. Valid values
411 those defined by QFont::Weight. 464 are those defined by \c QFont::Weight.
412 465
413 \sa QFont, fontWeight() 466 \sa QFont, fontWeight()
414 */ 467 */
@@ -418,8 +471,8 @@ void QStyleSheetItem::setFontWeight(int w)
418} 471}
419 472
420/*! 473/*!
421 Returns the logical font size setting of the style. This is either a valid 474 Returns the logical font size setting of the style. This is either
422 size between 1 and 7 or QStyleSheetItem::Undefined. 475 a valid size between 1 and 7 or \c QStyleSheetItem::Undefined.
423 476
424 \sa setLogicalFontSize(), setLogicalFontSizeStep(), QFont::pointSize(), QFont::setPointSize() 477 \sa setLogicalFontSize(), setLogicalFontSizeStep(), QFont::pointSize(), QFont::setPointSize()
425 */ 478 */
@@ -430,8 +483,8 @@ int QStyleSheetItem::logicalFontSize() const
430 483
431 484
432/*! 485/*!
433 Sets the logical font size setting of the style to \a s. 486 Sets the logical font size setting of the style to \a s. Valid
434 Valid logical sizes are 1 to 7. 487 logical sizes are 1 to 7.
435 488
436 \sa logicalFontSize(), QFont::pointSize(), QFont::setPointSize() 489 \sa logicalFontSize(), QFont::pointSize(), QFont::setPointSize()
437 */ 490 */
@@ -443,8 +496,8 @@ void QStyleSheetItem::setLogicalFontSize(int s)
443/*! 496/*!
444 Returns the logical font size step of this style. 497 Returns the logical font size step of this style.
445 498
446 The default is 0. Tags such as \c big define \c +1; \c small defines 499 The default is 0. Tags such as \c big define \c +1; \c small
447 \c -1. 500 defines \c -1.
448 501
449 \sa setLogicalFontSizeStep() 502 \sa setLogicalFontSizeStep()
450 */ 503 */
@@ -477,7 +530,7 @@ void QStyleSheetItem::setFontSize(int s)
477 530
478/*! 531/*!
479 Returns the font size setting of the style. This is either a valid 532 Returns the font size setting of the style. This is either a valid
480 point size or QStyleSheetItem::Undefined. 533 point size or \c QStyleSheetItem::Undefined.
481 534
482 \sa setFontSize(), QFont::pointSize(), QFont::setPointSize() 535 \sa setFontSize(), QFont::pointSize(), QFont::setPointSize()
483 */ 536 */
@@ -488,8 +541,8 @@ int QStyleSheetItem::fontSize() const
488 541
489 542
490/*! 543/*!
491 Returns the font family setting of the style. This is either a valid 544 Returns the font family setting of the style. This is either a
492 font family or QString::null if no family has been set. 545 valid font family or QString::null if no family has been set.
493 546
494 \sa setFontFamily(), QFont::family(), QFont::setFamily() 547 \sa setFontFamily(), QFont::family(), QFont::setFamily()
495 */ 548 */
@@ -538,8 +591,8 @@ void QStyleSheetItem::setNumberOfColumns(int ncols)
538 591
539 592
540/*! 593/*!
541 Returns the text color of this style or an invalid color 594 Returns the text color of this style or an invalid color if no
542 if no color has been set. 595 color has been set.
543 596
544 \sa setColor() QColor::isValid() 597 \sa setColor() QColor::isValid()
545 */ 598 */
@@ -569,9 +622,9 @@ bool QStyleSheetItem::isAnchor() const
569} 622}
570 623
571/*! 624/*!
572 If \a anc is TRUE sets this style to be an anchor (hypertext link); 625 If \a anc is TRUE, sets this style to be an anchor (hypertext
573 otherwise sets it to not be an anchor. Elements in this style have 626 link); otherwise sets it to not be an anchor. Elements in this
574 connections to other documents or anchors. 627 style link to other documents or anchors.
575 628
576 \sa isAnchor() 629 \sa isAnchor()
577 */ 630 */
@@ -593,6 +646,7 @@ QStyleSheetItem::WhiteSpaceMode QStyleSheetItem::whiteSpaceMode() const
593 646
594/*! 647/*!
595 Sets the whitespace mode to \a m. 648 Sets the whitespace mode to \a m.
649
596 \sa WhiteSpaceMode 650 \sa WhiteSpaceMode
597 */ 651 */
598void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m) 652void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m)
@@ -604,8 +658,8 @@ void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m)
604/*! 658/*!
605 Returns the width of margin \a m in pixels. 659 Returns the width of margin \a m in pixels.
606 660
607 The margin, \a m, can be \c MarginLeft, \c MarginRight, 661 The margin, \a m, can be \c MarginLeft, \c MarginRight, \c
608 \c MarginTop, \c MarginBottom, \c MarginAll, \c MarginVertical or \c 662 MarginTop, \c MarginBottom, \c MarginAll, \c MarginVertical or \c
609 MarginHorizontal. 663 MarginHorizontal.
610 664
611 \sa setMargin() Margin 665 \sa setMargin() Margin
@@ -619,8 +673,8 @@ int QStyleSheetItem::margin(Margin m) const
619/*! 673/*!
620 Sets the width of margin \a m to \a v pixels. 674 Sets the width of margin \a m to \a v pixels.
621 675
622 The margin, \a m, can be \c MarginLeft, \c MarginRight, 676 The margin, \a m, can be \c MarginLeft, \c MarginRight, \c
623 \c MarginTop, \c MarginBottom, \c MarginAll, \c MarginVertical or \c 677 MarginTop, \c MarginBottom, \c MarginAll, \c MarginVertical or \c
624 MarginHorizontal. The value \a v must be >= 0. 678 MarginHorizontal. The value \a v must be >= 0.
625 679
626 \sa margin() 680 \sa margin()
@@ -655,10 +709,11 @@ QStyleSheetItem::ListStyle QStyleSheetItem::listStyle() const
655 return d->list; 709 return d->list;
656} 710}
657 711
658/*! \enum QStyleSheetItem::ListStyle 712/*!
713 \enum QStyleSheetItem::ListStyle
659 714
660 This enum type defines how the items in a list are prefixed when 715 This enum type defines how the items in a list are prefixed when
661 displayed. The currently defined values are: 716 displayed.
662 717
663 \value ListDisc a filled circle (i.e. a bullet) 718 \value ListDisc a filled circle (i.e. a bullet)
664 \value ListCircle an unfilled circle 719 \value ListCircle an unfilled circle
@@ -667,11 +722,12 @@ QStyleSheetItem::ListStyle QStyleSheetItem::listStyle() const
667 \value ListLowerAlpha a lowercase letter: \e a, \e b, \e c, ... 722 \value ListLowerAlpha a lowercase letter: \e a, \e b, \e c, ...
668 \value ListUpperAlpha an uppercase letter: \e A, \e B, \e C, ... 723 \value ListUpperAlpha an uppercase letter: \e A, \e B, \e C, ...
669*/ 724*/
725
670/*! 726/*!
671 Sets the list style of the style to \a s. 727 Sets the list style of the style to \a s.
672 728
673 This is used by nested elements that have a display mode of 729 This is used by nested elements that have a display mode of \c
674 \c DisplayListItem. 730 DisplayListItem.
675 731
676 \sa listStyle() DisplayMode ListStyle 732 \sa listStyle() DisplayMode ListStyle
677 */ 733 */
@@ -681,8 +737,9 @@ void QStyleSheetItem::setListStyle(ListStyle s)
681} 737}
682 738
683 739
684/*! Returns a space-separated list of names of styles that may 740/*!
685 contain elements of this style. If nothing has been set, contexts() 741 Returns a space-separated list of names of styles that may contain
742 elements of this style. If nothing has been set, contexts()
686 returns an empty string, which indicates that this style can be 743 returns an empty string, which indicates that this style can be
687 nested everywhere. 744 nested everywhere.
688 745
@@ -706,8 +763,8 @@ void QStyleSheetItem::setContexts( const QString& c)
706} 763}
707 764
708/*! 765/*!
709 Returns TRUE if this style can be nested into an element 766 Returns TRUE if this style can be nested into an element of style
710 of style \a s; otherwise returns FALSE. 767 \a s; otherwise returns FALSE.
711 768
712 \sa contexts(), setContexts() 769 \sa contexts(), setContexts()
713 */ 770 */
@@ -733,9 +790,9 @@ bool QStyleSheetItem::selfNesting() const
733/*! 790/*!
734 Sets the self-nesting property for this style to \a nesting. 791 Sets the self-nesting property for this style to \a nesting.
735 792
736 In order to support "dirty" HTML, paragraphs \c{<p>} and list items 793 In order to support "dirty" HTML, paragraphs \c{<p>} and list
737 \c{<li>} are not self-nesting. This means that starting a new 794 items \c{<li>} are not self-nesting. This means that starting a
738 paragraph or list item automatically closes the previous one. 795 new paragraph or list item automatically closes the previous one.
739 796
740 \sa selfNesting() 797 \sa selfNesting()
741 */ 798 */
@@ -744,14 +801,26 @@ void QStyleSheetItem::setSelfNesting( bool nesting )
744 d->selfnest = nesting; 801 d->selfnest = nesting;
745} 802}
746 803
747/*! Sets the linespacing to be \a ls pixels */ 804/*
805 Sets the linespacing to be at least \a ls pixels.
806
807 For compatibility with previous Qt releases, small values get
808 treated differently: If \a ls is smaller than the default font
809 line spacing in pixels at parse time, the resulting line spacing
810 is the sum of the default line spacing plus \a ls. We recommend
811 not relying on this behavior.
812*/
748 813
749void QStyleSheetItem::setLineSpacing( int ls ) 814void QStyleSheetItem::setLineSpacing( int ls )
750{ 815{
751 d->lineSpacing = ls; 816 d->lineSpacing = ls;
752} 817}
753 818
754/*! Returns the linespacing */ 819/*!
820 \obsolete
821
822 Returns the linespacing
823*/
755 824
756int QStyleSheetItem::lineSpacing() const 825int QStyleSheetItem::lineSpacing() const
757{ 826{
@@ -787,202 +856,200 @@ int QStyleSheetItem::lineSpacing() const
787 The default QStyleSheet object has the following style bindings, 856 The default QStyleSheet object has the following style bindings,
788 sorted by structuring bindings, anchors, character style bindings 857 sorted by structuring bindings, anchors, character style bindings
789 (i.e. inline styles), special elements such as horizontal lines or 858 (i.e. inline styles), special elements such as horizontal lines or
790 images, and other tags. In addition, rich text supports simple HTML 859 images, and other tags. In addition, rich text supports simple
791 tables. 860 HTML tables.
792 861
793 The structuring tags are 862 The structuring tags are
863 \table
864 \header \i Structuring tags \i Notes
865 \row \i \c{<qt>}...\c{</qt>}
866 \i A Qt rich text document. It understands the following
867 attributes:
794 \list 868 \list
795 \i \c{<qt>}...\c{</qt>} 869 \i \c title -- The caption of the document. This attribute is
796 - A Qt rich text document. It understands the following attributes: 870 easily accessible with QTextView::documentTitle().
797 \list 871 \i \c type -- The type of the document. The default type is \c
798 \i title 872 page. It indicates that the document is displayed in a
799 - The caption of the document. This attribute is easily accessible with 873 page of its own. Another style is \c detail, which can be
800 QTextView::documentTitle(). 874 used to explain certain expressions in more detail in a
801 \i type 875 few sentences. For \c detail, QTextBrowser will then keep
802 - The type of the document. The default type is \c page . It 876 the current page and display the new document in a small
803 indicates that the document is displayed in a page of its 877 popup similar to QWhatsThis. Note that links will not work
804 own. Another style is \c detail, which can be used to 878 in documents with \c{<qt type="detail">...</qt>}.
805 explain certain expressions in more detail in a few 879 \i \c bgcolor -- The background color, for example \c
806 sentences. The QTextBrowser will then keep the current page 880 bgcolor="yellow" or \c bgcolor="#0000FF".
807 and display the new document in a small popup similar to 881 \i \c background -- The background pixmap, for example \c
808 QWhatsThis. Note that links will not work in documents with 882 background="granite.xpm". The pixmap name will be resolved
809 \c{<qt type="detail">...</qt>}. 883 by a QMimeSourceFactory().
810 \i bgcolor 884 \i \c text -- The default text color, for example \c text="red".
811 - The background color, for example \c bgcolor="yellow" or \c 885 \i \c link -- The link color, for example \c link="green".
812 bgcolor="#0000FF".
813 \i background
814 - The background pixmap, for example \c
815 background="granit.xpm". The pixmap name will be resolved by
816 a QMimeSourceFactory().
817 \i text
818 - The default text color, for example \c text="red".
819 \i link
820 - The link color, for example \c link="green".
821 \endlist
822 \i \c{<h1>...</h1>}
823 - A top-level heading.
824 \i \c{<h2>...</h2>}
825 - A sublevel heading.
826 \i \c{<h3>...</h3>}
827 - A sub-sublevel heading.
828 \i \c{<p>...</p>}
829 - A left-aligned paragraph. Adjust the alignment with
830 the \c align attribute. Possible values are
831 \c left, \c right and \c center.
832 \i \c{<center>...</center>}
833 - A centered paragraph.
834 \i \c{<blockquote>...</blockquote>}
835 - An indented paragraph that is useful for quotes.
836 \i \c{<ul>...</ul>}
837 - An unordered list. You can also pass a type argument to
838 define the bullet style. The default is \c type=disc; other
839 types are \c circle and \c square.
840 \i \c{<ol>...</ol>}
841 - An ordered list. You can also pass a type argument to define
842 the enumeration label style. The default is \c type="1"; other
843 types are \c "a" and \c "A".
844 \i <tt>&lt;li&gt;</tt>...<tt>&lt;/li&gt;</tt>
845 - A list item. This tag can be used only within the context of
846 \c ol or \c ul.
847 \i \c{<pre>...</pre>}
848 - For larger chunks of code. Whitespaces in the contents are preserved.
849 For small bits of code use the inline-style \c code.
850 \endlist 886 \endlist
887 \row \i \c{<h1>...</h1>}
888 \i A top-level heading.
889 \row \i \c{<h2>...</h2>}
890 \i A sublevel heading.
891 \row \i \c{<h3>...</h3>}
892 \i A sub-sublevel heading.
893 \row \i \c{<p>...</p>}
894 \i A left-aligned paragraph. Adjust the alignment with the \c
895 align attribute. Possible values are \c left, \c right and
896 \c center.
897 \row \i \c{<center>...}<br>\c{</center>}
898 \i A centered paragraph.
899 \row \i \c{<blockquote>...}<br>\c{</blockquote>}
900 \i An indented paragraph that is useful for quotes.
901 \row \i \c{<ul>...</ul>}
902 \i An unordered list. You can also pass a type argument to
903 define the bullet style. The default is \c type=disc;
904 other types are \c circle and \c square.
905 \row \i \c{<ol>...</ol>}
906 \i An ordered list. You can also pass a type argument to
907 define the enumeration label style. The default is \c
908 type="1"; other types are \c "a" and \c "A".
909 \row \i \c{<li>...</li>}
910 \i A list item. This tag can be used only within the context
911 of \c{<ol>} or \c{<ul>}.
912 \row \i \c{<pre>...</pre>}
913 \i For larger chunks of code. Whitespaces in the contents are
914 preserved. For small bits of code use the inline-style \c
915 code.
916 \endtable
851 917
852 Anchors and links are done with a single tag: 918 Anchors and links are done with a single tag:
919 \table
920 \header \i Anchor tags \i Notes
921 \row \i \c{<a>...</a>}
922 \i An anchor or link.
853 \list 923 \list
854 \i \c{<a>...</a>} 924 \i A link is created by using an \c href
855 - An anchor or link. The reference target is defined in the \c 925 attribute, for example
856 href attribute of the tag as in \c{<a 926 <br>\c{<a href="target.qml">Link Text</a>}. Links to
857 href="target.qml">...</a>}. You can also specify an 927 targets within a document are achieved in the same way
858 additional anchor within the specified target document, for 928 as for HTML, e.g.
859 example \c{<a href="target.qml#123">...</a>}. If \c a is 929 <br>\c{<a href="target.qml#subtitle">Link Text</a>}.
860 meant to be an anchor, the reference source is given in the 930 \i A target is created by using a \c name
861 \c name attribute. 931 attribute, for example
932 <br>\c{<a name="subtitle"><h2>Sub Title</h2></a>}.
862 \endlist 933 \endlist
934 \endtable
863 935
864 The default character style bindings are 936 The default character style bindings are
937 \table
938 \header \i Style tags \i Notes
939 \row \i \c{<em>...</em>}
940 \i Emphasized. By default this is the same as \c{<i>...</i>}
941 (italic).
942 \row \i \c{<strong>...</strong>}
943 \i Strong. By default this is the same as \c{<b>...</b>}
944 (bold).
945 \row \i \c{<i>...</i>}
946 \i Italic font style.
947 \row \i \c{<b>...</b>}
948 \i Bold font style.
949 \row \i \c{<u>...</u>}
950 \i Underlined font style.
951 \row \i \c{<s>...</s>}
952 \i Strike out font style.
953 \row \i \c{<big>...</big>}
954 \i A larger font size.
955 \row \i \c{<small>...</small>}
956 \i A smaller font size.
957 \row \i \c{<code>...</code>}
958 \i Indicates code. By default this is the same as
959 \c{<tt>...</tt>} (typewriter). For larger junks of code
960 use the block-tag \c{<}\c{pre>}.
961 \row \i \c{<tt>...</tt>}
962 \i Typewriter font style.
963 \row \i \c{<font>...</font>}
964 \i Customizes the font size, family and text color. The tag
965 understands the following attributes:
865 \list 966 \list
866 \i \c{<em>...</em>} 967 \i \c color -- The text color, for example \c color="red" or
867 - Emphasized. By default this is the same as 968 \c color="#FF0000".
868 \c{<i>...</i>} (italic). 969 \i \c size -- The logical size of the font. Logical sizes 1
869 \i \c{<strong>...</strong>} 970 to 7 are supported. The value may either be absolute
870 - Strong. By default this is the same as 971 (for example, \c size=3) or relative (\c size=-2). In
871 \c{<b>...</b>} (bold). 972 the latter case the sizes are simply added.
872 \i \c{<i>...</i>} 973 \i \c face -- The family of the font, for example \c face=times.
873 - Italic font style.
874 \i \c{<b>...</b>}
875 - Bold font style.
876 \i \c{<u>...</u>}
877 - Underlined font style.
878 \i \c{<big>...</big>}
879 - A larger font size.
880 \i \c{<small>...</small>}
881 - A smaller font size.
882 \i \c{<code>...</code>}
883 - Indicates code. By default this is the same as
884 \c{<tt>...</tt>} (typewriter). For
885 larger junks of code use the block-tag \c pre.
886 \i \c{<tt>...</tt>}
887 - Typewriter font style.
888 \i \c{<font>...</font>}
889 - Customizes the font size, family and text color. The tag understands
890 the following attributes:
891 \list
892 \i color
893 - The text color, for example \c color="red" or \c color="#FF0000".
894 \i size
895 - The logical size of the font. Logical sizes 1 to 7 are supported.
896 The value may either be absolute (for example,
897 \c size=3) or relative (\c size=-2). In the latter case the sizes
898 are simply added.
899 \i face
900 - The family of the font, for example \c face=times.
901 \endlist
902 \endlist 974 \endlist
975 \endtable
903 976
904 Special elements are: 977 Special elements are:
905 \list 978 \table
906 \i \c{<img>} 979 \header \i Special tags \i Notes
907 - An image. The image name for the mime source 980 \row \i \c{<img>}
908 factory is given in the source attribute, for example 981 \i An image. The image name for the mime source factory is
909 \c{<img src="qt.xpm">} 982 given in the source attribute, for example
910 The image tag also understands the attributes \c width and \c 983 \c{<img src="qt.xpm">} The image tag also understands the
911 height that determine the size of the image. If the pixmap 984 attributes \c width and \c height that determine the size
912 does not fit the specified size it will be scaled 985 of the image. If the pixmap does not fit the specified
913 automatically (by using QImage::smoothScale()). 986 size it will be scaled automatically (by using
914 987 QImage::smoothScale()).
988 <br>
915 The \c align attribute determines where the image is 989 The \c align attribute determines where the image is
916 placed. By default, an image is placed inline just like a 990 placed. By default, an image is placed inline just like a
917 normal character. Specify \c left or \c right to place the 991 normal character. Specify \c left or \c right to place the
918 image at the respective side. 992 image at the respective side.
919 \i \c{<hr>} 993 \row \i \c{<hr>}
920 - A horizonal line. 994 \i A horizonal line.
921 \i \c{<br>} 995 \row \i \c{<br>}
922 - A line break. 996 \i A line break.
923 \endlist 997 \row \i \c{<nobr>...</nobr>}
924 998 \i No break. Prevents word wrap.
925 Another tag not in any of the above cathegories is 999 \endtable
1000
1001 In addition, rich text supports simple HTML tables. A table
1002 consists of one or more rows each of which contains one or more
1003 cells. Cells are either data cells or header cells, depending on
1004 their content. Cells which span rows and columns are supported.
1005
1006 \table
1007 \header \i Table tags \i Notes
1008 \row \i \c{<table>...</table>}
1009 \i A table. Tables support the following attributes:
926 \list 1010 \list
927 \i \c{<nobr>...</nobr>} 1011 \i \c bgcolor -- The background color.
928 - No break. Prevents word wrap. 1012 \i \c width -- The table width. This is either an absolute
1013 pixel width or a relative percentage of the table's
1014 width, for example \c width=80%.
1015 \i \c border -- The width of the table border. The default is
1016 0 (= no border).
1017 \i \c cellspacing -- Additional space around the table cells.
1018 The default is 2.
1019 \i \c cellpadding -- Additional space around the contents of
1020 table cells. The default is 1.
929 \endlist 1021 \endlist
930 1022 \row \i \c{<tr>...</tr>}
931 In addition, rich text supports simple HTML tables. A table consists 1023 \i A table row. This is only valid within a \c table. Rows
932 of one or more rows each of which contains one or more cells. Cells 1024 support the following attribute:
933 are either data cells or header cells, depending on their
934 content. Cells which span rows and columns are supported.
935
936 \list
937 \i \c{<table>...</table>}
938 - A table. Tables support the following attributes:
939 \list 1025 \list
940 \i bgcolor 1026 \i \c bgcolor -- The background color.
941 - The background color.
942 \i width
943 - The table width. This is either an absolute pixel width or a relative
944 percentage of the table's width, for example \c width=80%.
945 \i border
946 - The width of the table border. The default is 0 (= no border).
947 \i cellspacing
948 - Additional space around the table cells. The default is 2.
949 \i cellpadding
950 - Additional space around the contents of table cells. The default is 1.
951 \endlist 1027 \endlist
952 \i \c{<tr>...</tr>} 1028 \row \i \c{<th>...</th>}
953 - A table row. This is only valid within a \c table. Rows support 1029 \i A table header cell. Similar to \c td, but defaults to
954 the following attribute: 1030 center alignment and a bold font.
1031 \row \i \c{<td>...</td>}
1032 \i A table data cell. This is only valid within a \c tr.
1033 Cells support the following attributes:
955 \list 1034 \list
956 \i bgcolor 1035 \i \c bgcolor -- The background color.
957 - The background color. 1036 \i \c width -- The cell width. This is either an absolute
958 \endlist 1037 pixel width or a relative percentage of table's width,
959 \i \c{<th>...</th>} 1038 for example \c width=50%.
960 - A table header cell. Similar to \c td, but defaults to center alignment 1039 \i \c colspan -- Specifies how many columns this cell spans.
961 and a bold font. 1040 The default is 1.
962 \i \c{<td>...</td>} 1041 \i \c rowspan -- Specifies how many rows this cell spans. The
963 - A table data cell. This is only valid within a \c tr. Cells 1042 default is 1.
964 support the following attributes: 1043 \i \c align -- Alignment; possible values are \c left, \c
965 \list 1044 right, and \c center. The default is left.
966 \i bgcolor
967 - The background color.
968 \i width
969 - The cell width. This is either an absolute pixel width or a relative
970 percentage of table's width, for example \c width=50%.
971 \i colspan
972 - Specifies how many columns this cell spans. The default is 1.
973 \i rowspan
974 - Specifies how many rows this cell spans. The default is 1.
975 \i align
976 - Alignment; possible values are \c left, \c right, and \c center. The
977 default is left.
978 \endlist
979 \endlist 1045 \endlist
1046 \endtable
980*/ 1047*/
981 1048
982/*! 1049/*!
983 Creates a style sheet with parent \a parent and name \a name. Like 1050 Creates a style sheet called \a name, with parent \a parent. Like
984 any QObject it will be deleted when its parent is 1051 any QObject it will be deleted when its parent is destroyed (if
985 destroyed (if the child still exists). 1052 the child still exists).
986 1053
987 By default the style sheet has the tag definitions defined above. 1054 By default the style sheet has the tag definitions defined above.
988*/ 1055*/
@@ -1018,7 +1085,6 @@ void QStyleSheet::init()
1018 1085
1019 style = new QStyleSheetItem( this, QString::fromLatin1("qt") ); 1086 style = new QStyleSheetItem( this, QString::fromLatin1("qt") );
1020 style->setDisplayMode( QStyleSheetItem::DisplayBlock ); 1087 style->setDisplayMode( QStyleSheetItem::DisplayBlock );
1021 //style->setMargin( QStyleSheetItem::MarginAll, 4 );
1022 1088
1023 style = new QStyleSheetItem( this, QString::fromLatin1("a") ); 1089 style = new QStyleSheetItem( this, QString::fromLatin1("a") );
1024 style->setAnchor( TRUE ); 1090 style->setAnchor( TRUE );
@@ -1047,40 +1113,39 @@ void QStyleSheet::init()
1047 style->setFontWeight( QFont::Bold); 1113 style->setFontWeight( QFont::Bold);
1048 style->setLogicalFontSize(6); 1114 style->setLogicalFontSize(6);
1049 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1115 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1050 style-> setMargin(QStyleSheetItem::MarginTop, 12); 1116 style-> setMargin(QStyleSheetItem::MarginTop, 18);
1051 style-> setMargin(QStyleSheetItem::MarginBottom, 6); 1117 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
1052 1118
1053 style = new QStyleSheetItem( this, QString::fromLatin1("h2") ); 1119 style = new QStyleSheetItem( this, QString::fromLatin1("h2") );
1054 style->setFontWeight( QFont::Bold); 1120 style->setFontWeight( QFont::Bold);
1055 style->setLogicalFontSize(5); 1121 style->setLogicalFontSize(5);
1056 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1122 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1057 style-> setMargin(QStyleSheetItem::MarginTop, 10); 1123 style-> setMargin(QStyleSheetItem::MarginTop, 16);
1058 style-> setMargin(QStyleSheetItem::MarginBottom, 5); 1124 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
1059 1125
1060 style = new QStyleSheetItem( this, QString::fromLatin1("h3") ); 1126 style = new QStyleSheetItem( this, QString::fromLatin1("h3") );
1061 style->setFontWeight( QFont::Bold); 1127 style->setFontWeight( QFont::Bold);
1062 style->setLogicalFontSize(4); 1128 style->setLogicalFontSize(4);
1063 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1129 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1064 style-> setMargin(QStyleSheetItem::MarginTop, 8); 1130 style-> setMargin(QStyleSheetItem::MarginTop, 14);
1065 style-> setMargin(QStyleSheetItem::MarginBottom, 4); 1131 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
1066 1132
1067 style = new QStyleSheetItem( this, QString::fromLatin1("h4") ); 1133 style = new QStyleSheetItem( this, QString::fromLatin1("h4") );
1068 style->setFontWeight( QFont::Bold); 1134 style->setFontWeight( QFont::Bold);
1069 style->setLogicalFontSize(3); 1135 style->setLogicalFontSize(3);
1070 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1136 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1071 style-> setMargin(QStyleSheetItem::MarginTop, 8); 1137 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
1072 style-> setMargin(QStyleSheetItem::MarginBottom, 4);
1073 1138
1074 style = new QStyleSheetItem( this, QString::fromLatin1("h5") ); 1139 style = new QStyleSheetItem( this, QString::fromLatin1("h5") );
1075 style->setFontWeight( QFont::Bold); 1140 style->setFontWeight( QFont::Bold);
1076 style->setLogicalFontSize(2); 1141 style->setLogicalFontSize(2);
1077 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1142 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1078 style-> setMargin(QStyleSheetItem::MarginTop, 8); 1143 style-> setMargin(QStyleSheetItem::MarginTop, 12);
1079 style-> setMargin(QStyleSheetItem::MarginBottom, 4); 1144 style-> setMargin(QStyleSheetItem::MarginBottom, 4);
1080 1145
1081 style = new QStyleSheetItem( this, QString::fromLatin1("p") ); 1146 style = new QStyleSheetItem( this, QString::fromLatin1("p") );
1082 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1147 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1083 style-> setMargin(QStyleSheetItem::MarginVertical, 8); 1148 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
1084 style->setSelfNesting( FALSE ); 1149 style->setSelfNesting( FALSE );
1085 1150
1086 style = new QStyleSheetItem( this, QString::fromLatin1("center") ); 1151 style = new QStyleSheetItem( this, QString::fromLatin1("center") );
@@ -1097,18 +1162,19 @@ void QStyleSheet::init()
1097 1162
1098 style = new QStyleSheetItem( this, QString::fromLatin1("ul") ); 1163 style = new QStyleSheetItem( this, QString::fromLatin1("ul") );
1099 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1164 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1100 style-> setMargin(QStyleSheetItem::MarginVertical, 4); 1165 style->setListStyle( QStyleSheetItem::ListDisc );
1166 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
1167 style->setMargin( QStyleSheetItem::MarginLeft, 40 );
1101 1168
1102 style = new QStyleSheetItem( this, QString::fromLatin1("ol") ); 1169 style = new QStyleSheetItem( this, QString::fromLatin1("ol") );
1103 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1170 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1104 style->setListStyle( QStyleSheetItem::ListDecimal ); 1171 style->setListStyle( QStyleSheetItem::ListDecimal );
1105 style-> setMargin(QStyleSheetItem::MarginVertical, 4); 1172 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
1173 style->setMargin( QStyleSheetItem::MarginLeft, 40 );
1106 1174
1107 style = new QStyleSheetItem( this, QString::fromLatin1("li") ); 1175 style = new QStyleSheetItem( this, QString::fromLatin1("li") );
1108 style->setDisplayMode(QStyleSheetItem::DisplayListItem); 1176 style->setDisplayMode(QStyleSheetItem::DisplayListItem);
1109 style->setSelfNesting( FALSE ); 1177 style->setSelfNesting( FALSE );
1110 style->setContexts(QString::fromLatin1("ol ul"));
1111 style-> setMargin(QStyleSheetItem::MarginVertical, 4);
1112 1178
1113 style = new QStyleSheetItem( this, QString::fromLatin1("code") ); 1179 style = new QStyleSheetItem( this, QString::fromLatin1("code") );
1114 style->setFontFamily( QString::fromLatin1("courier") ); 1180 style->setFontFamily( QString::fromLatin1("courier") );
@@ -1119,6 +1185,7 @@ void QStyleSheet::init()
1119 new QStyleSheetItem(this, QString::fromLatin1("img")); 1185 new QStyleSheetItem(this, QString::fromLatin1("img"));
1120 new QStyleSheetItem(this, QString::fromLatin1("br")); 1186 new QStyleSheetItem(this, QString::fromLatin1("br"));
1121 new QStyleSheetItem(this, QString::fromLatin1("hr")); 1187 new QStyleSheetItem(this, QString::fromLatin1("hr"));
1188
1122 style = new QStyleSheetItem(this, QString::fromLatin1("sub")); 1189 style = new QStyleSheetItem(this, QString::fromLatin1("sub"));
1123 style->setVerticalAlignment( QStyleSheetItem::VAlignSub ); 1190 style->setVerticalAlignment( QStyleSheetItem::VAlignSub );
1124 style = new QStyleSheetItem(this, QString::fromLatin1("sup")); 1191 style = new QStyleSheetItem(this, QString::fromLatin1("sup"));
@@ -1135,9 +1202,13 @@ void QStyleSheet::init()
1135 1202
1136 style = new QStyleSheetItem( this, QString::fromLatin1("head") ); 1203 style = new QStyleSheetItem( this, QString::fromLatin1("head") );
1137 style->setDisplayMode(QStyleSheetItem::DisplayNone); 1204 style->setDisplayMode(QStyleSheetItem::DisplayNone);
1205 style = new QStyleSheetItem( this, QString::fromLatin1("body") );
1206 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1138 style = new QStyleSheetItem( this, QString::fromLatin1("div") ); 1207 style = new QStyleSheetItem( this, QString::fromLatin1("div") );
1139 style->setDisplayMode(QStyleSheetItem::DisplayBlock) ; 1208 style->setDisplayMode(QStyleSheetItem::DisplayBlock) ;
1209 style = new QStyleSheetItem( this, QString::fromLatin1("span") );
1140 style = new QStyleSheetItem( this, QString::fromLatin1("dl") ); 1210 style = new QStyleSheetItem( this, QString::fromLatin1("dl") );
1211 style-> setMargin(QStyleSheetItem::MarginVertical, 8);
1141 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1212 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1142 style = new QStyleSheetItem( this, QString::fromLatin1("dt") ); 1213 style = new QStyleSheetItem( this, QString::fromLatin1("dt") );
1143 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1214 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
@@ -1148,10 +1219,15 @@ void QStyleSheet::init()
1148 style->setContexts(QString::fromLatin1("dt dl") ); 1219 style->setContexts(QString::fromLatin1("dt dl") );
1149 style = new QStyleSheetItem( this, QString::fromLatin1("u") ); 1220 style = new QStyleSheetItem( this, QString::fromLatin1("u") );
1150 style->setFontUnderline( TRUE); 1221 style->setFontUnderline( TRUE);
1222 style = new QStyleSheetItem( this, QString::fromLatin1("s") );
1223 style->setFontStrikeOut( TRUE);
1151 style = new QStyleSheetItem( this, QString::fromLatin1("nobr") ); 1224 style = new QStyleSheetItem( this, QString::fromLatin1("nobr") );
1152 style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpaceNoWrap ); 1225 style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpaceNoWrap );
1153 style = new QStyleSheetItem( this, QString::fromLatin1("wsp") ); // qt extension for QTextEdit 1226
1154 style->setWhiteSpaceMode( (QStyleSheetItem::WhiteSpaceMode) 3 ); // WhiteSpaceModeNoCompression 1227 // compatibily with some minor 3.0.x Qt versions that had an
1228 // undocumented <wsp> tag. ### Remove 3.1
1229 style = new QStyleSheetItem( this, QString::fromLatin1("wsp") );
1230 style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpacePre );
1155 1231
1156 // tables 1232 // tables
1157 style = new QStyleSheetItem( this, QString::fromLatin1("table") ); 1233 style = new QStyleSheetItem( this, QString::fromLatin1("table") );
@@ -1173,12 +1249,12 @@ static QStyleSheet* defaultsheet = 0;
1173static QSingleCleanupHandler<QStyleSheet> qt_cleanup_stylesheet; 1249static QSingleCleanupHandler<QStyleSheet> qt_cleanup_stylesheet;
1174 1250
1175/*! 1251/*!
1176 Returns the application-wide default style sheet. This style sheet is 1252 Returns the application-wide default style sheet. This style sheet
1177 used by rich text rendering classes such as QSimpleRichText, 1253 is used by rich text rendering classes such as QSimpleRichText,
1178 QWhatsThis and QMessageBox to define the rendering style and 1254 QWhatsThis and QMessageBox to define the rendering style and
1179 available tags within rich text documents. It serves also as initial 1255 available tags within rich text documents. It also serves as the
1180 style sheet for the more complex render widgets QTextEdit and 1256 initial style sheet for the more complex render widgets, QTextEdit
1181 QTextBrowser. 1257 and QTextBrowser.
1182 1258
1183 \sa setDefaultSheet() 1259 \sa setDefaultSheet()
1184*/ 1260*/
@@ -1192,9 +1268,9 @@ QStyleSheet* QStyleSheet::defaultSheet()
1192} 1268}
1193 1269
1194/*! 1270/*!
1195 Sets the application-wide default style sheet to \a sheet, deleting 1271 Sets the application-wide default style sheet to \a sheet,
1196 any style sheet previously set. The ownership is transferred to 1272 deleting any style sheet previously set. The ownership is
1197 QStyleSheet. 1273 transferred to QStyleSheet.
1198 1274
1199 \sa defaultSheet() 1275 \sa defaultSheet()
1200*/ 1276*/
@@ -1222,7 +1298,7 @@ void QStyleSheet::insert( QStyleSheetItem* style )
1222 1298
1223 1299
1224/*! 1300/*!
1225 Returns the style with name \a name or 0 if there is no such style. 1301 Returns the style called \a name or 0 if there is no such style.
1226 */ 1302 */
1227QStyleSheetItem* QStyleSheet::item( const QString& name) 1303QStyleSheetItem* QStyleSheet::item( const QString& name)
1228{ 1304{
@@ -1233,7 +1309,9 @@ QStyleSheetItem* QStyleSheet::item( const QString& name)
1233 1309
1234/*! 1310/*!
1235 \overload 1311 \overload
1236 Returns the style with name \a name or 0 if there is no such style (const version) 1312
1313 Returns the style called \a name or 0 if there is no such style
1314 (const version)
1237 */ 1315 */
1238const QStyleSheetItem* QStyleSheet::item( const QString& name) const 1316const QStyleSheetItem* QStyleSheet::item( const QString& name) const
1239{ 1317{
@@ -1245,21 +1323,22 @@ const QStyleSheetItem* QStyleSheet::item( const QString& name) const
1245 1323
1246/*! 1324/*!
1247 \preliminary 1325 \preliminary
1326
1248 Generates an internal object for the tag called \a name, given the 1327 Generates an internal object for the tag called \a name, given the
1249 attributes \a attr, and using additional information provided 1328 attributes \a attr, and using additional information provided by
1250 by the mime source factory \a factory. 1329 the mime source factory \a factory.
1251 1330
1252 \a context is the optional context of the document, i.e. the path to 1331 \a context is the optional context of the document, i.e. the path
1253 look for relative links. This becomes important if the text contains 1332 to look for relative links. This becomes important if the text
1254 relative references, for example within image tags. QSimpleRichText 1333 contains relative references, for example within image tags.
1255 always uses the default mime source factory (see 1334 QSimpleRichText always uses the default mime source factory (see
1256 \l{QMimeSourceFactory::defaultFactory()}) to resolve these references. 1335 \l{QMimeSourceFactory::defaultFactory()}) to resolve these
1257 The context will then be used to calculate the absolute path. See 1336 references. The context will then be used to calculate the
1258 QMimeSourceFactory::makeAbsolute() for details. 1337 absolute path. See QMimeSourceFactory::makeAbsolute() for details.
1259 1338
1260 \a emptyTag and \a doc are for internal use only. 1339 \a emptyTag and \a doc are for internal use only.
1261 1340
1262 This function should not (yet) be used in application code. 1341 This function should not be used in application code.
1263*/ 1342*/
1264QTextCustomItem* QStyleSheet::tag( const QString& name, 1343QTextCustomItem* QStyleSheet::tag( const QString& name,
1265 const QMap<QString, QString> &attr, 1344 const QMap<QString, QString> &attr,
@@ -1267,24 +1346,20 @@ QTextCustomItem* QStyleSheet::tag( const QString& name,
1267 const QMimeSourceFactory& factory, 1346 const QMimeSourceFactory& factory,
1268 bool /*emptyTag */, QTextDocument *doc ) const 1347 bool /*emptyTag */, QTextDocument *doc ) const
1269{ 1348{
1270 static QString s_img = QString::fromLatin1("img");
1271 static QString s_hr = QString::fromLatin1("hr");
1272
1273 const QStyleSheetItem* style = item( name ); 1349 const QStyleSheetItem* style = item( name );
1274 // first some known tags 1350 // first some known tags
1275 if ( !style ) 1351 if ( !style )
1276 return 0; 1352 return 0;
1277 if ( style->name() == s_img ) 1353 if ( style->name() == "img" )
1278 return new QTextImage( doc, attr, context, (QMimeSourceFactory&)factory ); 1354 return new QTextImage( doc, attr, context, (QMimeSourceFactory&)factory );
1279 if ( style->name() == s_hr ) 1355 if ( style->name() == "hr" )
1280 return new QTextHorizontalLine( doc, attr, context, (QMimeSourceFactory&)factory ); 1356 return new QTextHorizontalLine( doc, attr, context, (QMimeSourceFactory&)factory );
1281 return 0; 1357 return 0;
1282} 1358}
1283 1359
1284 1360
1285/*! 1361/*! Auxiliary function. Converts the plain text string \a plain to a
1286 Auxiliary function. Converts the plain text string \a plain to a 1362 rich text formatted paragraph while preserving most of its look.
1287 rich text formatted paragraph while preserving its look.
1288 1363
1289 \a mode defines the whitespace mode. Possible values are \c 1364 \a mode defines the whitespace mode. Possible values are \c
1290 QStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces 1365 QStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces
@@ -1300,15 +1375,25 @@ QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem
1300 rich += "<p>"; 1375 rich += "<p>";
1301 for ( int i = 0; i < int(plain.length()); ++i ) { 1376 for ( int i = 0; i < int(plain.length()); ++i ) {
1302 if ( plain[i] == '\n' ){ 1377 if ( plain[i] == '\n' ){
1303 if ( col == 1 ) 1378 int c = 1;
1304 rich += "<p></p>"; 1379 while ( i+1 < int(plain.length()) && plain[i+1] == '\n' ) {
1305 else 1380 i++;
1306 rich += "<br>"; 1381 c++;
1307 col = 0; 1382 }
1383 if ( c == 1)
1384 rich += "<br>\n";
1385 else {
1386 rich += "</p>\n";
1387 while ( --c > 1 )
1388 rich += "<br>\n";
1389 rich += "<p>";
1308 } 1390 }
1309 else if ( mode == QStyleSheetItem::WhiteSpacePre && plain[i] == '\t' ){ 1391 col = 0;
1392 } else {
1393 if ( mode == QStyleSheetItem::WhiteSpacePre && plain[i] == '\t' ){
1310 rich += 0x00a0U; 1394 rich += 0x00a0U;
1311 while ( col % 4 ) { 1395 ++col;
1396 while ( col % 8 ) {
1312 rich += 0x00a0U; 1397 rich += 0x00a0U;
1313 ++col; 1398 ++col;
1314 } 1399 }
@@ -1325,6 +1410,8 @@ QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem
1325 rich += plain[i]; 1410 rich += plain[i];
1326 ++col; 1411 ++col;
1327 } 1412 }
1413 }
1414 if ( col != 0 )
1328 rich += "</p>"; 1415 rich += "</p>";
1329 return rich; 1416 return rich;
1330} 1417}
@@ -1358,28 +1445,29 @@ QString QStyleSheet::escape( const QString& plain)
1358 1445
1359 This enum is used in widgets that can display both plain text and 1446 This enum is used in widgets that can display both plain text and
1360 rich text, e.g. QLabel. It is used for deciding whether a text 1447 rich text, e.g. QLabel. It is used for deciding whether a text
1361 string should be interpreted as one or the other. This is 1448 string should be interpreted as one or the other. This is normally
1362 normally done by passing one of the enum values to a setTextFormat() 1449 done by passing one of the enum values to a setTextFormat()
1363 function. 1450 function.
1364 1451
1365 \value PlainText The text string is interpreted as a plain text string. 1452 \value PlainText The text string is interpreted as a plain text
1453 string.
1366 1454
1367 \value RichText The text string is interpreted as a rich text string 1455 \value RichText The text string is interpreted as a rich text
1368 using the current QStyleSheet::defaultSheet(). 1456 string using the current QStyleSheet::defaultSheet().
1369 1457
1370 \value AutoText The text string is interpreted as for \c RichText if 1458 \value AutoText The text string is interpreted as for \c RichText
1371 QStyleSheet::mightBeRichText() returns TRUE, otherwise as for \c 1459 if QStyleSheet::mightBeRichText() returns TRUE, otherwise as
1372 PlainText. 1460 \c PlainText.
1373*/ 1461*/
1374 1462
1375/*! 1463/*!
1376 Returns TRUE if the string \a text is likely to be rich text; 1464 Returns TRUE if the string \a text is likely to be rich text;
1377 otherwise returns FALSE. 1465 otherwise returns FALSE.
1378 1466
1379 Note: The function uses a fast and therefore simple heuristic. It 1467 This function uses a fast and therefore simple heuristic. It
1380 mainly checks whether there is something that looks like a tag 1468 mainly checks whether there is something that looks like a tag
1381 before the first line break. Although the result may be correct for 1469 before the first line break. Although the result may be correct
1382 most common cases, there is no guarantee. 1470 for common cases, there is no guarantee.
1383*/ 1471*/
1384bool QStyleSheet::mightBeRichText( const QString& text) 1472bool QStyleSheet::mightBeRichText( const QString& text)
1385{ 1473{
@@ -1413,15 +1501,16 @@ bool QStyleSheet::mightBeRichText( const QString& text)
1413} 1501}
1414 1502
1415 1503
1416/*! \fn void QStyleSheet::error( const QString& msg) const 1504/*!
1505 \fn void QStyleSheet::error( const QString& msg) const
1417 1506
1418 This virtual function is called when an error occurs when 1507 This virtual function is called when an error occurs when
1419 processing rich text. Reimplement it if you need to catch 1508 processing rich text. Reimplement it if you need to catch error
1420 error messages. 1509 messages.
1421 1510
1422 Errors might occur if some rich text strings contain tags that are 1511 Errors might occur if some rich text strings contain tags that are
1423 not understood by the stylesheet, if some tags are nested incorrectly, or 1512 not understood by the stylesheet, if some tags are nested
1424 if tags are not closed properly. 1513 incorrectly, or if tags are not closed properly.
1425 1514
1426 \a msg is the error message. 1515 \a msg is the error message.
1427*/ 1516*/
@@ -1434,13 +1523,12 @@ void QStyleSheet::error( const QString& ) const
1434 Scales the font \a font to the appropriate physical point size 1523 Scales the font \a font to the appropriate physical point size
1435 corresponding to the logical font size \a logicalSize. 1524 corresponding to the logical font size \a logicalSize.
1436 1525
1437 When calling this function, \a font has a point size corresponding to 1526 When calling this function, \a font has a point size corresponding
1438 the logical font size 3. 1527 to the logical font size 3.
1439 1528
1440 Logical font sizes range from 1 to 7, with 1 being the smallest. 1529 Logical font sizes range from 1 to 7, with 1 being the smallest.
1441 1530
1442 \sa QStyleSheetItem::logicalFontSize(), 1531 \sa QStyleSheetItem::logicalFontSize(), QStyleSheetItem::logicalFontSizeStep(), QFont::setPointSize()
1443 QStyleSheetItem::logicalFontSizeStep(), QFont::setPointSize()
1444 */ 1532 */
1445void QStyleSheet::scaleFont( QFont& font, int logicalSize ) const 1533void QStyleSheet::scaleFont( QFont& font, int logicalSize ) const
1446{ 1534{