qtextformat.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextformat.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qtextformat.h"-
35#include "qtextformat_p.h"-
36-
37#include <qvariant.h>-
38#include <qdatastream.h>-
39#include <qdebug.h>-
40#include <qmap.h>-
41#include <qhashfunctions.h>-
42-
43QT_BEGIN_NAMESPACE-
44-
45/*!-
46 \class QTextLength-
47 \reentrant-
48-
49 \brief The QTextLength class encapsulates the different types of length-
50 used in a QTextDocument.-
51 \inmodule QtGui-
52-
53 \ingroup richtext-processing-
54-
55 When we specify a value for the length of an element in a text document,-
56 we often need to provide some other information so that the length is-
57 used in the way we expect. For example, when we specify a table width,-
58 the value can represent a fixed number of pixels, or it can be a percentage-
59 value. This information changes both the meaning of the value and the way-
60 it is used.-
61-
62 Generally, this class is used to specify table widths. These can be-
63 specified either as a fixed amount of pixels, as a percentage of the-
64 containing frame's width, or by a variable width that allows it to take-
65 up just the space it requires.-
66-
67 \sa QTextTable-
68*/-
69-
70/*!-
71 \fn explicit QTextLength::QTextLength()-
72-
73 Constructs a new length object which represents a variable size.-
74*/-
75-
76/*!-
77 \fn QTextLength::QTextLength(Type type, qreal value)-
78-
79 Constructs a new length object of the given \a type and \a value.-
80*/-
81-
82/*!-
83 \fn Type QTextLength::type() const-
84-
85 Returns the type of this length object.-
86-
87 \sa QTextLength::Type-
88*/-
89-
90/*!-
91 \fn qreal QTextLength::value(qreal maximumLength) const-
92-
93 Returns the effective length, constrained by the type of the length object-
94 and the specified \a maximumLength.-
95-
96 \sa type()-
97*/-
98-
99/*!-
100 \fn qreal QTextLength::rawValue() const-
101-
102 Returns the constraint value that is specific for the type of the length.-
103 If the length is QTextLength::PercentageLength then the raw value is in-
104 percent, in the range of 0 to 100. If the length is QTextLength::FixedLength-
105 then that fixed amount is returned. For variable lengths, zero is returned.-
106*/-
107-
108/*!-
109 \fn bool QTextLength::operator==(const QTextLength &other) const-
110-
111 Returns \c true if this text length is the same as the \a other text-
112 length.-
113*/-
114-
115/*!-
116 \fn bool QTextLength::operator!=(const QTextLength &other) const-
117-
118 Returns \c true if this text length is different from the \a other text-
119 length.-
120*/-
121-
122/*!-
123 \enum QTextLength::Type-
124-
125 This enum describes the different types a length object can-
126 have.-
127-
128 \value VariableLength The width of the object is variable-
129 \value FixedLength The width of the object is fixed-
130 \value PercentageLength The width of the object is in-
131 percentage of the maximum width-
132-
133 \sa type()-
134*/-
135-
136/*!-
137 Returns the text length as a QVariant-
138*/-
139QTextLength::operator QVariant() const-
140{-
141 return QVariant(QVariant::TextLength, this);
never executed: return QVariant(QVariant::TextLength, this);
0
142}-
143-
144#ifndef QT_NO_DATASTREAM-
145QDataStream &operator<<(QDataStream &stream, const QTextLength &length)-
146{-
147 return stream << qint32(length.lengthType) << double(length.fixedValueOrPercentage);
never executed: return stream << qint32(length.lengthType) << double(length.fixedValueOrPercentage);
0
148}-
149-
150QDataStream &operator>>(QDataStream &stream, QTextLength &length)-
151{-
152 qint32 type;-
153 double fixedValueOrPercentage;-
154 stream >> type >> fixedValueOrPercentage;-
155 length.fixedValueOrPercentage = fixedValueOrPercentage;-
156 length.lengthType = QTextLength::Type(type);-
157 return stream;
never executed: return stream;
0
158}-
159#endif // QT_NO_DATASTREAM-
160-
161class QTextFormatPrivate : public QSharedData-
162{-
163public:-
164 QTextFormatPrivate() : hashDirty(true), fontDirty(true), hashValue(0) {}
never executed: end of block
0
165-
166 struct Property-
167 {-
168 inline Property(qint32 k, const QVariant &v) : key(k), value(v) {}
never executed: end of block
0
169 inline Property() {}-
170-
171 qint32 key;-
172 QVariant value;-
173-
174 inline bool operator==(const Property &other) const-
175 { return key == other.key && value == other.value; }
never executed: return key == other.key && value == other.value;
key == other.keyDescription
TRUEnever evaluated
FALSEnever evaluated
value == other.valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
176 inline bool operator!=(const Property &other) const-
177 { return key != other.key || value != other.value; }
never executed: return key != other.key || value != other.value;
key != other.keyDescription
TRUEnever evaluated
FALSEnever evaluated
value != other.valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
178 };-
179-
180 inline uint hash() const-
181 {-
182 if (!hashDirty)
!hashDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
183 return hashValue;
never executed: return hashValue;
0
184 return recalcHash();
never executed: return recalcHash();
0
185 }-
186-
187 inline bool operator==(const QTextFormatPrivate &rhs) const {-
188 if (hash() != rhs.hash())
hash() != rhs.hash()Description
TRUEnever evaluated
FALSEnever evaluated
0
189 return false;
never executed: return false;
0
190-
191 return props == rhs.props;
never executed: return props == rhs.props;
0
192 }-
193-
194 inline void insertProperty(qint32 key, const QVariant &value)-
195 {-
196 hashDirty = true;-
197 if (key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty)
key >= QTextFo...stFontPropertyDescription
TRUEnever evaluated
FALSEnever evaluated
key <= QTextFo...stFontPropertyDescription
TRUEnever evaluated
FALSEnever evaluated
0
198 fontDirty = true;
never executed: fontDirty = true;
0
199 for (int i = 0; i < props.count(); ++i)
i < props.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
200 if (props.at(i).key == key) {
props.at(i).key == keyDescription
TRUEnever evaluated
FALSEnever evaluated
0
201 props[i].value = value;-
202 return;
never executed: return;
0
203 }-
204 props.append(Property(key, value));-
205 }
never executed: end of block
0
206-
207 inline void clearProperty(qint32 key)-
208 {-
209 for (int i = 0; i < props.count(); ++i)
i < props.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
210 if (props.at(i).key == key) {
props.at(i).key == keyDescription
TRUEnever evaluated
FALSEnever evaluated
0
211 hashDirty = true;-
212 if (key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty)
key >= QTextFo...stFontPropertyDescription
TRUEnever evaluated
FALSEnever evaluated
key <= QTextFo...stFontPropertyDescription
TRUEnever evaluated
FALSEnever evaluated
0
213 fontDirty = true;
never executed: fontDirty = true;
0
214 props.remove(i);-
215 return;
never executed: return;
0
216 }-
217 }
never executed: end of block
0
218-
219 inline int propertyIndex(qint32 key) const-
220 {-
221 for (int i = 0; i < props.count(); ++i)
i < props.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
222 if (props.at(i).key == key)
props.at(i).key == keyDescription
TRUEnever evaluated
FALSEnever evaluated
0
223 return i;
never executed: return i;
0
224 return -1;
never executed: return -1;
0
225 }-
226-
227 inline QVariant property(qint32 key) const-
228 {-
229 const int idx = propertyIndex(key);-
230 if (idx < 0)
idx < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
231 return QVariant();
never executed: return QVariant();
0
232 return props.at(idx).value;
never executed: return props.at(idx).value;
0
233 }-
234-
235 inline bool hasProperty(qint32 key) const-
236 { return propertyIndex(key) != -1; }
never executed: return propertyIndex(key) != -1;
0
237-
238 void resolveFont(const QFont &defaultFont);-
239-
240 inline const QFont &font() const {-
241 if (fontDirty)
fontDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
242 recalcFont();
never executed: recalcFont();
0
243 return fnt;
never executed: return fnt;
0
244 }-
245-
246 QVector<Property> props;-
247private:-
248-
249 uint recalcHash() const;-
250 void recalcFont() const;-
251-
252 mutable bool hashDirty;-
253 mutable bool fontDirty;-
254 mutable uint hashValue;-
255 mutable QFont fnt;-
256-
257 friend QDataStream &operator<<(QDataStream &, const QTextFormat &);-
258 friend QDataStream &operator>>(QDataStream &, QTextFormat &);-
259};-
260-
261static inline uint hash(const QColor &color)-
262{-
263 return (color.isValid()) ? color.rgba() : 0x234109;
never executed: return (color.isValid()) ? color.rgba() : 0x234109;
(color.isValid())Description
TRUEnever evaluated
FALSEnever evaluated
0
264}-
265-
266static inline uint hash(const QPen &pen)-
267{-
268 return hash(pen.color()) + qHash(pen.widthF());
never executed: return hash(pen.color()) + qHash(pen.widthF());
0
269}-
270-
271static inline uint hash(const QBrush &brush)-
272{-
273 return hash(brush.color()) + (brush.style() << 3);
never executed: return hash(brush.color()) + (brush.style() << 3);
0
274}-
275-
276static inline uint variantHash(const QVariant &variant)-
277{-
278 // simple and fast hash functions to differentiate between type and value-
279 switch (variant.userType()) { // sorted by occurrence frequency-
280 case QVariant::String: return qHash(variant.toString());
never executed: return qHash(variant.toString());
never executed: case QVariant::String:
0
281 case QVariant::Double: return qHash(variant.toDouble());
never executed: return qHash(variant.toDouble());
never executed: case QVariant::Double:
0
282 case QVariant::Int: return 0x811890 + variant.toInt();
never executed: return 0x811890 + variant.toInt();
never executed: case QVariant::Int:
0
283 case QVariant::Brush:
never executed: case QVariant::Brush:
0
284 return 0x01010101 + hash(qvariant_cast<QBrush>(variant));
never executed: return 0x01010101 + hash(qvariant_cast<QBrush>(variant));
0
285 case QVariant::Bool: return 0x371818 + variant.toBool();
never executed: return 0x371818 + variant.toBool();
never executed: case QVariant::Bool:
0
286 case QVariant::Pen: return 0x02020202 + hash(qvariant_cast<QPen>(variant));
never executed: return 0x02020202 + hash(qvariant_cast<QPen>(variant));
never executed: case QVariant::Pen:
0
287 case QVariant::List:
never executed: case QVariant::List:
0
288 return 0x8377 + qvariant_cast<QVariantList>(variant).count();
never executed: return 0x8377 + qvariant_cast<QVariantList>(variant).count();
0
289 case QVariant::Color: return hash(qvariant_cast<QColor>(variant));
never executed: return hash(qvariant_cast<QColor>(variant));
never executed: case QVariant::Color:
0
290 case QVariant::TextLength:
never executed: case QVariant::TextLength:
0
291 return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue());
never executed: return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue());
0
292 case QMetaType::Float: return qHash(variant.toFloat());
never executed: return qHash(variant.toFloat());
never executed: case QMetaType::Float:
0
293 case QVariant::Invalid: return 0;
never executed: return 0;
never executed: case QVariant::Invalid:
0
294 default: break;
never executed: break;
never executed: default:
0
295 }-
296 return qHash(variant.typeName());
never executed: return qHash(variant.typeName());
0
297}-
298-
299static inline int getHash(const QTextFormatPrivate *d, int format)-
300{-
301 return (d ? d->hash() : 0) + format;
never executed: return (d ? d->hash() : 0) + format;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
302}-
303-
304uint QTextFormatPrivate::recalcHash() const-
305{-
306 hashValue = 0;-
307 for (QVector<Property>::ConstIterator it = props.constBegin(); it != props.constEnd(); ++it)
it != props.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
308 hashValue += (static_cast<quint32>(it->key) << 16) + variantHash(it->value);
never executed: hashValue += (static_cast<quint32>(it->key) << 16) + variantHash(it->value);
0
309-
310 hashDirty = false;-
311-
312 return hashValue;
never executed: return hashValue;
0
313}-
314-
315void QTextFormatPrivate::resolveFont(const QFont &defaultFont)-
316{-
317 recalcFont();-
318 const uint oldMask = fnt.resolve();-
319 fnt = fnt.resolve(defaultFont);-
320-
321 if (hasProperty(QTextFormat::FontSizeAdjustment)) {
hasProperty(QT...izeAdjustment)Description
TRUEnever evaluated
FALSEnever evaluated
0
322 const qreal scaleFactors[7] = {qreal(0.7), qreal(0.8), qreal(1.0), qreal(1.2), qreal(1.5), qreal(2), qreal(2.4)};-
323-
324 const int htmlFontSize = qBound(0, property(QTextFormat::FontSizeAdjustment).toInt() + 3 - 1, 6);-
325-
326-
327 if (defaultFont.pointSize() <= 0) {
defaultFont.pointSize() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
328 qreal pixelSize = scaleFactors[htmlFontSize] * defaultFont.pixelSize();-
329 fnt.setPixelSize(qRound(pixelSize));-
330 } else {
never executed: end of block
0
331 qreal pointSize = scaleFactors[htmlFontSize] * defaultFont.pointSizeF();-
332 fnt.setPointSizeF(pointSize);-
333 }
never executed: end of block
0
334 }-
335-
336 fnt.resolve(oldMask);-
337}
never executed: end of block
0
338-
339void QTextFormatPrivate::recalcFont() const-
340{-
341 // update cached font as well-
342 QFont f;-
343-
344 bool hasSpacingInformation = false;-
345 QFont::SpacingType spacingType = QFont::PercentageSpacing;-
346 qreal letterSpacing = 0.0;-
347-
348 for (int i = 0; i < props.count(); ++i) {
i < props.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
349 switch (props.at(i).key) {-
350 case QTextFormat::FontFamily:
never executed: case QTextFormat::FontFamily:
0
351 f.setFamily(props.at(i).value.toString());-
352 break;
never executed: break;
0
353 case QTextFormat::FontPointSize:
never executed: case QTextFormat::FontPointSize:
0
354 f.setPointSizeF(props.at(i).value.toReal());-
355 break;
never executed: break;
0
356 case QTextFormat::FontPixelSize:
never executed: case QTextFormat::FontPixelSize:
0
357 f.setPixelSize(props.at(i).value.toInt());-
358 break;
never executed: break;
0
359 case QTextFormat::FontWeight: {
never executed: case QTextFormat::FontWeight:
0
360 const QVariant weightValue = props.at(i).value;-
361 int weight = weightValue.toInt();-
362 if (weight >= 0 && weightValue.isValid())
weight >= 0Description
TRUEnever evaluated
FALSEnever evaluated
weightValue.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
363 f.setWeight(weight);
never executed: f.setWeight(weight);
0
364 break; }
never executed: break;
0
365 case QTextFormat::FontItalic:
never executed: case QTextFormat::FontItalic:
0
366 f.setItalic(props.at(i).value.toBool());-
367 break;
never executed: break;
0
368 case QTextFormat::FontUnderline:
never executed: case QTextFormat::FontUnderline:
0
369 if (! hasProperty(QTextFormat::TextUnderlineStyle)) // don't use the old one if the new one is there.
! hasProperty(...nderlineStyle)Description
TRUEnever evaluated
FALSEnever evaluated
0
370 f.setUnderline(props.at(i).value.toBool());
never executed: f.setUnderline(props.at(i).value.toBool());
0
371 break;
never executed: break;
0
372 case QTextFormat::TextUnderlineStyle:
never executed: case QTextFormat::TextUnderlineStyle:
0
373 f.setUnderline(static_cast<QTextCharFormat::UnderlineStyle>(props.at(i).value.toInt()) == QTextCharFormat::SingleUnderline);-
374 break;
never executed: break;
0
375 case QTextFormat::FontOverline:
never executed: case QTextFormat::FontOverline:
0
376 f.setOverline(props.at(i).value.toBool());-
377 break;
never executed: break;
0
378 case QTextFormat::FontStrikeOut:
never executed: case QTextFormat::FontStrikeOut:
0
379 f.setStrikeOut(props.at(i).value.toBool());-
380 break;
never executed: break;
0
381 case QTextFormat::FontLetterSpacingType:
never executed: case QTextFormat::FontLetterSpacingType:
0
382 spacingType = static_cast<QFont::SpacingType>(props.at(i).value.toInt());-
383 hasSpacingInformation = true;-
384 break;
never executed: break;
0
385 case QTextFormat::FontLetterSpacing:
never executed: case QTextFormat::FontLetterSpacing:
0
386 letterSpacing = props.at(i).value.toReal();-
387 hasSpacingInformation = true;-
388 break;
never executed: break;
0
389 case QTextFormat::FontWordSpacing:
never executed: case QTextFormat::FontWordSpacing:
0
390 f.setWordSpacing(props.at(i).value.toReal());-
391 break;
never executed: break;
0
392 case QTextFormat::FontCapitalization:
never executed: case QTextFormat::FontCapitalization:
0
393 f.setCapitalization(static_cast<QFont::Capitalization> (props.at(i).value.toInt()));-
394 break;
never executed: break;
0
395 case QTextFormat::FontFixedPitch: {
never executed: case QTextFormat::FontFixedPitch:
0
396 const bool value = props.at(i).value.toBool();-
397 if (f.fixedPitch() != value)
f.fixedPitch() != valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
398 f.setFixedPitch(value);
never executed: f.setFixedPitch(value);
0
399 break; }
never executed: break;
0
400 case QTextFormat::FontStretch:
never executed: case QTextFormat::FontStretch:
0
401 f.setStretch(props.at(i).value.toInt());-
402 break;
never executed: break;
0
403 case QTextFormat::FontStyleHint:
never executed: case QTextFormat::FontStyleHint:
0
404 f.setStyleHint(static_cast<QFont::StyleHint>(props.at(i).value.toInt()), f.styleStrategy());-
405 break;
never executed: break;
0
406 case QTextFormat::FontHintingPreference:
never executed: case QTextFormat::FontHintingPreference:
0
407 f.setHintingPreference(static_cast<QFont::HintingPreference>(props.at(i).value.toInt()));-
408 break;
never executed: break;
0
409 case QTextFormat::FontStyleStrategy:
never executed: case QTextFormat::FontStyleStrategy:
0
410 f.setStyleStrategy(static_cast<QFont::StyleStrategy>(props.at(i).value.toInt()));-
411 break;
never executed: break;
0
412 case QTextFormat::FontKerning:
never executed: case QTextFormat::FontKerning:
0
413 f.setKerning(props.at(i).value.toBool());-
414 break;
never executed: break;
0
415 default:
never executed: default:
0
416 break;
never executed: break;
0
417 }-
418 }-
419-
420 if (hasSpacingInformation)
hasSpacingInformationDescription
TRUEnever evaluated
FALSEnever evaluated
0
421 f.setLetterSpacing(spacingType, letterSpacing);
never executed: f.setLetterSpacing(spacingType, letterSpacing);
0
422-
423 fnt = f;-
424 fontDirty = false;-
425}
never executed: end of block
0
426-
427#ifndef QT_NO_DATASTREAM-
428Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextFormat &fmt)-
429{-
430 stream << fmt.format_type << fmt.properties();-
431 return stream;
never executed: return stream;
0
432}-
433-
434Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)-
435{-
436 QMap<qint32, QVariant> properties;-
437 stream >> fmt.format_type >> properties;-
438-
439 // QTextFormat's default constructor doesn't allocate the private structure, so-
440 // we have to do this, in case fmt is a default constructed value.-
441 if(!fmt.d)
!fmt.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
442 fmt.d = new QTextFormatPrivate();
never executed: fmt.d = new QTextFormatPrivate();
0
443-
444 for (QMap<qint32, QVariant>::ConstIterator it = properties.constBegin();-
445 it != properties.constEnd(); ++it)
it != properties.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
446 fmt.d->insertProperty(it.key(), it.value());
never executed: fmt.d->insertProperty(it.key(), it.value());
0
447-
448 return stream;
never executed: return stream;
0
449}-
450#endif // QT_NO_DATASTREAM-
451-
452/*!-
453 \class QTextFormat-
454 \reentrant-
455-
456 \brief The QTextFormat class provides formatting information for a-
457 QTextDocument.-
458 \inmodule QtGui-
459-
460 \ingroup richtext-processing-
461 \ingroup shared-
462-
463 A QTextFormat is a generic class used for describing the format of-
464 parts of a QTextDocument. The derived classes QTextCharFormat,-
465 QTextBlockFormat, QTextListFormat, and QTextTableFormat are usually-
466 more useful, and describe the formatting that is applied to-
467 specific parts of the document.-
468-
469 A format has a \c FormatType which specifies the kinds of text item it-
470 can format; e.g. a block of text, a list, a table, etc. A format-
471 also has various properties (some specific to particular format-
472 types), as described by the Property enum. Every property has a-
473 corresponding Property.-
474-
475 The format type is given by type(), and the format can be tested-
476 with isCharFormat(), isBlockFormat(), isListFormat(),-
477 isTableFormat(), isFrameFormat(), and isImageFormat(). If the-
478 type is determined, it can be retrieved with toCharFormat(),-
479 toBlockFormat(), toListFormat(), toTableFormat(), toFrameFormat(),-
480 and toImageFormat().-
481-
482 A format's properties can be set with the setProperty() functions,-
483 and retrieved with boolProperty(), intProperty(), doubleProperty(),-
484 and stringProperty() as appropriate. All the property IDs used in-
485 the format can be retrieved with allPropertyIds(). One format can-
486 be merged into another using merge().-
487-
488 A format's object index can be set with setObjectIndex(), and-
489 retrieved with objectIndex(). These methods can be used to-
490 associate the format with a QTextObject. It is used to represent-
491 lists, frames, and tables inside the document.-
492-
493 \sa {Rich Text Processing}-
494*/-
495-
496/*!-
497 \enum QTextFormat::FormatType-
498-
499 This enum describes the text item a QTextFormat object is formatting.-
500-
501 \value InvalidFormat An invalid format as created by the default-
502 constructor-
503 \value BlockFormat The object formats a text block-
504 \value CharFormat The object formats a single character-
505 \value ListFormat The object formats a list-
506 \omitvalue TableFormat Unused Value, a table's FormatType is FrameFormat.-
507 \value FrameFormat The object formats a frame-
508-
509 \value UserFormat-
510-
511 \sa QTextCharFormat, QTextBlockFormat, QTextListFormat,-
512 QTextTableFormat, type()-
513*/-
514-
515/*!-
516 \enum QTextFormat::Property-
517-
518 This enum describes the different properties a format can have.-
519-
520 \value ObjectIndex The index of the formatted object. See objectIndex().-
521-
522 Paragraph and character properties-
523-
524 \value CssFloat How a frame is located relative to the surrounding text-
525 \value LayoutDirection The layout direction of the text in the document-
526 (Qt::LayoutDirection).-
527-
528 \value OutlinePen-
529 \value ForegroundBrush-
530 \value BackgroundBrush-
531 \value BackgroundImageUrl-
532-
533 Paragraph properties-
534-
535 \value BlockAlignment-
536 \value BlockTopMargin-
537 \value BlockBottomMargin-
538 \value BlockLeftMargin-
539 \value BlockRightMargin-
540 \value TextIndent-
541 \value TabPositions Specifies the tab positions. The tab positions are structs of QTextOption::Tab which are stored in-
542 a QList (internally, in a QList<QVariant>).-
543 \value BlockIndent-
544 \value LineHeight-
545 \value LineHeightType-
546 \value BlockNonBreakableLines-
547 \value BlockTrailingHorizontalRulerWidth The width of a horizontal ruler element.-
548-
549 Character properties-
550-
551 \value FontFamily-
552 \value FontPointSize-
553 \value FontPixelSize-
554 \value FontSizeAdjustment Specifies the change in size given to the fontsize already set using-
555 FontPointSize or FontPixelSize.-
556 \value FontFixedPitch-
557 \omitvalue FontSizeIncrement-
558 \value FontWeight-
559 \value FontItalic-
560 \value FontUnderline \e{This property has been deprecated.} Use QTextFormat::TextUnderlineStyle instead.-
561 \value FontOverline-
562 \value FontStrikeOut-
563 \value FontCapitalization Specifies the capitalization type that is to be applied to the text.-
564 \value FontLetterSpacingType Specifies the meaning of the FontLetterSpacing property. The default-
565 is QFont::PercentageSpacing.-
566 \value FontLetterSpacing Changes the default spacing between individual letters in the font. The value is-
567 specified as a percentage or absolute value, depending on FontLetterSpacingType.-
568 The default value is 100%.-
569 \value FontWordSpacing Changes the default spacing between individual words. A positive value increases the word spacing-
570 by the corresponding pixels; a negative value decreases the spacing.-
571 \value FontStretch Corresponds to the QFont::Stretch property-
572 \value FontStyleHint Corresponds to the QFont::StyleHint property-
573 \value FontStyleStrategy Corresponds to the QFont::StyleStrategy property-
574 \value FontKerning Specifies whether the font has kerning turned on.-
575 \value FontHintingPreference Controls the use of hinting according to values-
576 of the QFont::HintingPreference enum.-
577-
578 \omitvalue FirstFontProperty-
579 \omitvalue LastFontProperty-
580-
581 \value TextUnderlineColor-
582 \value TextVerticalAlignment-
583 \value TextOutline-
584 \value TextUnderlineStyle-
585 \value TextToolTip Specifies the (optional) tool tip to be displayed for a fragment of text.-
586-
587 \value IsAnchor-
588 \value AnchorHref-
589 \value AnchorName-
590 \value ObjectType-
591-
592 List properties-
593-
594 \value ListStyle Specifies the style used for the items in a list,-
595 described by values of the QTextListFormat::Style enum.-
596 \value ListIndent Specifies the amount of indentation used for a list.-
597 \value ListNumberPrefix Defines the text which is prepended to item numbers in-
598 numeric lists.-
599 \value ListNumberSuffix Defines the text which is appended to item numbers in-
600 numeric lists.-
601-
602 Table and frame properties-
603-
604 \value FrameBorder-
605 \value FrameBorderBrush-
606 \value FrameBorderStyle See the \l{QTextFrameFormat::BorderStyle}{BorderStyle} enum.-
607 \value FrameBottomMargin-
608 \value FrameHeight-
609 \value FrameLeftMargin-
610 \value FrameMargin-
611 \value FramePadding-
612 \value FrameRightMargin-
613 \value FrameTopMargin-
614 \value FrameWidth-
615 \value TableCellSpacing-
616 \value TableCellPadding-
617 \value TableColumns-
618 \value TableColumnWidthConstraints-
619 \value TableHeaderRowCount-
620-
621 Table cell properties-
622-
623 \value TableCellRowSpan-
624 \value TableCellColumnSpan-
625 \value TableCellLeftPadding-
626 \value TableCellRightPadding-
627 \value TableCellTopPadding-
628 \value TableCellBottomPadding-
629-
630 Image properties-
631-
632 \value ImageName-
633 \value ImageWidth-
634 \value ImageHeight-
635-
636 Selection properties-
637-
638 \value FullWidthSelection When set on the characterFormat of a selection,-
639 the whole width of the text will be shown selected.-
640-
641 Page break properties-
642-
643 \value PageBreakPolicy Specifies how pages are broken. See the PageBreakFlag enum.-
644-
645 \value UserProperty-
646-
647 \sa property(), setProperty()-
648*/-
649-
650/*!-
651 \enum QTextFormat::ObjectTypes-
652-
653 This enum describes what kind of QTextObject this format is associated with.-
654-
655 \value NoObject-
656 \value ImageObject-
657 \value TableObject-
658 \value TableCellObject-
659 \value UserObject The first object that can be used for application-specific purposes.-
660-
661 \sa QTextObject, QTextTable, QTextObject::format()-
662*/-
663-
664/*!-
665 \enum QTextFormat::PageBreakFlag-
666 \since 4.2-
667-
668 This enum describes how page breaking is performed when printing. It maps to the-
669 corresponding css properties.-
670-
671 \value PageBreak_Auto The page break is determined automatically depending on the-
672 available space on the current page-
673 \value PageBreak_AlwaysBefore The page is always broken before the paragraph/table-
674 \value PageBreak_AlwaysAfter A new page is always started after the paragraph/table-
675-
676 \sa QTextBlockFormat::pageBreakPolicy(), QTextFrameFormat::pageBreakPolicy(),-
677 PageBreakPolicy-
678*/-
679-
680/*!-
681 \fn bool QTextFormat::isValid() const-
682-
683 Returns \c true if the format is valid (i.e. is not-
684 InvalidFormat); otherwise returns \c false.-
685*/-
686-
687/*!-
688 \fn bool QTextFormat::isEmpty() const-
689 \since 5.3-
690-
691 Returns true if the format does not store any properties; false otherwise.-
692-
693 \sa propertyCount(), properties()-
694*/-
695-
696/*!-
697 \fn bool QTextFormat::isCharFormat() const-
698-
699 Returns \c true if this text format is a \c CharFormat; otherwise-
700 returns \c false.-
701*/-
702-
703-
704/*!-
705 \fn bool QTextFormat::isBlockFormat() const-
706-
707 Returns \c true if this text format is a \c BlockFormat; otherwise-
708 returns \c false.-
709*/-
710-
711-
712/*!-
713 \fn bool QTextFormat::isListFormat() const-
714-
715 Returns \c true if this text format is a \c ListFormat; otherwise-
716 returns \c false.-
717*/-
718-
719-
720/*!-
721 \fn bool QTextFormat::isTableFormat() const-
722-
723 Returns \c true if this text format is a \c TableFormat; otherwise-
724 returns \c false.-
725*/-
726-
727-
728/*!-
729 \fn bool QTextFormat::isFrameFormat() const-
730-
731 Returns \c true if this text format is a \c FrameFormat; otherwise-
732 returns \c false.-
733*/-
734-
735-
736/*!-
737 \fn bool QTextFormat::isImageFormat() const-
738-
739 Returns \c true if this text format is an image format; otherwise-
740 returns \c false.-
741*/-
742-
743-
744/*!-
745 \fn bool QTextFormat::isTableCellFormat() const-
746 \since 4.4-
747-
748 Returns \c true if this text format is a \c TableCellFormat; otherwise-
749 returns \c false.-
750*/-
751-
752-
753/*!-
754 Creates a new text format with an \c InvalidFormat.-
755-
756 \sa FormatType-
757*/-
758QTextFormat::QTextFormat()-
759 : format_type(InvalidFormat)-
760{-
761}
never executed: end of block
0
762-
763/*!-
764 Creates a new text format of the given \a type.-
765-
766 \sa FormatType-
767*/-
768QTextFormat::QTextFormat(int type)-
769 : format_type(type)-
770{-
771}
never executed: end of block
0
772-
773-
774/*!-
775 \fn QTextFormat::QTextFormat(const QTextFormat &other)-
776-
777 Creates a new text format with the same attributes as the \a other-
778 text format.-
779*/-
780QTextFormat::QTextFormat(const QTextFormat &rhs)-
781 : d(rhs.d), format_type(rhs.format_type)-
782{-
783}
never executed: end of block
0
784-
785/*!-
786 \fn QTextFormat &QTextFormat::operator=(const QTextFormat &other)-
787-
788 Assigns the \a other text format to this text format, and returns a-
789 reference to this text format.-
790*/-
791QTextFormat &QTextFormat::operator=(const QTextFormat &rhs)-
792{-
793 d = rhs.d;-
794 format_type = rhs.format_type;-
795 return *this;
never executed: return *this;
0
796}-
797-
798/*!-
799 \fn void QTextFormat::swap(QTextFormat &other)-
800 \since 5.0-
801-
802 Swaps this text format with \a other. This function is very fast-
803 and never fails.-
804*/-
805-
806/*!-
807 Destroys this text format.-
808*/-
809QTextFormat::~QTextFormat()-
810{-
811}-
812-
813-
814/*!-
815 Returns the text format as a QVariant-
816*/-
817QTextFormat::operator QVariant() const-
818{-
819 return QVariant(QVariant::TextFormat, this);
never executed: return QVariant(QVariant::TextFormat, this);
0
820}-
821-
822/*!-
823 Merges the \a other format with this format; where there are-
824 conflicts the \a other format takes precedence.-
825*/-
826void QTextFormat::merge(const QTextFormat &other)-
827{-
828 if (format_type != other.format_type)
format_type !=...er.format_typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
829 return;
never executed: return;
0
830-
831 if (!d) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
832 d = other.d;-
833 return;
never executed: return;
0
834 }-
835-
836 if (!other.d)
!other.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
837 return;
never executed: return;
0
838-
839 QTextFormatPrivate *d = this->d;-
840-
841 const QVector<QTextFormatPrivate::Property> &otherProps = other.d->props;-
842 d->props.reserve(d->props.size() + otherProps.size());-
843 for (int i = 0; i < otherProps.count(); ++i) {
i < otherProps.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
844 const QTextFormatPrivate::Property &p = otherProps.at(i);-
845 d->insertProperty(p.key, p.value);-
846 }
never executed: end of block
0
847}
never executed: end of block
0
848-
849/*!-
850 Returns the type of this format.-
851-
852 \sa FormatType-
853*/-
854int QTextFormat::type() const-
855{-
856 return format_type;
never executed: return format_type;
0
857}-
858-
859/*!-
860 Returns this format as a block format.-
861*/-
862QTextBlockFormat QTextFormat::toBlockFormat() const-
863{-
864 return QTextBlockFormat(*this);
never executed: return QTextBlockFormat(*this);
0
865}-
866-
867/*!-
868 Returns this format as a character format.-
869*/-
870QTextCharFormat QTextFormat::toCharFormat() const-
871{-
872 return QTextCharFormat(*this);
never executed: return QTextCharFormat(*this);
0
873}-
874-
875/*!-
876 Returns this format as a list format.-
877*/-
878QTextListFormat QTextFormat::toListFormat() const-
879{-
880 return QTextListFormat(*this);
never executed: return QTextListFormat(*this);
0
881}-
882-
883/*!-
884 Returns this format as a table format.-
885*/-
886QTextTableFormat QTextFormat::toTableFormat() const-
887{-
888 return QTextTableFormat(*this);
never executed: return QTextTableFormat(*this);
0
889}-
890-
891/*!-
892 Returns this format as a frame format.-
893*/-
894QTextFrameFormat QTextFormat::toFrameFormat() const-
895{-
896 return QTextFrameFormat(*this);
never executed: return QTextFrameFormat(*this);
0
897}-
898-
899/*!-
900 Returns this format as an image format.-
901*/-
902QTextImageFormat QTextFormat::toImageFormat() const-
903{-
904 return QTextImageFormat(*this);
never executed: return QTextImageFormat(*this);
0
905}-
906-
907/*!-
908 \since 4.4-
909-
910 Returns this format as a table cell format.-
911*/-
912QTextTableCellFormat QTextFormat::toTableCellFormat() const-
913{-
914 return QTextTableCellFormat(*this);
never executed: return QTextTableCellFormat(*this);
0
915}-
916-
917/*!-
918 Returns the value of the property specified by \a propertyId. If the-
919 property isn't of QTextFormat::Bool type, false is returned instead.-
920-
921 \sa setProperty(), intProperty(), doubleProperty(), stringProperty(), colorProperty(),-
922 lengthProperty(), lengthVectorProperty(), Property-
923*/-
924bool QTextFormat::boolProperty(int propertyId) const-
925{-
926 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
927 return false;
never executed: return false;
0
928 const QVariant prop = d->property(propertyId);-
929 if (prop.userType() != QVariant::Bool)
prop.userType(...QVariant::BoolDescription
TRUEnever evaluated
FALSEnever evaluated
0
930 return false;
never executed: return false;
0
931 return prop.toBool();
never executed: return prop.toBool();
0
932}-
933-
934/*!-
935 Returns the value of the property specified by \a propertyId. If the-
936 property is not of QTextFormat::Integer type, 0 is returned instead.-
937-
938 \sa setProperty(), boolProperty(), doubleProperty(), stringProperty(), colorProperty(),-
939 lengthProperty(), lengthVectorProperty(), Property-
940*/-
941int QTextFormat::intProperty(int propertyId) const-
942{-
943 // required, since the default layout direction has to be LayoutDirectionAuto, which is not integer 0-
944 int def = (propertyId == QTextFormat::LayoutDirection) ? int(Qt::LayoutDirectionAuto) : 0;
(propertyId ==...youtDirection)Description
TRUEnever evaluated
FALSEnever evaluated
0
945-
946 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
947 return def;
never executed: return def;
0
948 const QVariant prop = d->property(propertyId);-
949 if (prop.userType() != QVariant::Int)
prop.userType(... QVariant::IntDescription
TRUEnever evaluated
FALSEnever evaluated
0
950 return def;
never executed: return def;
0
951 return prop.toInt();
never executed: return prop.toInt();
0
952}-
953-
954/*!-
955 Returns the value of the property specified by \a propertyId. If the-
956 property isn't of QVariant::Double or QMetaType::Float type, 0 is-
957 returned instead.-
958-
959 \sa setProperty(), boolProperty(), intProperty(), stringProperty(), colorProperty(),-
960 lengthProperty(), lengthVectorProperty(), Property-
961*/-
962qreal QTextFormat::doubleProperty(int propertyId) const-
963{-
964 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
965 return 0.;
never executed: return 0.;
0
966 const QVariant prop = d->property(propertyId);-
967 if (prop.userType() != QVariant::Double && prop.userType() != QMetaType::Float)
prop.userType(...ariant::DoubleDescription
TRUEnever evaluated
FALSEnever evaluated
prop.userType(...etaType::FloatDescription
TRUEnever evaluated
FALSEnever evaluated
0
968 return 0.;
never executed: return 0.;
0
969 return qvariant_cast<qreal>(prop);
never executed: return qvariant_cast<qreal>(prop);
0
970}-
971-
972/*!-
973 Returns the value of the property given by \a propertyId; if the-
974 property isn't of QVariant::String type, an empty string is-
975 returned instead.-
976-
977 \sa setProperty(), boolProperty(), intProperty(), doubleProperty(), colorProperty(),-
978 lengthProperty(), lengthVectorProperty(), Property-
979*/-
980QString QTextFormat::stringProperty(int propertyId) const-
981{-
982 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
983 return QString();
never executed: return QString();
0
984 const QVariant prop = d->property(propertyId);-
985 if (prop.userType() != QVariant::String)
prop.userType(...ariant::StringDescription
TRUEnever evaluated
FALSEnever evaluated
0
986 return QString();
never executed: return QString();
0
987 return prop.toString();
never executed: return prop.toString();
0
988}-
989-
990/*!-
991 Returns the value of the property given by \a propertyId; if the-
992 property isn't of QVariant::Color type, an invalid color is-
993 returned instead.-
994-
995 \sa setProperty(), boolProperty(), intProperty(), doubleProperty(),-
996 stringProperty(), lengthProperty(), lengthVectorProperty(), Property-
997*/-
998QColor QTextFormat::colorProperty(int propertyId) const-
999{-
1000 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1001 return QColor();
never executed: return QColor();
0
1002 const QVariant prop = d->property(propertyId);-
1003 if (prop.userType() != QVariant::Color)
prop.userType(...Variant::ColorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1004 return QColor();
never executed: return QColor();
0
1005 return qvariant_cast<QColor>(prop);
never executed: return qvariant_cast<QColor>(prop);
0
1006}-
1007-
1008/*!-
1009 Returns the value of the property given by \a propertyId; if the-
1010 property isn't of QVariant::Pen type, Qt::NoPen is-
1011 returned instead.-
1012-
1013 \sa setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(),-
1014 lengthProperty(), lengthVectorProperty(), Property-
1015*/-
1016QPen QTextFormat::penProperty(int propertyId) const-
1017{-
1018 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1019 return QPen(Qt::NoPen);
never executed: return QPen(Qt::NoPen);
0
1020 const QVariant prop = d->property(propertyId);-
1021 if (prop.userType() != QVariant::Pen)
prop.userType(... QVariant::PenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1022 return QPen(Qt::NoPen);
never executed: return QPen(Qt::NoPen);
0
1023 return qvariant_cast<QPen>(prop);
never executed: return qvariant_cast<QPen>(prop);
0
1024}-
1025-
1026/*!-
1027 Returns the value of the property given by \a propertyId; if the-
1028 property isn't of QVariant::Brush type, Qt::NoBrush is-
1029 returned instead.-
1030-
1031 \sa setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(),-
1032 lengthProperty(), lengthVectorProperty(), Property-
1033*/-
1034QBrush QTextFormat::brushProperty(int propertyId) const-
1035{-
1036 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1037 return QBrush(Qt::NoBrush);
never executed: return QBrush(Qt::NoBrush);
0
1038 const QVariant prop = d->property(propertyId);-
1039 if (prop.userType() != QVariant::Brush)
prop.userType(...Variant::BrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
1040 return QBrush(Qt::NoBrush);
never executed: return QBrush(Qt::NoBrush);
0
1041 return qvariant_cast<QBrush>(prop);
never executed: return qvariant_cast<QBrush>(prop);
0
1042}-
1043-
1044/*!-
1045 Returns the value of the property given by \a propertyId.-
1046-
1047 \sa setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(),-
1048 colorProperty(), lengthVectorProperty(), Property-
1049*/-
1050QTextLength QTextFormat::lengthProperty(int propertyId) const-
1051{-
1052 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1053 return QTextLength();
never executed: return QTextLength();
0
1054 return qvariant_cast<QTextLength>(d->property(propertyId));
never executed: return qvariant_cast<QTextLength>(d->property(propertyId));
0
1055}-
1056-
1057/*!-
1058 Returns the value of the property given by \a propertyId. If the-
1059 property isn't of QTextFormat::LengthVector type, an empty length-
1060 vector is returned instead.-
1061-
1062 \sa setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(),-
1063 colorProperty(), lengthProperty(), Property-
1064*/-
1065QVector<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const-
1066{-
1067 QVector<QTextLength> vector;-
1068 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1069 return vector;
never executed: return vector;
0
1070 const QVariant prop = d->property(propertyId);-
1071 if (prop.userType() != QVariant::List)
prop.userType(...QVariant::ListDescription
TRUEnever evaluated
FALSEnever evaluated
0
1072 return vector;
never executed: return vector;
0
1073-
1074 QList<QVariant> propertyList = prop.toList();-
1075 for (int i=0; i<propertyList.size(); ++i) {
i<propertyList.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1076 QVariant var = propertyList.at(i);-
1077 if (var.userType() == QVariant::TextLength)
var.userType()...nt::TextLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1078 vector.append(qvariant_cast<QTextLength>(var));
never executed: vector.append(qvariant_cast<QTextLength>(var));
0
1079 }
never executed: end of block
0
1080-
1081 return vector;
never executed: return vector;
0
1082}-
1083-
1084/*!-
1085 Returns the property specified by the given \a propertyId.-
1086-
1087 \sa Property-
1088*/-
1089QVariant QTextFormat::property(int propertyId) const-
1090{-
1091 return d ? d->property(propertyId) : QVariant();
never executed: return d ? d->property(propertyId) : QVariant();
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1092}-
1093-
1094/*!-
1095 Sets the property specified by the \a propertyId to the given \a value.-
1096-
1097 \sa Property-
1098*/-
1099void QTextFormat::setProperty(int propertyId, const QVariant &value)-
1100{-
1101 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1102 d = new QTextFormatPrivate;
never executed: d = new QTextFormatPrivate;
0
1103 if (!value.isValid())
!value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1104 clearProperty(propertyId);
never executed: clearProperty(propertyId);
0
1105 else-
1106 d->insertProperty(propertyId, value);
never executed: d->insertProperty(propertyId, value);
0
1107}-
1108-
1109/*!-
1110 Sets the value of the property given by \a propertyId to \a value.-
1111-
1112 \sa lengthVectorProperty(), Property-
1113*/-
1114void QTextFormat::setProperty(int propertyId, const QVector<QTextLength> &value)-
1115{-
1116 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1117 d = new QTextFormatPrivate;
never executed: d = new QTextFormatPrivate;
0
1118 QVariantList list;-
1119 const int numValues = value.size();-
1120 list.reserve(numValues);-
1121 for (int i = 0; i < numValues; ++i)
i < numValuesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1122 list << value.at(i);
never executed: list << value.at(i);
0
1123 d->insertProperty(propertyId, list);-
1124}
never executed: end of block
0
1125-
1126/*!-
1127 Clears the value of the property given by \a propertyId-
1128-
1129 \sa Property-
1130*/-
1131void QTextFormat::clearProperty(int propertyId)-
1132{-
1133 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1134 return;
never executed: return;
0
1135 d->clearProperty(propertyId);-
1136}
never executed: end of block
0
1137-
1138-
1139/*!-
1140 \fn void QTextFormat::setObjectType(int type)-
1141-
1142 Sets the text format's object type to \a type.-
1143-
1144 \sa ObjectTypes, objectType()-
1145*/-
1146-
1147-
1148/*!-
1149 \fn int QTextFormat::objectType() const-
1150-
1151 Returns the text format's object type.-
1152-
1153 \sa ObjectTypes, setObjectType()-
1154*/-
1155-
1156-
1157/*!-
1158 Returns the index of the format object, or -1 if the format object is invalid.-
1159-
1160 \sa setObjectIndex()-
1161*/-
1162int QTextFormat::objectIndex() const-
1163{-
1164 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1165 return -1;
never executed: return -1;
0
1166 const QVariant prop = d->property(ObjectIndex);-
1167 if (prop.userType() != QVariant::Int) // ####
prop.userType(... QVariant::IntDescription
TRUEnever evaluated
FALSEnever evaluated
0
1168 return -1;
never executed: return -1;
0
1169 return prop.toInt();
never executed: return prop.toInt();
0
1170}-
1171-
1172/*!-
1173 \fn void QTextFormat::setObjectIndex(int index)-
1174-
1175 Sets the format object's object \a index.-
1176-
1177 \sa objectIndex()-
1178*/-
1179void QTextFormat::setObjectIndex(int o)-
1180{-
1181 if (o == -1) {
o == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1182 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1183 d->clearProperty(ObjectIndex);
never executed: d->clearProperty(ObjectIndex);
0
1184 } else {
never executed: end of block
0
1185 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1186 d = new QTextFormatPrivate;
never executed: d = new QTextFormatPrivate;
0
1187 // ### type-
1188 d->insertProperty(ObjectIndex, o);-
1189 }
never executed: end of block
0
1190}-
1191-
1192/*!-
1193 Returns \c true if the text format has a property with the given \a-
1194 propertyId; otherwise returns \c false.-
1195-
1196 \sa properties(), Property-
1197*/-
1198bool QTextFormat::hasProperty(int propertyId) const-
1199{-
1200 return d ? d->hasProperty(propertyId) : false;
never executed: return d ? d->hasProperty(propertyId) : false;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1201}-
1202-
1203/*-
1204 Returns the property type for the given \a propertyId.-
1205-
1206 \sa hasProperty(), allPropertyIds(), Property-
1207*/-
1208-
1209/*!-
1210 Returns a map with all properties of this text format.-
1211*/-
1212QMap<int, QVariant> QTextFormat::properties() const-
1213{-
1214 QMap<int, QVariant> map;-
1215 if (d) {
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1216 for (int i = 0; i < d->props.count(); ++i)
i < d->props.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1217 map.insert(d->props.at(i).key, d->props.at(i).value);
never executed: map.insert(d->props.at(i).key, d->props.at(i).value);
0
1218 }
never executed: end of block
0
1219 return map;
never executed: return map;
0
1220}-
1221-
1222/*!-
1223 \since 4.3-
1224 Returns the number of properties stored in the format.-
1225*/-
1226int QTextFormat::propertyCount() const-
1227{-
1228 return d ? d->props.count() : 0;
never executed: return d ? d->props.count() : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1229}-
1230-
1231/*!-
1232 \fn bool QTextFormat::operator!=(const QTextFormat &other) const-
1233-
1234 Returns \c true if this text format is different from the \a other text-
1235 format.-
1236*/-
1237-
1238-
1239/*!-
1240 \fn bool QTextFormat::operator==(const QTextFormat &other) const-
1241-
1242 Returns \c true if this text format is the same as the \a other text-
1243 format.-
1244*/-
1245bool QTextFormat::operator==(const QTextFormat &rhs) const-
1246{-
1247 if (format_type != rhs.format_type)
format_type != rhs.format_typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1248 return false;
never executed: return false;
0
1249-
1250 if (d == rhs.d)
d == rhs.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1251 return true;
never executed: return true;
0
1252-
1253 if (d && d->props.isEmpty() && !rhs.d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
d->props.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!rhs.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1254 return true;
never executed: return true;
0
1255-
1256 if (!d && rhs.d && rhs.d->props.isEmpty())
!dDescription
TRUEnever evaluated
FALSEnever evaluated
rhs.dDescription
TRUEnever evaluated
FALSEnever evaluated
rhs.d->props.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1257 return true;
never executed: return true;
0
1258-
1259 if (!d || !rhs.d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
!rhs.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1260 return false;
never executed: return false;
0
1261-
1262 return *d == *rhs.d;
never executed: return *d == *rhs.d;
0
1263}-
1264-
1265/*!-
1266 \class QTextCharFormat-
1267 \reentrant-
1268-
1269 \brief The QTextCharFormat class provides formatting information for-
1270 characters in a QTextDocument.-
1271 \inmodule QtGui-
1272-
1273 \ingroup richtext-processing-
1274 \ingroup shared-
1275-
1276 The character format of text in a document specifies the visual properties-
1277 of the text, as well as information about its role in a hypertext document.-
1278-
1279 The font used can be set by supplying a font to the setFont() function, and-
1280 each aspect of its appearance can be adjusted to give the desired effect.-
1281 setFontFamily() and setFontPointSize() define the font's family (e.g. Times)-
1282 and printed size; setFontWeight() and setFontItalic() provide control over-
1283 the style of the font. setFontUnderline(), setFontOverline(),-
1284 setFontStrikeOut(), and setFontFixedPitch() provide additional effects for-
1285 text.-
1286-
1287 The color is set with setForeground(). If the text is intended to be used-
1288 as an anchor (for hyperlinks), this can be enabled with setAnchor(). The-
1289 setAnchorHref() and setAnchorNames() functions are used to specify the-
1290 information about the hyperlink's destination and the anchor's name.-
1291-
1292 \sa QTextFormat, QTextBlockFormat, QTextTableFormat, QTextListFormat-
1293*/-
1294-
1295/*!-
1296 \enum QTextCharFormat::VerticalAlignment-
1297-
1298 This enum describes the ways that adjacent characters can be vertically-
1299 aligned.-
1300-
1301 \value AlignNormal Adjacent characters are positioned in the standard-
1302 way for text in the writing system in use.-
1303 \value AlignSuperScript Characters are placed above the base line for-
1304 normal text.-
1305 \value AlignSubScript Characters are placed below the base line for-
1306 normal text.-
1307 \value AlignMiddle The center of the object is vertically aligned with the-
1308 base line. Currently, this is only implemented for-
1309 inline objects.-
1310 \value AlignBottom The bottom edge of the object is vertically aligned with-
1311 the base line.-
1312 \value AlignTop The top edge of the object is vertically aligned with-
1313 the base line.-
1314 \value AlignBaseline The base lines of the characters are aligned.-
1315*/-
1316-
1317/*!-
1318 \enum QTextCharFormat::UnderlineStyle-
1319-
1320 This enum describes the different ways drawing underlined text.-
1321-
1322 \value NoUnderline Text is draw without any underlining decoration.-
1323 \value SingleUnderline A line is drawn using Qt::SolidLine.-
1324 \value DashUnderline Dashes are drawn using Qt::DashLine.-
1325 \value DotLine Dots are drawn using Qt::DotLine;-
1326 \value DashDotLine Dashs and dots are drawn using Qt::DashDotLine.-
1327 \value DashDotDotLine Underlines draw drawn using Qt::DashDotDotLine.-
1328 \value WaveUnderline The text is underlined using a wave shaped line.-
1329 \value SpellCheckUnderline The underline is drawn depending on the QStyle::SH_SpellCeckUnderlineStyle-
1330 style hint of the QApplication style. By default this is mapped to-
1331 WaveUnderline, on \macos it is mapped to DashDotLine.-
1332-
1333 \sa Qt::PenStyle-
1334*/-
1335-
1336/*!-
1337 \fn QTextCharFormat::QTextCharFormat()-
1338-
1339 Constructs a new character format object.-
1340*/-
1341QTextCharFormat::QTextCharFormat() : QTextFormat(CharFormat) {}
never executed: end of block
0
1342-
1343/*!-
1344 \internal-
1345 \fn QTextCharFormat::QTextCharFormat(const QTextFormat &other)-
1346-
1347 Creates a new character format with the same attributes as the \a given-
1348 text format.-
1349*/-
1350QTextCharFormat::QTextCharFormat(const QTextFormat &fmt)-
1351 : QTextFormat(fmt)-
1352{-
1353}
never executed: end of block
0
1354-
1355/*!-
1356 \fn bool QTextCharFormat::isValid() const-
1357-
1358 Returns \c true if this character format is valid; otherwise returns-
1359 false.-
1360*/-
1361-
1362-
1363/*!-
1364 \fn void QTextCharFormat::setFontFamily(const QString &family)-
1365-
1366 Sets the text format's font \a family.-
1367-
1368 \sa setFont()-
1369*/-
1370-
1371-
1372/*!-
1373 \fn QString QTextCharFormat::fontFamily() const-
1374-
1375 Returns the text format's font family.-
1376-
1377 \sa font()-
1378*/-
1379-
1380-
1381/*!-
1382 \fn void QTextCharFormat::setFontPointSize(qreal size)-
1383-
1384 Sets the text format's font \a size.-
1385-
1386 \sa setFont()-
1387*/-
1388-
1389-
1390/*!-
1391 \fn qreal QTextCharFormat::fontPointSize() const-
1392-
1393 Returns the font size used to display text in this format.-
1394-
1395 \sa font()-
1396*/-
1397-
1398-
1399/*!-
1400 \fn void QTextCharFormat::setFontWeight(int weight)-
1401-
1402 Sets the text format's font weight to \a weight.-
1403-
1404 \sa setFont(), QFont::Weight-
1405*/-
1406-
1407-
1408/*!-
1409 \fn int QTextCharFormat::fontWeight() const-
1410-
1411 Returns the text format's font weight.-
1412-
1413 \sa font(), QFont::Weight-
1414*/-
1415-
1416-
1417/*!-
1418 \fn void QTextCharFormat::setFontItalic(bool italic)-
1419-
1420 If \a italic is true, sets the text format's font to be italic; otherwise-
1421 the font will be non-italic.-
1422-
1423 \sa setFont()-
1424*/-
1425-
1426-
1427/*!-
1428 \fn bool QTextCharFormat::fontItalic() const-
1429-
1430 Returns \c true if the text format's font is italic; otherwise-
1431 returns \c false.-
1432-
1433 \sa font()-
1434*/-
1435-
1436-
1437/*!-
1438 \fn void QTextCharFormat::setFontUnderline(bool underline)-
1439-
1440 If \a underline is true, sets the text format's font to be underlined;-
1441 otherwise it is displayed non-underlined.-
1442-
1443 \sa setFont()-
1444*/-
1445-
1446-
1447/*!-
1448 \fn bool QTextCharFormat::fontUnderline() const-
1449-
1450 Returns \c true if the text format's font is underlined; otherwise-
1451 returns \c false.-
1452-
1453 \sa font()-
1454*/-
1455bool QTextCharFormat::fontUnderline() const-
1456{-
1457 if (hasProperty(TextUnderlineStyle))
hasProperty(Te...nderlineStyle)Description
TRUEnever evaluated
FALSEnever evaluated
0
1458 return underlineStyle() == SingleUnderline;
never executed: return underlineStyle() == SingleUnderline;
0
1459 return boolProperty(FontUnderline);
never executed: return boolProperty(FontUnderline);
0
1460}-
1461-
1462/*!-
1463 \fn UnderlineStyle QTextCharFormat::underlineStyle() const-
1464 \since 4.2-
1465-
1466 Returns the style of underlining the text.-
1467*/-
1468-
1469/*!-
1470 \fn void QTextCharFormat::setUnderlineStyle(UnderlineStyle style)-
1471 \since 4.2-
1472-
1473 Sets the style of underlining the text to \a style.-
1474*/-
1475void QTextCharFormat::setUnderlineStyle(UnderlineStyle style)-
1476{-
1477 setProperty(TextUnderlineStyle, style);-
1478 // for compatibility-
1479 setProperty(FontUnderline, style == SingleUnderline);-
1480}
never executed: end of block
0
1481-
1482/*!-
1483 \fn void QTextCharFormat::setFontOverline(bool overline)-
1484-
1485 If \a overline is true, sets the text format's font to be overlined;-
1486 otherwise the font is displayed non-overlined.-
1487-
1488 \sa setFont()-
1489*/-
1490-
1491-
1492/*!-
1493 \fn bool QTextCharFormat::fontOverline() const-
1494-
1495 Returns \c true if the text format's font is overlined; otherwise-
1496 returns \c false.-
1497-
1498 \sa font()-
1499*/-
1500-
1501-
1502/*!-
1503 \fn void QTextCharFormat::setFontStrikeOut(bool strikeOut)-
1504-
1505 If \a strikeOut is true, sets the text format's font with strike-out-
1506 enabled (with a horizontal line through it); otherwise it is displayed-
1507 without strikeout.-
1508-
1509 \sa setFont()-
1510*/-
1511-
1512-
1513/*!-
1514 \fn bool QTextCharFormat::fontStrikeOut() const-
1515-
1516 Returns \c true if the text format's font is struck out (has a horizontal line-
1517 drawn through it); otherwise returns \c false.-
1518-
1519 \sa font()-
1520*/-
1521-
1522-
1523/*!-
1524 \since 4.5-
1525 \fn void QTextCharFormat::setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy)-
1526-
1527 Sets the font style \a hint and \a strategy.-
1528-
1529 Qt does not support style hints on X11 since this information is not provided by the window system.-
1530-
1531 \sa setFont()-
1532 \sa QFont::setStyleHint()-
1533*/-
1534-
1535-
1536/*!-
1537 \since 4.5-
1538 \fn void QTextCharFormat::setFontStyleStrategy(QFont::StyleStrategy strategy)-
1539-
1540 Sets the font style \a strategy.-
1541-
1542 \sa setFont()-
1543 \sa QFont::setStyleStrategy()-
1544*/-
1545-
1546-
1547/*!-
1548 \since 4.5-
1549 \fn void QTextCharFormat::setFontKerning(bool enable)-
1550 Enables kerning for this font if \a enable is true; otherwise disables it.-
1551-
1552 When kerning is enabled, glyph metrics do not add up anymore, even for-
1553 Latin text. In other words, the assumption that width('a') + width('b')-
1554 is equal to width("ab") is not neccesairly true.-
1555-
1556 \sa setFont()-
1557*/-
1558-
1559-
1560/*!-
1561 \fn QTextCharFormat::StyleHint QTextCharFormat::fontStyleHint() const-
1562 \since 4.5-
1563-
1564 Returns the font style hint.-
1565-
1566 \sa setFontStyleHint(), font()-
1567*/-
1568-
1569-
1570/*!-
1571 \since 4.5-
1572 \fn QTextCharFormat::StyleStrategy QTextCharFormat::fontStyleStrategy() const-
1573-
1574 Returns the current font style strategy.-
1575-
1576 \sa setFontStyleStrategy()-
1577 \sa font()-
1578*/-
1579-
1580-
1581/*!-
1582 \since 4.5-
1583 \fn bool QTextCharFormat::fontKerning() const-
1584 Returns \c true if the font kerning is enabled.-
1585-
1586 \sa setFontKerning()-
1587 \sa font()-
1588*/-
1589-
1590-
1591/*!-
1592 \fn void QTextCharFormat::setFontFixedPitch(bool fixedPitch)-
1593-
1594 If \a fixedPitch is true, sets the text format's font to be fixed pitch;-
1595 otherwise a non-fixed pitch font is used.-
1596-
1597 \sa setFont()-
1598*/-
1599-
1600-
1601/*!-
1602 \fn bool QTextCharFormat::fontFixedPitch() const-
1603-
1604 Returns \c true if the text format's font is fixed pitch; otherwise-
1605 returns \c false.-
1606-
1607 \sa font()-
1608*/-
1609-
1610/*!-
1611 \since 4.8-
1612-
1613 \fn void QTextCharFormat::setFontHintingPreference(QFont::HintingPreference hintingPreference)-
1614-
1615 Sets the hinting preference of the text format's font to be \a hintingPreference.-
1616-
1617 \sa setFont(), QFont::setHintingPreference()-
1618*/-
1619-
1620/*!-
1621 \since 4.8-
1622-
1623 \fn QFont::HintingPreference QTextCharFormat::fontHintingPreference() const-
1624-
1625 Returns the hinting preference set for this text format.-
1626-
1627 \sa font(), QFont::hintingPreference()-
1628*/-
1629-
1630/*!-
1631 \fn QPen QTextCharFormat::textOutline() const-
1632-
1633 Returns the pen used to draw the outlines of characters in this format.-
1634*/-
1635-
1636-
1637/*!-
1638 \fn void QTextCharFormat::setTextOutline(const QPen &pen)-
1639-
1640 Sets the pen used to draw the outlines of characters to the given \a pen.-
1641*/-
1642-
1643/*!-
1644 \fn void QTextCharFormat::setToolTip(const QString &text)-
1645 \since 4.3-
1646-
1647 Sets the tool tip for a fragment of text to the given \a text.-
1648*/-
1649-
1650/*!-
1651 \fn QString QTextCharFormat::toolTip() const-
1652 \since 4.3-
1653-
1654 Returns the tool tip that is displayed for a fragment of text.-
1655*/-
1656-
1657/*!-
1658 \fn void QTextFormat::setForeground(const QBrush &brush)-
1659-
1660 Sets the foreground brush to the specified \a brush. The foreground-
1661 brush is mostly used to render text.-
1662-
1663 \sa foreground(), clearForeground(), setBackground()-
1664*/-
1665-
1666-
1667/*!-
1668 \fn QBrush QTextFormat::foreground() const-
1669-
1670 Returns the brush used to render foreground details, such as text,-
1671 frame outlines, and table borders.-
1672-
1673 \sa setForeground(), clearForeground(), background()-
1674*/-
1675-
1676/*!-
1677 \fn void QTextFormat::clearForeground()-
1678-
1679 Clears the brush used to paint the document's foreground. The default-
1680 brush will be used.-
1681-
1682 \sa foreground(), setForeground(), clearBackground()-
1683*/-
1684-
1685-
1686/*!-
1687 \fn void QTextCharFormat::setAnchor(bool anchor)-
1688-
1689 If \a anchor is true, text with this format represents an anchor, and is-
1690 formatted in the appropriate way; otherwise the text is formatted normally.-
1691 (Anchors are hyperlinks which are often shown underlined and in a different-
1692 color from plain text.)-
1693-
1694 The way the text is rendered is independent of whether or not the format-
1695 has a valid anchor defined. Use setAnchorHref(), and optionally-
1696 setAnchorNames() to create a hypertext link.-
1697-
1698 \sa isAnchor()-
1699*/-
1700-
1701-
1702/*!-
1703 \fn bool QTextCharFormat::isAnchor() const-
1704-
1705 Returns \c true if the text is formatted as an anchor; otherwise-
1706 returns \c false.-
1707-
1708 \sa setAnchor(), setAnchorHref(), setAnchorNames()-
1709*/-
1710-
1711-
1712/*!-
1713 \fn void QTextCharFormat::setAnchorHref(const QString &value)-
1714-
1715 Sets the hypertext link for the text format to the given \a value.-
1716 This is typically a URL like "http://example.com/index.html".-
1717-
1718 The anchor will be displayed with the \a value as its display text;-
1719 if you want to display different text call setAnchorNames().-
1720-
1721 To format the text as a hypertext link use setAnchor().-
1722*/-
1723-
1724-
1725/*!-
1726 \fn QString QTextCharFormat::anchorHref() const-
1727-
1728 Returns the text format's hypertext link, or an empty string if-
1729 none has been set.-
1730*/-
1731-
1732-
1733/*!-
1734 \fn void QTextCharFormat::setAnchorName(const QString &name)-
1735 \obsolete-
1736-
1737 This function is deprecated. Use setAnchorNames() instead.-
1738-
1739 Sets the text format's anchor \a name. For the anchor to work as a-
1740 hyperlink, the destination must be set with setAnchorHref() and-
1741 the anchor must be enabled with setAnchor().-
1742*/-
1743-
1744/*!-
1745 \fn void QTextCharFormat::setAnchorNames(const QStringList &names)-
1746 \since 4.3-
1747-
1748 Sets the text format's anchor \a names. For the anchor to work as a-
1749 hyperlink, the destination must be set with setAnchorHref() and-
1750 the anchor must be enabled with setAnchor().-
1751*/-
1752-
1753/*!-
1754 \fn QString QTextCharFormat::anchorName() const-
1755 \obsolete-
1756-
1757 This function is deprecated. Use anchorNames() instead.-
1758-
1759 Returns the anchor name associated with this text format, or an empty-
1760 string if none has been set. If the anchor name is set, text with this-
1761 format can be the destination of a hypertext link.-
1762*/-
1763QString QTextCharFormat::anchorName() const-
1764{-
1765 QVariant prop = property(AnchorName);-
1766 if (prop.userType() == QVariant::StringList)
prop.userType(...nt::StringListDescription
TRUEnever evaluated
FALSEnever evaluated
0
1767 return prop.toStringList().value(0);
never executed: return prop.toStringList().value(0);
0
1768 else if (prop.userType() != QVariant::String)
prop.userType(...ariant::StringDescription
TRUEnever evaluated
FALSEnever evaluated
0
1769 return QString();
never executed: return QString();
0
1770 return prop.toString();
never executed: return prop.toString();
0
1771}-
1772-
1773/*!-
1774 \fn QStringList QTextCharFormat::anchorNames() const-
1775 \since 4.3-
1776-
1777 Returns the anchor names associated with this text format, or an empty-
1778 string list if none has been set. If the anchor names are set, text with this-
1779 format can be the destination of a hypertext link.-
1780*/-
1781QStringList QTextCharFormat::anchorNames() const-
1782{-
1783 QVariant prop = property(AnchorName);-
1784 if (prop.userType() == QVariant::StringList)
prop.userType(...nt::StringListDescription
TRUEnever evaluated
FALSEnever evaluated
0
1785 return prop.toStringList();
never executed: return prop.toStringList();
0
1786 else if (prop.userType() != QVariant::String)
prop.userType(...ariant::StringDescription
TRUEnever evaluated
FALSEnever evaluated
0
1787 return QStringList();
never executed: return QStringList();
0
1788 return QStringList(prop.toString());
never executed: return QStringList(prop.toString());
0
1789}-
1790-
1791-
1792/*!-
1793 \fn void QTextCharFormat::setTableCellRowSpan(int tableCellRowSpan)-
1794 \internal-
1795-
1796 If this character format is applied to characters in a table cell,-
1797 the cell will span \a tableCellRowSpan rows.-
1798*/-
1799-
1800-
1801/*!-
1802 \fn int QTextCharFormat::tableCellRowSpan() const-
1803 \internal-
1804-
1805 If this character format is applied to characters in a table cell,-
1806 this function returns the number of rows spanned by the text (this may-
1807 be 1); otherwise it returns 1.-
1808*/-
1809-
1810/*!-
1811 \fn void QTextCharFormat::setTableCellColumnSpan(int tableCellColumnSpan)-
1812 \internal-
1813-
1814 If this character format is applied to characters in a table cell,-
1815 the cell will span \a tableCellColumnSpan columns.-
1816*/-
1817-
1818-
1819/*!-
1820 \fn int QTextCharFormat::tableCellColumnSpan() const-
1821 \internal-
1822-
1823 If this character format is applied to characters in a table cell,-
1824 this function returns the number of columns spanned by the text (this-
1825 may be 1); otherwise it returns 1.-
1826*/-
1827-
1828/*!-
1829 \fn void QTextCharFormat::setUnderlineColor(const QColor &color)-
1830-
1831 Sets the underline color used for the characters with this format to-
1832 the \a color specified.-
1833-
1834 \sa underlineColor()-
1835*/-
1836-
1837/*!-
1838 \fn QColor QTextCharFormat::underlineColor() const-
1839-
1840 Returns the color used to underline the characters with this format.-
1841-
1842 \sa setUnderlineColor()-
1843*/-
1844-
1845/*!-
1846 \fn void QTextCharFormat::setVerticalAlignment(VerticalAlignment alignment)-
1847-
1848 Sets the vertical alignment used for the characters with this format to-
1849 the \a alignment specified.-
1850-
1851 \sa verticalAlignment()-
1852*/-
1853-
1854/*!-
1855 \fn VerticalAlignment QTextCharFormat::verticalAlignment() const-
1856-
1857 Returns the vertical alignment used for characters with this format.-
1858-
1859 \sa setVerticalAlignment()-
1860*/-
1861-
1862/*!-
1863 \enum QTextCharFormat::FontPropertiesInheritanceBehavior-
1864 \since 5.3-
1865-
1866 This enum specifies how the setFont() function should behave with-
1867 respect to unset font properties.-
1868-
1869 \value FontPropertiesSpecifiedOnly If a property is not explicitly set, do not-
1870 change the text format's property value.-
1871 \value FontPropertiesAll If a property is not explicitly set, override the-
1872 text format's property with a default value.-
1873-
1874 \sa setFont()-
1875*/-
1876-
1877/*!-
1878 \overload-
1879-
1880 Sets the text format's \a font.-
1881-
1882 \sa font()-
1883*/-
1884void QTextCharFormat::setFont(const QFont &font)-
1885{-
1886 setFont(font, FontPropertiesAll);-
1887}
never executed: end of block
0
1888-
1889/*!-
1890 \since 5.3-
1891-
1892 Sets the text format's \a font.-
1893-
1894 If \a behavior is QTextCharFormat::FontPropertiesAll, the font property that-
1895 has not been explicitly set is treated like as it were set with default value;-
1896 If \a behavior is QTextCharFormat::FontPropertiesSpecifiedOnly, the font property that-
1897 has not been explicitly set is ignored and the respective property value-
1898 remains unchanged.-
1899-
1900 \sa font()-
1901*/-
1902void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior)-
1903{-
1904 const uint mask = behavior == FontPropertiesAll ? uint(QFont::AllPropertiesResolved)
behavior == FontPropertiesAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
1905 : font.resolve();-
1906-
1907 if (mask & QFont::FamilyResolved)
mask & QFont::FamilyResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1908 setFontFamily(font.family());
never executed: setFontFamily(font.family());
0
1909 if (mask & QFont::SizeResolved) {
mask & QFont::SizeResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1910 const qreal pointSize = font.pointSizeF();-
1911 if (pointSize > 0) {
pointSize > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1912 setFontPointSize(pointSize);-
1913 } else {
never executed: end of block
0
1914 const int pixelSize = font.pixelSize();-
1915 if (pixelSize > 0)
pixelSize > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1916 setProperty(QTextFormat::FontPixelSize, pixelSize);
never executed: setProperty(QTextFormat::FontPixelSize, pixelSize);
0
1917 }
never executed: end of block
0
1918 }-
1919-
1920 if (mask & QFont::WeightResolved)
mask & QFont::WeightResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1921 setFontWeight(font.weight());
never executed: setFontWeight(font.weight());
0
1922 if (mask & QFont::StyleResolved)
mask & QFont::StyleResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1923 setFontItalic(font.style() != QFont::StyleNormal);
never executed: setFontItalic(font.style() != QFont::StyleNormal);
0
1924 if (mask & QFont::UnderlineResolved)
mask & QFont::...erlineResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1925 setUnderlineStyle(font.underline() ? SingleUnderline : NoUnderline);
never executed: setUnderlineStyle(font.underline() ? SingleUnderline : NoUnderline);
0
1926 if (mask & QFont::OverlineResolved)
mask & QFont::OverlineResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1927 setFontOverline(font.overline());
never executed: setFontOverline(font.overline());
0
1928 if (mask & QFont::StrikeOutResolved)
mask & QFont::...ikeOutResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1929 setFontStrikeOut(font.strikeOut());
never executed: setFontStrikeOut(font.strikeOut());
0
1930 if (mask & QFont::FixedPitchResolved)
mask & QFont::...dPitchResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1931 setFontFixedPitch(font.fixedPitch());
never executed: setFontFixedPitch(font.fixedPitch());
0
1932 if (mask & QFont::CapitalizationResolved)
mask & QFont::...zationResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1933 setFontCapitalization(font.capitalization());
never executed: setFontCapitalization(font.capitalization());
0
1934 if (mask & QFont::WordSpacingResolved)
mask & QFont::...pacingResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1935 setFontWordSpacing(font.wordSpacing());
never executed: setFontWordSpacing(font.wordSpacing());
0
1936 if (mask & QFont::LetterSpacingResolved) {
mask & QFont::...pacingResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1937 setFontLetterSpacingType(font.letterSpacingType());-
1938 setFontLetterSpacing(font.letterSpacing());-
1939 }
never executed: end of block
0
1940 if (mask & QFont::StretchResolved)
mask & QFont::StretchResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1941 setFontStretch(font.stretch());
never executed: setFontStretch(font.stretch());
0
1942 if (mask & QFont::StyleHintResolved)
mask & QFont::...leHintResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1943 setFontStyleHint(font.styleHint());
never executed: setFontStyleHint(font.styleHint());
0
1944 if (mask & QFont::StyleStrategyResolved)
mask & QFont::...rategyResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1945 setFontStyleStrategy(font.styleStrategy());
never executed: setFontStyleStrategy(font.styleStrategy());
0
1946 if (mask & QFont::HintingPreferenceResolved)
mask & QFont::...erenceResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1947 setFontHintingPreference(font.hintingPreference());
never executed: setFontHintingPreference(font.hintingPreference());
0
1948 if (mask & QFont::KerningResolved)
mask & QFont::KerningResolvedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1949 setFontKerning(font.kerning());
never executed: setFontKerning(font.kerning());
0
1950}
never executed: end of block
0
1951-
1952/*!-
1953 Returns the font for this character format.-
1954*/-
1955QFont QTextCharFormat::font() const-
1956{-
1957 return d ? d->font() : QFont();
never executed: return d ? d->font() : QFont();
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1958}-
1959-
1960/*!-
1961 \class QTextBlockFormat-
1962 \reentrant-
1963-
1964 \brief The QTextBlockFormat class provides formatting information for-
1965 blocks of text in a QTextDocument.-
1966 \inmodule QtGui-
1967-
1968 \ingroup richtext-processing-
1969 \ingroup shared-
1970-
1971 A document is composed of a list of blocks, represented by QTextBlock-
1972 objects. Each block can contain an item of some kind, such as a-
1973 paragraph of text, a table, a list, or an image. Every block has an-
1974 associated QTextBlockFormat that specifies its characteristics.-
1975-
1976 To cater for left-to-right and right-to-left languages you can set-
1977 a block's direction with setDirection(). Paragraph alignment is-
1978 set with setAlignment(). Margins are controlled by setTopMargin(),-
1979 setBottomMargin(), setLeftMargin(), setRightMargin(). Overall-
1980 indentation is set with setIndent(), the indentation of the first-
1981 line with setTextIndent().-
1982-
1983 Line spacing is set with setLineHeight() and retrieved via lineHeight()-
1984 and lineHeightType(). The types of line spacing available are in the-
1985 LineHeightTypes enum.-
1986-
1987 Line breaking can be enabled and disabled with setNonBreakableLines().-
1988-
1989 The brush used to paint the paragraph's background-
1990 is set with \l{QTextFormat::setBackground()}{setBackground()}, and other-
1991 aspects of the text's appearance can be customized by using the-
1992 \l{QTextFormat::setProperty()}{setProperty()} function with the-
1993 \c OutlinePen, \c ForegroundBrush, and \c BackgroundBrush-
1994 \l{QTextFormat::Property} values.-
1995-
1996 If a text block is part of a list, it can also have a list format that-
1997 is accessible with the listFormat() function.-
1998-
1999 \sa QTextBlock, QTextCharFormat-
2000*/-
2001-
2002/*!-
2003 \since 4.8-
2004 \enum QTextBlockFormat::LineHeightTypes-
2005-
2006 This enum describes the various types of line spacing support paragraphs can have.-
2007-
2008 \value SingleHeight This is the default line height: single spacing.-
2009 \value ProportionalHeight This sets the spacing proportional to the line (in percentage).-
2010 For example, set to 200 for double spacing.-
2011 \value FixedHeight This sets the line height to a fixed line height (in pixels).-
2012 \value MinimumHeight This sets the minimum line height (in pixels).-
2013 \value LineDistanceHeight This adds the specified height between lines (in pixels).-
2014-
2015 \sa lineHeight(), lineHeightType(), setLineHeight()-
2016*/-
2017-
2018/*!-
2019 \fn QTextBlockFormat::QTextBlockFormat()-
2020-
2021 Constructs a new QTextBlockFormat.-
2022*/-
2023QTextBlockFormat::QTextBlockFormat() : QTextFormat(BlockFormat) {}
never executed: end of block
0
2024-
2025/*!-
2026 \internal-
2027 \fn QTextBlockFormat::QTextBlockFormat(const QTextFormat &other)-
2028-
2029 Creates a new block format with the same attributes as the \a given-
2030 text format.-
2031*/-
2032QTextBlockFormat::QTextBlockFormat(const QTextFormat &fmt)-
2033 : QTextFormat(fmt)-
2034{-
2035}
never executed: end of block
0
2036-
2037/*!-
2038 \since 4.4-
2039 Sets the tab positions for the text block to those specified by-
2040 \a tabs.-
2041-
2042 \sa tabPositions()-
2043*/-
2044void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs)-
2045{-
2046 QList<QVariant> list;-
2047 list.reserve(tabs.count());-
2048 QList<QTextOption::Tab>::ConstIterator iter = tabs.constBegin();-
2049 while (iter != tabs.constEnd()) {
iter != tabs.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
2050 QVariant v;-
2051 v.setValue<QTextOption::Tab>(*iter);-
2052 list.append(v);-
2053 ++iter;-
2054 }
never executed: end of block
0
2055 setProperty(TabPositions, list);-
2056}
never executed: end of block
0
2057-
2058/*!-
2059 \since 4.4-
2060 Returns a list of tab positions defined for the text block.-
2061-
2062 \sa setTabPositions()-
2063*/-
2064QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const-
2065{-
2066 QVariant variant = property(TabPositions);-
2067 if(variant.isNull())
variant.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2068 return QList<QTextOption::Tab>();
never executed: return QList<QTextOption::Tab>();
0
2069 QList<QTextOption::Tab> answer;-
2070 QList<QVariant> variantsList = qvariant_cast<QList<QVariant> >(variant);-
2071 QList<QVariant>::Iterator iter = variantsList.begin();-
2072 answer.reserve(variantsList.count());-
2073 while(iter != variantsList.end()) {
iter != variantsList.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
2074 answer.append( qvariant_cast<QTextOption::Tab>(*iter));-
2075 ++iter;-
2076 }
never executed: end of block
0
2077 return answer;
never executed: return answer;
0
2078}-
2079-
2080/*!-
2081 \fn QTextBlockFormat::isValid() const-
2082-
2083 Returns \c true if this block format is valid; otherwise returns-
2084 false.-
2085*/-
2086-
2087/*!-
2088 \fn void QTextFormat::setLayoutDirection(Qt::LayoutDirection direction)-
2089-
2090 Sets the document's layout direction to the specified \a direction.-
2091-
2092 \sa layoutDirection()-
2093*/-
2094-
2095-
2096/*!-
2097 \fn Qt::LayoutDirection QTextFormat::layoutDirection() const-
2098-
2099 Returns the document's layout direction.-
2100-
2101 \sa setLayoutDirection()-
2102*/-
2103-
2104-
2105/*!-
2106 \fn void QTextBlockFormat::setAlignment(Qt::Alignment alignment)-
2107-
2108 Sets the paragraph's \a alignment.-
2109-
2110 \sa alignment()-
2111*/-
2112-
2113-
2114/*!-
2115 \fn Qt::Alignment QTextBlockFormat::alignment() const-
2116-
2117 Returns the paragraph's alignment.-
2118-
2119 \sa setAlignment()-
2120*/-
2121-
2122-
2123/*!-
2124 \fn void QTextBlockFormat::setTopMargin(qreal margin)-
2125-
2126 Sets the paragraph's top \a margin.-
2127-
2128 \sa topMargin(), setBottomMargin(), setLeftMargin(), setRightMargin()-
2129*/-
2130-
2131-
2132/*!-
2133 \fn qreal QTextBlockFormat::topMargin() const-
2134-
2135 Returns the paragraph's top margin.-
2136-
2137 \sa setTopMargin(), bottomMargin()-
2138*/-
2139-
2140-
2141/*!-
2142 \fn void QTextBlockFormat::setBottomMargin(qreal margin)-
2143-
2144 Sets the paragraph's bottom \a margin.-
2145-
2146 \sa bottomMargin(), setTopMargin(), setLeftMargin(), setRightMargin()-
2147*/-
2148-
2149-
2150/*!-
2151 \fn qreal QTextBlockFormat::bottomMargin() const-
2152-
2153 Returns the paragraph's bottom margin.-
2154-
2155 \sa setBottomMargin(), topMargin()-
2156*/-
2157-
2158-
2159/*!-
2160 \fn void QTextBlockFormat::setLeftMargin(qreal margin)-
2161-
2162 Sets the paragraph's left \a margin. Indentation can be applied separately-
2163 with setIndent().-
2164-
2165 \sa leftMargin(), setRightMargin(), setTopMargin(), setBottomMargin()-
2166*/-
2167-
2168-
2169/*!-
2170 \fn qreal QTextBlockFormat::leftMargin() const-
2171-
2172 Returns the paragraph's left margin.-
2173-
2174 \sa setLeftMargin(), rightMargin(), indent()-
2175*/-
2176-
2177-
2178/*!-
2179 \fn void QTextBlockFormat::setRightMargin(qreal margin)-
2180-
2181 Sets the paragraph's right \a margin.-
2182-
2183 \sa rightMargin(), setLeftMargin(), setTopMargin(), setBottomMargin()-
2184*/-
2185-
2186-
2187/*!-
2188 \fn qreal QTextBlockFormat::rightMargin() const-
2189-
2190 Returns the paragraph's right margin.-
2191-
2192 \sa setRightMargin(), leftMargin()-
2193*/-
2194-
2195-
2196/*!-
2197 \fn void QTextBlockFormat::setTextIndent(qreal indent)-
2198-
2199 Sets the \a indent for the first line in the block. This allows the first-
2200 line of a paragraph to be indented differently to the other lines,-
2201 enhancing the readability of the text.-
2202-
2203 \sa textIndent(), setLeftMargin(), setRightMargin(), setTopMargin(), setBottomMargin()-
2204*/-
2205-
2206-
2207/*!-
2208 \fn qreal QTextBlockFormat::textIndent() const-
2209-
2210 Returns the paragraph's text indent.-
2211-
2212 \sa setTextIndent()-
2213*/-
2214-
2215-
2216/*!-
2217 \fn void QTextBlockFormat::setIndent(int indentation)-
2218-
2219 Sets the paragraph's \a indentation. Margins are set independently of-
2220 indentation with setLeftMargin() and setTextIndent().-
2221 The \a indentation is an integer that is multiplied with the document-wide-
2222 standard indent, resulting in the actual indent of the paragraph.-
2223-
2224 \sa indent(), QTextDocument::indentWidth()-
2225*/-
2226-
2227-
2228/*!-
2229 \fn int QTextBlockFormat::indent() const-
2230-
2231 Returns the paragraph's indent.-
2232-
2233 \sa setIndent()-
2234*/-
2235-
2236-
2237/*!-
2238 \fn void QTextBlockFormat::setLineHeight(qreal height, int heightType)-
2239 \since 4.8-
2240-
2241 Sets the line height for the paragraph to the value given by \a height-
2242 which is dependent on \a heightType in the way described by the-
2243 LineHeightTypes enum.-
2244-
2245 \sa LineHeightTypes, lineHeight(), lineHeightType()-
2246*/-
2247-
2248-
2249/*!-
2250 \fn qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling) const-
2251 \since 4.8-
2252-
2253 Returns the height of the lines in the paragraph based on the height of the-
2254 script line given by \a scriptLineHeight and the specified \a scaling-
2255 factor.-
2256-
2257 The value that is returned is also dependent on the given LineHeightType of-
2258 the paragraph as well as the LineHeight setting that has been set for the-
2259 paragraph.-
2260-
2261 The scaling is needed for heights that include a fixed number of pixels, to-
2262 scale them appropriately for printing.-
2263-
2264 \sa LineHeightTypes, setLineHeight(), lineHeightType()-
2265*/-
2266-
2267-
2268/*!-
2269 \fn qreal QTextBlockFormat::lineHeight() const-
2270 \since 4.8-
2271-
2272 This returns the LineHeight property for the paragraph.-
2273-
2274 \sa LineHeightTypes, setLineHeight(), lineHeightType()-
2275*/-
2276-
2277-
2278/*!-
2279 \fn qreal QTextBlockFormat::lineHeightType() const-
2280 \since 4.8-
2281-
2282 This returns the LineHeightType property of the paragraph.-
2283-
2284 \sa LineHeightTypes, setLineHeight(), lineHeight()-
2285*/-
2286-
2287-
2288/*!-
2289 \fn void QTextBlockFormat::setNonBreakableLines(bool b)-
2290-
2291 If \a b is true, the lines in the paragraph are treated as-
2292 non-breakable; otherwise they are breakable.-
2293-
2294 \sa nonBreakableLines()-
2295*/-
2296-
2297-
2298/*!-
2299 \fn bool QTextBlockFormat::nonBreakableLines() const-
2300-
2301 Returns \c true if the lines in the paragraph are non-breakable;-
2302 otherwise returns \c false.-
2303-
2304 \sa setNonBreakableLines()-
2305*/-
2306-
2307/*!-
2308 \fn QTextFormat::PageBreakFlags QTextBlockFormat::pageBreakPolicy() const-
2309 \since 4.2-
2310-
2311 Returns the currently set page break policy for the paragraph. The default is-
2312 QTextFormat::PageBreak_Auto.-
2313-
2314 \sa setPageBreakPolicy()-
2315*/-
2316-
2317/*!-
2318 \fn void QTextBlockFormat::setPageBreakPolicy(PageBreakFlags policy)-
2319 \since 4.2-
2320-
2321 Sets the page break policy for the paragraph to \a policy.-
2322-
2323 \sa pageBreakPolicy()-
2324*/-
2325-
2326/*!-
2327 \class QTextListFormat-
2328 \reentrant-
2329-
2330 \brief The QTextListFormat class provides formatting information for-
2331 lists in a QTextDocument.-
2332 \inmodule QtGui-
2333-
2334 \ingroup richtext-processing-
2335 \ingroup shared-
2336-
2337 A list is composed of one or more items, represented as text blocks.-
2338 The list's format specifies the appearance of items in the list.-
2339 In particular, it determines the indentation and the style of each item.-
2340-
2341 The indentation of the items is an integer value that causes each item to-
2342 be offset from the left margin by a certain amount. This value is read with-
2343 indent() and set with setIndent().-
2344-
2345 The style used to decorate each item is set with setStyle() and can be read-
2346 with the style() function. The style controls the type of bullet points and-
2347 numbering scheme used for items in the list. Note that lists that use the-
2348 decimal numbering scheme begin counting at 1 rather than 0.-
2349-
2350 Style properties can be set to further configure the appearance of list-
2351 items; for example, the ListNumberPrefix and ListNumberSuffix properties-
2352 can be used to customize the numbers used in an ordered list so that they-
2353 appear as (1), (2), (3), etc.:-
2354-
2355 \snippet textdocument-listitemstyles/mainwindow.cpp add a styled, ordered list-
2356-
2357 \sa QTextList-
2358*/-
2359-
2360/*!-
2361 \enum QTextListFormat::Style-
2362-
2363 This enum describes the symbols used to decorate list items:-
2364-
2365 \value ListDisc a filled circle-
2366 \value ListCircle an empty circle-
2367 \value ListSquare a filled square-
2368 \value ListDecimal decimal values in ascending order-
2369 \value ListLowerAlpha lower case Latin characters in alphabetical order-
2370 \value ListUpperAlpha upper case Latin characters in alphabetical order-
2371 \value ListLowerRoman lower case roman numerals (supports up to 4999 items only)-
2372 \value ListUpperRoman upper case roman numerals (supports up to 4999 items only)-
2373 \omitvalue ListStyleUndefined-
2374*/-
2375-
2376/*!-
2377 \fn QTextListFormat::QTextListFormat()-
2378-
2379 Constructs a new list format object.-
2380*/-
2381QTextListFormat::QTextListFormat()-
2382 : QTextFormat(ListFormat)-
2383{-
2384 setIndent(1);-
2385}
never executed: end of block
0
2386-
2387/*!-
2388 \internal-
2389 \fn QTextListFormat::QTextListFormat(const QTextFormat &other)-
2390-
2391 Creates a new list format with the same attributes as the \a given-
2392 text format.-
2393*/-
2394QTextListFormat::QTextListFormat(const QTextFormat &fmt)-
2395 : QTextFormat(fmt)-
2396{-
2397}
never executed: end of block
0
2398-
2399/*!-
2400 \fn bool QTextListFormat::isValid() const-
2401-
2402 Returns \c true if this list format is valid; otherwise-
2403 returns \c false.-
2404*/-
2405-
2406/*!-
2407 \fn void QTextListFormat::setStyle(Style style)-
2408-
2409 Sets the list format's \a style.-
2410-
2411 \sa style(), Style-
2412*/-
2413-
2414/*!-
2415 \fn Style QTextListFormat::style() const-
2416-
2417 Returns the list format's style.-
2418-
2419 \sa setStyle(), Style-
2420*/-
2421-
2422-
2423/*!-
2424 \fn void QTextListFormat::setIndent(int indentation)-
2425-
2426 Sets the list format's \a indentation.-
2427 The indentation is multiplied by the QTextDocument::indentWidth-
2428 property to get the effective indent in pixels.-
2429-
2430 \sa indent()-
2431*/-
2432-
2433-
2434/*!-
2435 \fn int QTextListFormat::indent() const-
2436-
2437 Returns the list format's indentation.-
2438 The indentation is multiplied by the QTextDocument::indentWidth-
2439 property to get the effective indent in pixels.-
2440-
2441 \sa setIndent()-
2442*/-
2443-
2444/*!-
2445 \fn void QTextListFormat::setNumberPrefix(const QString &numberPrefix)-
2446 \since 4.8-
2447-
2448 Sets the list format's number prefix to the string specified by-
2449 \a numberPrefix. This can be used with all sorted list types. It does not-
2450 have any effect on unsorted list types.-
2451-
2452 The default prefix is an empty string.-
2453-
2454 \sa numberPrefix()-
2455*/-
2456-
2457/*!-
2458 \fn int QTextListFormat::numberPrefix() const-
2459 \since 4.8-
2460-
2461 Returns the list format's number prefix.-
2462-
2463 \sa setNumberPrefix()-
2464*/-
2465-
2466/*!-
2467 \fn void QTextListFormat::setNumberSuffix(const QString &numberSuffix)-
2468 \since 4.8-
2469-
2470 Sets the list format's number suffix to the string specified by-
2471 \a numberSuffix. This can be used with all sorted list types. It does not-
2472 have any effect on unsorted list types.-
2473-
2474 The default suffix is ".".-
2475-
2476 \sa numberSuffix()-
2477*/-
2478-
2479/*!-
2480 \fn int QTextListFormat::numberSuffix() const-
2481 \since 4.8-
2482-
2483 Returns the list format's number suffix.-
2484-
2485 \sa setNumberSuffix()-
2486*/-
2487-
2488/*!-
2489 \class QTextFrameFormat-
2490 \reentrant-
2491-
2492 \brief The QTextFrameFormat class provides formatting information for-
2493 frames in a QTextDocument.-
2494 \inmodule QtGui-
2495-
2496 \ingroup richtext-processing-
2497 \ingroup shared-
2498-
2499 A text frame groups together one or more blocks of text, providing a layer-
2500 of structure larger than the paragraph. The format of a frame specifies-
2501 how it is rendered and positioned on the screen. It does not directly-
2502 specify the behavior of the text formatting within, but provides-
2503 constraints on the layout of its children.-
2504-
2505 The frame format defines the width() and height() of the frame on the-
2506 screen. Each frame can have a border() that surrounds its contents with-
2507 a rectangular box. The border is surrounded by a margin() around the frame,-
2508 and the contents of the frame are kept separate from the border by the-
2509 frame's padding(). This scheme is similar to the box model used by Cascading-
2510 Style Sheets for HTML pages.-
2511-
2512 \image qtextframe-style.png-
2513-
2514 The position() of a frame is set using setPosition() and determines how it-
2515 is located relative to the surrounding text.-
2516-
2517 The validity of a QTextFrameFormat object can be determined with the-
2518 isValid() function.-
2519-
2520 \sa QTextFrame, QTextBlockFormat-
2521*/-
2522-
2523/*!-
2524 \enum QTextFrameFormat::Position-
2525-
2526 This enum describes how a frame is located relative to the surrounding text.-
2527-
2528 \value InFlow-
2529 \value FloatLeft-
2530 \value FloatRight-
2531-
2532 \sa position(), CssFloat-
2533*/-
2534-
2535/*!-
2536 \enum QTextFrameFormat::BorderStyle-
2537 \since 4.3-
2538-
2539 This enum describes different border styles for the text frame.-
2540-
2541 \value BorderStyle_None-
2542 \value BorderStyle_Dotted-
2543 \value BorderStyle_Dashed-
2544 \value BorderStyle_Solid-
2545 \value BorderStyle_Double-
2546 \value BorderStyle_DotDash-
2547 \value BorderStyle_DotDotDash-
2548 \value BorderStyle_Groove-
2549 \value BorderStyle_Ridge-
2550 \value BorderStyle_Inset-
2551 \value BorderStyle_Outset-
2552-
2553 \sa borderStyle(), FrameBorderStyle-
2554*/-
2555-
2556/*!-
2557 \fn QTextFrameFormat::QTextFrameFormat()-
2558-
2559 Constructs a text frame format object with the default properties.-
2560*/-
2561QTextFrameFormat::QTextFrameFormat() : QTextFormat(FrameFormat)-
2562{-
2563 setBorderStyle(BorderStyle_Outset);-
2564 setBorderBrush(Qt::darkGray);-
2565}
never executed: end of block
0
2566-
2567/*!-
2568 \internal-
2569 \fn QTextFrameFormat::QTextFrameFormat(const QTextFormat &other)-
2570-
2571 Creates a new frame format with the same attributes as the \a given-
2572 text format.-
2573*/-
2574QTextFrameFormat::QTextFrameFormat(const QTextFormat &fmt)-
2575 : QTextFormat(fmt)-
2576{-
2577}
never executed: end of block
0
2578-
2579/*!-
2580 \fn QTextFrameFormat::isValid() const-
2581-
2582 Returns \c true if the format description is valid; otherwise returns \c false.-
2583*/-
2584-
2585/*!-
2586 \fn QTextFrameFormat::setPosition(Position policy)-
2587-
2588 Sets the \a policy for positioning frames with this frame format.-
2589-
2590*/-
2591-
2592/*!-
2593 \fn Position QTextFrameFormat::position() const-
2594-
2595 Returns the positioning policy for frames with this frame format.-
2596*/-
2597-
2598/*!-
2599 \fn QTextFrameFormat::setBorder(qreal width)-
2600-
2601 Sets the \a width (in pixels) of the frame's border.-
2602*/-
2603-
2604/*!-
2605 \fn qreal QTextFrameFormat::border() const-
2606-
2607 Returns the width of the border in pixels.-
2608*/-
2609-
2610/*!-
2611 \fn QTextFrameFormat::setBorderBrush(const QBrush &brush)-
2612 \since 4.3-
2613-
2614 Sets the \a brush used for the frame's border.-
2615*/-
2616-
2617/*!-
2618 \fn QBrush QTextFrameFormat::borderBrush() const-
2619 \since 4.3-
2620-
2621 Returns the brush used for the frame's border.-
2622*/-
2623-
2624/*!-
2625 \fn QTextFrameFormat::setBorderStyle(BorderStyle style)-
2626 \since 4.3-
2627-
2628 Sets the \a style of the frame's border.-
2629*/-
2630-
2631/*!-
2632 \fn BorderStyle QTextFrameFormat::borderStyle() const-
2633 \since 4.3-
2634-
2635 Returns the style of the frame's border.-
2636*/-
2637-
2638/*!-
2639 \fn QTextFrameFormat::setMargin(qreal margin)-
2640-
2641 Sets the frame's \a margin in pixels.-
2642 This method also sets the left, right, top and bottom margins-
2643 of the frame to the same value. The individual margins override-
2644 the general margin.-
2645*/-
2646void QTextFrameFormat::setMargin(qreal amargin)-
2647{-
2648 setProperty(FrameMargin, amargin);-
2649 setProperty(FrameTopMargin, amargin);-
2650 setProperty(FrameBottomMargin, amargin);-
2651 setProperty(FrameLeftMargin, amargin);-
2652 setProperty(FrameRightMargin, amargin);-
2653}
never executed: end of block
0
2654-
2655-
2656/*!-
2657 \fn qreal QTextFrameFormat::margin() const-
2658-
2659 Returns the width of the frame's external margin in pixels.-
2660*/-
2661-
2662/*!-
2663 \fn QTextFrameFormat::setTopMargin(qreal margin)-
2664 \since 4.3-
2665-
2666 Sets the frame's top \a margin in pixels.-
2667*/-
2668-
2669/*!-
2670 \fn qreal QTextFrameFormat::topMargin() const-
2671 \since 4.3-
2672-
2673 Returns the width of the frame's top margin in pixels.-
2674*/-
2675qreal QTextFrameFormat::topMargin() const-
2676{-
2677 if (!hasProperty(FrameTopMargin))
!hasProperty(FrameTopMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
2678 return margin();
never executed: return margin();
0
2679 return doubleProperty(FrameTopMargin);
never executed: return doubleProperty(FrameTopMargin);
0
2680}-
2681-
2682/*!-
2683 \fn QTextFrameFormat::setBottomMargin(qreal margin)-
2684 \since 4.3-
2685-
2686 Sets the frame's bottom \a margin in pixels.-
2687*/-
2688-
2689/*!-
2690 \fn qreal QTextFrameFormat::bottomMargin() const-
2691 \since 4.3-
2692-
2693 Returns the width of the frame's bottom margin in pixels.-
2694*/-
2695qreal QTextFrameFormat::bottomMargin() const-
2696{-
2697 if (!hasProperty(FrameBottomMargin))
!hasProperty(F...eBottomMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
2698 return margin();
never executed: return margin();
0
2699 return doubleProperty(FrameBottomMargin);
never executed: return doubleProperty(FrameBottomMargin);
0
2700}-
2701-
2702/*!-
2703 \fn QTextFrameFormat::setLeftMargin(qreal margin)-
2704 \since 4.3-
2705-
2706 Sets the frame's left \a margin in pixels.-
2707*/-
2708-
2709/*!-
2710 \fn qreal QTextFrameFormat::leftMargin() const-
2711 \since 4.3-
2712-
2713 Returns the width of the frame's left margin in pixels.-
2714*/-
2715qreal QTextFrameFormat::leftMargin() const-
2716{-
2717 if (!hasProperty(FrameLeftMargin))
!hasProperty(FrameLeftMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
2718 return margin();
never executed: return margin();
0
2719 return doubleProperty(FrameLeftMargin);
never executed: return doubleProperty(FrameLeftMargin);
0
2720}-
2721-
2722/*!-
2723 \fn QTextFrameFormat::setRightMargin(qreal margin)-
2724 \since 4.3-
2725-
2726 Sets the frame's right \a margin in pixels.-
2727*/-
2728-
2729/*!-
2730 \fn qreal QTextFrameFormat::rightMargin() const-
2731 \since 4.3-
2732-
2733 Returns the width of the frame's right margin in pixels.-
2734*/-
2735qreal QTextFrameFormat::rightMargin() const-
2736{-
2737 if (!hasProperty(FrameRightMargin))
!hasProperty(FrameRightMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
2738 return margin();
never executed: return margin();
0
2739 return doubleProperty(FrameRightMargin);
never executed: return doubleProperty(FrameRightMargin);
0
2740}-
2741-
2742/*!-
2743 \fn QTextFrameFormat::setPadding(qreal width)-
2744-
2745 Sets the \a width of the frame's internal padding in pixels.-
2746*/-
2747-
2748/*!-
2749 \fn qreal QTextFrameFormat::padding() const-
2750-
2751 Returns the width of the frame's internal padding in pixels.-
2752*/-
2753-
2754/*!-
2755 \fn QTextFrameFormat::setWidth(const QTextLength &width)-
2756-
2757 Sets the frame's border rectangle's \a width.-
2758-
2759 \sa QTextLength-
2760*/-
2761-
2762/*!-
2763 \fn QTextFrameFormat::setWidth(qreal width)-
2764 \overload-
2765-
2766 Convenience method that sets the width of the frame's border-
2767 rectangle's width to the specified fixed \a width.-
2768*/-
2769-
2770/*!-
2771 \fn QTextFormat::PageBreakFlags QTextFrameFormat::pageBreakPolicy() const-
2772 \since 4.2-
2773-
2774 Returns the currently set page break policy for the frame/table. The default is-
2775 QTextFormat::PageBreak_Auto.-
2776-
2777 \sa setPageBreakPolicy()-
2778*/-
2779-
2780/*!-
2781 \fn void QTextFrameFormat::setPageBreakPolicy(PageBreakFlags policy)-
2782 \since 4.2-
2783-
2784 Sets the page break policy for the frame/table to \a policy.-
2785-
2786 \sa pageBreakPolicy()-
2787*/-
2788-
2789/*!-
2790 \fn QTextLength QTextFrameFormat::width() const-
2791-
2792 Returns the width of the frame's border rectangle.-
2793-
2794 \sa QTextLength-
2795*/-
2796-
2797/*!-
2798 \fn void QTextFrameFormat::setHeight(const QTextLength &height)-
2799-
2800 Sets the frame's \a height.-
2801*/-
2802-
2803/*!-
2804 \fn void QTextFrameFormat::setHeight(qreal height)-
2805 \overload-
2806-
2807 Sets the frame's \a height.-
2808*/-
2809-
2810/*!-
2811 \fn qreal QTextFrameFormat::height() const-
2812-
2813 Returns the height of the frame's border rectangle.-
2814*/-
2815-
2816/*!-
2817 \class QTextTableFormat-
2818 \reentrant-
2819-
2820 \brief The QTextTableFormat class provides formatting information for-
2821 tables in a QTextDocument.-
2822 \inmodule QtGui-
2823-
2824 \ingroup richtext-processing-
2825 \ingroup shared-
2826-
2827 A table is a group of cells ordered into rows and columns. Each table-
2828 contains at least one row and one column. Each cell contains a block.-
2829 Tables in rich text documents are formatted using the properties-
2830 defined in this class.-
2831-
2832 Tables are horizontally justified within their parent frame according to the-
2833 table's alignment. This can be read with the alignment() function and set-
2834 with setAlignment().-
2835-
2836 Cells within the table are separated by cell spacing. The number of pixels-
2837 between cells is set with setCellSpacing() and read with cellSpacing().-
2838 The contents of each cell is surrounded by cell padding. The number of pixels-
2839 between each cell edge and its contents is set with setCellPadding() and read-
2840 with cellPadding().-
2841-
2842 \image qtexttableformat-cell.png-
2843-
2844 The table's background color can be read with the background() function,-
2845 and can be specified with setBackground(). The background color of each-
2846 cell can be set independently, and will control the color of the cell within-
2847 the padded area.-
2848-
2849 The table format also provides a way to constrain the widths of the columns-
2850 in the table. Columns can be assigned a fixed width, a variable width, or-
2851 a percentage of the available width (see QTextLength). The columns() function-
2852 returns the number of columns with constraints, and the-
2853 columnWidthConstraints() function returns the constraints defined for the-
2854 table. These quantities can also be set by calling setColumnWidthConstraints()-
2855 with a vector containing new constraints. If no constraints are-
2856 required, clearColumnWidthConstraints() can be used to remove them.-
2857-
2858 \sa QTextTable, QTextTableCell, QTextLength-
2859*/-
2860-
2861/*!-
2862 \fn QTextTableFormat::QTextTableFormat()-
2863-
2864 Constructs a new table format object.-
2865*/-
2866QTextTableFormat::QTextTableFormat()-
2867 : QTextFrameFormat()-
2868{-
2869 setObjectType(TableObject);-
2870 setCellSpacing(2);-
2871 setBorder(1);-
2872}
never executed: end of block
0
2873-
2874/*!-
2875 \internal-
2876 \fn QTextTableFormat::QTextTableFormat(const QTextFormat &other)-
2877-
2878 Creates a new table format with the same attributes as the \a given-
2879 text format.-
2880*/-
2881QTextTableFormat::QTextTableFormat(const QTextFormat &fmt)-
2882 : QTextFrameFormat(fmt)-
2883{-
2884}
never executed: end of block
0
2885-
2886/*!-
2887 \fn bool QTextTableFormat::isValid() const-
2888-
2889 Returns \c true if this table format is valid; otherwise-
2890 returns \c false.-
2891*/-
2892-
2893-
2894/*!-
2895 \fn int QTextTableFormat::columns() const-
2896-
2897 Returns the number of columns specified by the table format.-
2898*/-
2899-
2900-
2901/*!-
2902 \internal-
2903 \fn void QTextTableFormat::setColumns(int columns)-
2904-
2905 Sets the number of \a columns required by the table format.-
2906-
2907 \sa columns()-
2908*/-
2909-
2910/*!-
2911 \fn void QTextTableFormat::clearColumnWidthConstraints()-
2912-
2913 Clears the column width constraints for the table.-
2914-
2915 \sa columnWidthConstraints(), setColumnWidthConstraints()-
2916*/-
2917-
2918/*!-
2919 \fn void QTextTableFormat::setColumnWidthConstraints(const QVector<QTextLength> &constraints)-
2920-
2921 Sets the column width \a constraints for the table.-
2922-
2923 \sa columnWidthConstraints(), clearColumnWidthConstraints()-
2924*/-
2925-
2926/*!-
2927 \fn QVector<QTextLength> QTextTableFormat::columnWidthConstraints() const-
2928-
2929 Returns a list of constraints used by this table format to control the-
2930 appearance of columns in a table.-
2931-
2932 \sa setColumnWidthConstraints()-
2933*/-
2934-
2935/*!-
2936 \fn qreal QTextTableFormat::cellSpacing() const-
2937-
2938 Returns the table's cell spacing. This describes the distance between-
2939 adjacent cells.-
2940*/-
2941-
2942/*!-
2943 \fn void QTextTableFormat::setCellSpacing(qreal spacing)-
2944-
2945 Sets the cell \a spacing for the table. This determines the distance-
2946 between adjacent cells.-
2947*/-
2948-
2949/*!-
2950 \fn qreal QTextTableFormat::cellPadding() const-
2951-
2952 Returns the table's cell padding. This describes the distance between-
2953 the border of a cell and its contents.-
2954*/-
2955-
2956/*!-
2957 \fn void QTextTableFormat::setCellPadding(qreal padding)-
2958-
2959 Sets the cell \a padding for the table. This determines the distance-
2960 between the border of a cell and its contents.-
2961*/-
2962-
2963/*!-
2964 \fn void QTextTableFormat::setAlignment(Qt::Alignment alignment)-
2965-
2966 Sets the table's \a alignment.-
2967-
2968 \sa alignment()-
2969*/-
2970-
2971/*!-
2972 \fn Qt::Alignment QTextTableFormat::alignment() const-
2973-
2974 Returns the table's alignment.-
2975-
2976 \sa setAlignment()-
2977*/-
2978-
2979/*!-
2980 \fn void QTextTableFormat::setHeaderRowCount(int count)-
2981 \since 4.2-
2982-
2983 Declares the first \a count rows of the table as table header.-
2984 The table header rows get repeated when a table is broken-
2985 across a page boundary.-
2986*/-
2987-
2988/*!-
2989 \fn int QTextTableFormat::headerRowCount() const-
2990 \since 4.2-
2991-
2992 Returns the number of rows in the table that define the header.-
2993-
2994 \sa setHeaderRowCount()-
2995*/-
2996-
2997/*!-
2998 \fn void QTextFormat::setBackground(const QBrush &brush)-
2999-
3000 Sets the brush use to paint the document's background to the-
3001 \a brush specified.-
3002-
3003 \sa background(), clearBackground(), setForeground()-
3004*/-
3005-
3006/*!-
3007 \fn QColor QTextFormat::background() const-
3008-
3009 Returns the brush used to paint the document's background.-
3010-
3011 \sa setBackground(), clearBackground(), foreground()-
3012*/-
3013-
3014/*!-
3015 \fn void QTextFormat::clearBackground()-
3016-
3017 Clears the brush used to paint the document's background. The default-
3018 brush will be used.-
3019-
3020 \sa background(), setBackground(), clearForeground()-
3021*/-
3022-
3023-
3024/*!-
3025 \class QTextImageFormat-
3026 \reentrant-
3027-
3028 \brief The QTextImageFormat class provides formatting information for-
3029 images in a QTextDocument.-
3030 \inmodule QtGui-
3031-
3032 \ingroup richtext-processing-
3033 \ingroup shared-
3034-
3035 Inline images are represented by a Unicode value U+FFFC (OBJECT-
3036 REPLACEMENT CHARACTER) which has an associated QTextImageFormat. The-
3037 image format specifies a name with setName() that is used to-
3038 locate the image. The size of the rectangle that the image will-
3039 occupy is specified using setWidth() and setHeight().-
3040-
3041 Images can be supplied in any format for which Qt has an image-
3042 reader, so SVG drawings can be included alongside PNG, TIFF and-
3043 other bitmap formats.-
3044-
3045 \sa QImage, QImageReader-
3046*/-
3047-
3048/*!-
3049 \fn QTextImageFormat::QTextImageFormat()-
3050-
3051 Creates a new image format object.-
3052*/-
3053QTextImageFormat::QTextImageFormat() : QTextCharFormat() { setObjectType(ImageObject); }
never executed: end of block
0
3054-
3055/*!-
3056 \internal-
3057 \fn QTextImageFormat::QTextImageFormat(const QTextFormat &other)-
3058-
3059 Creates a new image format with the same attributes as the \a given-
3060 text format.-
3061*/-
3062QTextImageFormat::QTextImageFormat(const QTextFormat &fmt)-
3063 : QTextCharFormat(fmt)-
3064{-
3065}
never executed: end of block
0
3066-
3067/*!-
3068 \fn bool QTextImageFormat::isValid() const-
3069-
3070 Returns \c true if this image format is valid; otherwise returns \c false.-
3071*/-
3072-
3073-
3074/*!-
3075 \fn void QTextImageFormat::setName(const QString &name)-
3076-
3077 Sets the \a name of the image. The \a name is used to locate the image-
3078 in the application's resources.-
3079-
3080 \sa name()-
3081*/-
3082-
3083-
3084/*!-
3085 \fn QString QTextImageFormat::name() const-
3086-
3087 Returns the name of the image. The name refers to an entry in the-
3088 application's resources file.-
3089-
3090 \sa setName()-
3091*/-
3092-
3093/*!-
3094 \fn void QTextImageFormat::setWidth(qreal width)-
3095-
3096 Sets the \a width of the rectangle occupied by the image.-
3097-
3098 \sa width(), setHeight()-
3099*/-
3100-
3101-
3102/*!-
3103 \fn qreal QTextImageFormat::width() const-
3104-
3105 Returns the width of the rectangle occupied by the image.-
3106-
3107 \sa height(), setWidth()-
3108*/-
3109-
3110-
3111/*!-
3112 \fn void QTextImageFormat::setHeight(qreal height)-
3113-
3114 Sets the \a height of the rectangle occupied by the image.-
3115-
3116 \sa height(), setWidth()-
3117*/-
3118-
3119-
3120/*!-
3121 \fn qreal QTextImageFormat::height() const-
3122-
3123 Returns the height of the rectangle occupied by the image.-
3124-
3125 \sa width(), setHeight()-
3126*/-
3127-
3128/*!-
3129 \fn void QTextCharFormat::setFontCapitalization(QFont::Capitalization capitalization)-
3130 \since 4.4-
3131-
3132 Sets the capitalization of the text that apppears in this font to \a capitalization.-
3133-
3134 A font's capitalization makes the text appear in the selected capitalization mode.-
3135-
3136 \sa fontCapitalization()-
3137*/-
3138-
3139/*!-
3140 \fn Capitalization QTextCharFormat::fontCapitalization() const-
3141 \since 4.4-
3142-
3143 Returns the current capitalization type of the font.-
3144*/-
3145-
3146/*!-
3147 \fn void QTextCharFormat::setFontLetterSpacingType(QFont::SpacingType letterSpacingType)-
3148 \since 5.0-
3149-
3150 Sets the letter spacing type of this format to \a letterSpacingType.-
3151-
3152 \sa fontLetterSpacingType()-
3153 \sa setFontLetterSpacing()-
3154 \sa fontLetterSpacing()-
3155*/-
3156-
3157/*!-
3158 \fn QFont::SpacingType QTextCharFormat::fontLetterSpacingType() const-
3159 \since 5.0-
3160-
3161 Returns the letter spacing type of this format..-
3162-
3163 \sa setFontLetterSpacingType()-
3164 \sa setFontLetterSpacing()-
3165 \sa fontLetterSpacing()-
3166*/-
3167-
3168/*!-
3169 \fn void QTextCharFormat::setFontLetterSpacing(qreal spacing)-
3170 \since 4.4-
3171-
3172 Sets the letter spacing of this format to the given \a spacing. The meaning of the value-
3173 depends on the font letter spacing type.-
3174-
3175 For percentage spacing a value of 100 indicates default spacing; a value of 200 doubles the-
3176 amount of space a letter takes.-
3177-
3178 \sa fontLetterSpacing()-
3179 \sa setFontLetterSpacingType()-
3180 \sa fontLetterSpacingType()-
3181*/-
3182-
3183/*!-
3184 \fn qreal QTextCharFormat::fontLetterSpacing() const-
3185 \since 4.4-
3186-
3187 Returns the current letter spacing.-
3188-
3189 \sa setFontLetterSpacing()-
3190 \sa setFontLetterSpacingType()-
3191 \sa fontLetterSpacingType()-
3192*/-
3193-
3194/*!-
3195 \fn void QTextCharFormat::setFontWordSpacing(qreal spacing)-
3196 \since 4.4-
3197-
3198 Sets the word spacing of this format to the given \a spacing, in pixels.-
3199-
3200 \sa fontWordSpacing()-
3201*/-
3202-
3203/*!-
3204 \fn qreal QTextCharFormat::fontWordSpacing() const-
3205 \since 4.4-
3206-
3207 Returns the current word spacing value.-
3208*/-
3209-
3210/*!-
3211 \fn void QTextCharFormat::setFontStretch(int factor)-
3212 \since 5.0-
3213-
3214 Sets the stretch factor for the font to \a factor.-
3215-
3216 The stretch factor changes the width of all characters in the font by factor percent. For example, setting \a factor to 150 results in all characters in the font being 1.5 times (ie. 150%) wider. The default stretch factor is 100. The minimum stretch factor is 1, and the maximum stretch factor is 4000.-
3217-
3218 The stretch factor is only applied to outline fonts. The stretch factor is ignored for bitmap fonts.-
3219-
3220 \sa fontStretch()-
3221*/-
3222-
3223/*!-
3224 \fn int QTextCharFormat::fontStretch() const-
3225 \since 5.0-
3226-
3227 Returns the current font stretching.-
3228 \sa setFontStretch()-
3229*/-
3230-
3231/*!-
3232 \fn qreal QTextTableCellFormat::topPadding() const-
3233 \since 4.4-
3234-
3235 Gets the top padding of the table cell.-
3236-
3237 \sa setTopPadding(), leftPadding(), rightPadding(), bottomPadding()-
3238*/-
3239-
3240/*!-
3241 \fn qreal QTextTableCellFormat::bottomPadding() const-
3242 \since 4.4-
3243-
3244 Gets the bottom padding of the table cell.-
3245-
3246 \sa setBottomPadding(), leftPadding(), rightPadding(), topPadding()-
3247*/-
3248-
3249/*!-
3250 \fn qreal QTextTableCellFormat::leftPadding() const-
3251 \since 4.4-
3252-
3253 Gets the left padding of the table cell.-
3254-
3255 \sa setLeftPadding(), rightPadding(), topPadding(), bottomPadding()-
3256*/-
3257-
3258/*!-
3259 \fn qreal QTextTableCellFormat::rightPadding() const-
3260 \since 4.4-
3261-
3262 Gets the right padding of the table cell.-
3263-
3264 \sa setRightPadding(), leftPadding(), topPadding(), bottomPadding()-
3265*/-
3266-
3267/*!-
3268 \fn void QTextTableCellFormat::setTopPadding(qreal padding)-
3269 \since 4.4-
3270-
3271 Sets the top \a padding of the table cell.-
3272-
3273 \sa topPadding(), setLeftPadding(), setRightPadding(), setBottomPadding()-
3274*/-
3275-
3276/*!-
3277 \fn void QTextTableCellFormat::setBottomPadding(qreal padding)-
3278 \since 4.4-
3279-
3280 Sets the bottom \a padding of the table cell.-
3281-
3282 \sa bottomPadding(), setLeftPadding(), setRightPadding(), setTopPadding()-
3283*/-
3284-
3285/*!-
3286 \fn void QTextTableCellFormat::setLeftPadding(qreal padding)-
3287 \since 4.4-
3288-
3289 Sets the left \a padding of the table cell.-
3290-
3291 \sa leftPadding(), setRightPadding(), setTopPadding(), setBottomPadding()-
3292*/-
3293-
3294/*!-
3295 \fn void QTextTableCellFormat::setRightPadding(qreal padding)-
3296 \since 4.4-
3297-
3298 Sets the right \a padding of the table cell.-
3299-
3300 \sa rightPadding(), setLeftPadding(), setTopPadding(), setBottomPadding()-
3301*/-
3302-
3303/*!-
3304 \fn void QTextTableCellFormat::setPadding(qreal padding)-
3305 \since 4.4-
3306-
3307 Sets the left, right, top, and bottom \a padding of the table cell.-
3308-
3309 \sa setLeftPadding(), setRightPadding(), setTopPadding(), setBottomPadding()-
3310*/-
3311-
3312/*!-
3313 \fn bool QTextTableCellFormat::isValid() const-
3314 \since 4.4-
3315-
3316 Returns \c true if this table cell format is valid; otherwise returns \c false.-
3317*/-
3318-
3319/*!-
3320 \fn QTextTableCellFormat::QTextTableCellFormat()-
3321 \since 4.4-
3322-
3323 Constructs a new table cell format object.-
3324*/-
3325QTextTableCellFormat::QTextTableCellFormat()-
3326 : QTextCharFormat()-
3327{-
3328 setObjectType(TableCellObject);-
3329}
never executed: end of block
0
3330-
3331/*!-
3332 \internal-
3333 \fn QTextTableCellFormat::QTextTableCellFormat(const QTextFormat &other)-
3334-
3335 Creates a new table cell format with the same attributes as the \a given-
3336 text format.-
3337*/-
3338QTextTableCellFormat::QTextTableCellFormat(const QTextFormat &fmt)-
3339 : QTextCharFormat(fmt)-
3340{-
3341}
never executed: end of block
0
3342-
3343/*!-
3344 \class QTextTableCellFormat-
3345 \reentrant-
3346 \since 4.4-
3347-
3348 \brief The QTextTableCellFormat class provides formatting information for-
3349 table cells in a QTextDocument.-
3350 \inmodule QtGui-
3351-
3352 \ingroup richtext-processing-
3353 \ingroup shared-
3354-
3355 The table cell format of a table cell in a document specifies the visual-
3356 properties of the table cell.-
3357-
3358 The padding properties of a table cell are controlled by setLeftPadding(),-
3359 setRightPadding(), setTopPadding(), and setBottomPadding(). All the paddings-
3360 can be set at once using setPadding().-
3361-
3362 \sa QTextFormat, QTextBlockFormat, QTextTableFormat, QTextCharFormat-
3363*/-
3364-
3365// -------------------------------------------------------
3366-
3367-
3368QTextFormatCollection::QTextFormatCollection(const QTextFormatCollection &rhs)-
3369{-
3370 formats = rhs.formats;-
3371 objFormats = rhs.objFormats;-
3372}
never executed: end of block
0
3373-
3374QTextFormatCollection &QTextFormatCollection::operator=(const QTextFormatCollection &rhs)-
3375{-
3376 formats = rhs.formats;-
3377 objFormats = rhs.objFormats;-
3378 return *this;
never executed: return *this;
0
3379}-
3380-
3381QTextFormatCollection::~QTextFormatCollection()-
3382{-
3383}-
3384-
3385int QTextFormatCollection::indexForFormat(const QTextFormat &format)-
3386{-
3387 uint hash = getHash(format.d, format.format_type);-
3388 QMultiHash<uint, int>::const_iterator i = hashes.constFind(hash);-
3389 while (i != hashes.constEnd() && i.key() == hash) {
i != hashes.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
i.key() == hashDescription
TRUEnever evaluated
FALSEnever evaluated
0
3390 if (formats.value(i.value()) == format) {
formats.value(...e()) == formatDescription
TRUEnever evaluated
FALSEnever evaluated
0
3391 return i.value();
never executed: return i.value();
0
3392 }-
3393 ++i;-
3394 }
never executed: end of block
0
3395-
3396 int idx = formats.size();-
3397 formats.append(format);-
3398-
3399 QT_TRY{-
3400 QTextFormat &f = formats.last();-
3401 if (!f.d)
!f.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3402 f.d = new QTextFormatPrivate;
never executed: f.d = new QTextFormatPrivate;
0
3403 f.d->resolveFont(defaultFnt);-
3404-
3405 if (!hashes.contains(hash, idx))
!hashes.contains(hash, idx)Description
TRUEnever evaluated
FALSEnever evaluated
0
3406 hashes.insert(hash, idx);
never executed: hashes.insert(hash, idx);
0
3407-
3408 } QT_CATCH(...) {
never executed: end of block
dead code: { formats.pop_back(); qt_noop(); }
-
3409 formats.pop_back();
dead code: { formats.pop_back(); qt_noop(); }
-
3410 QT_RETHROW;
dead code: { formats.pop_back(); qt_noop(); }
-
3411 }
dead code: { formats.pop_back(); qt_noop(); }
-
3412 return idx;
never executed: return idx;
0
3413}-
3414-
3415bool QTextFormatCollection::hasFormatCached(const QTextFormat &format) const-
3416{-
3417 uint hash = getHash(format.d, format.format_type);-
3418 QMultiHash<uint, int>::const_iterator i = hashes.constFind(hash);-
3419 while (i != hashes.constEnd() && i.key() == hash) {
i != hashes.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
i.key() == hashDescription
TRUEnever evaluated
FALSEnever evaluated
0
3420 if (formats.value(i.value()) == format) {
formats.value(...e()) == formatDescription
TRUEnever evaluated
FALSEnever evaluated
0
3421 return true;
never executed: return true;
0
3422 }-
3423 ++i;-
3424 }
never executed: end of block
0
3425 return false;
never executed: return false;
0
3426}-
3427-
3428int QTextFormatCollection::objectFormatIndex(int objectIndex) const-
3429{-
3430 if (objectIndex == -1)
objectIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
3431 return -1;
never executed: return -1;
0
3432 return objFormats.at(objectIndex);
never executed: return objFormats.at(objectIndex);
0
3433}-
3434-
3435void QTextFormatCollection::setObjectFormatIndex(int objectIndex, int formatIndex)-
3436{-
3437 objFormats[objectIndex] = formatIndex;-
3438}
never executed: end of block
0
3439-
3440int QTextFormatCollection::createObjectIndex(const QTextFormat &f)-
3441{-
3442 const int objectIndex = objFormats.size();-
3443 objFormats.append(indexForFormat(f));-
3444 return objectIndex;
never executed: return objectIndex;
0
3445}-
3446-
3447QTextFormat QTextFormatCollection::format(int idx) const-
3448{-
3449 if (idx < 0 || idx >= formats.count())
idx < 0Description
TRUEnever evaluated
FALSEnever evaluated
idx >= formats.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
3450 return QTextFormat();
never executed: return QTextFormat();
0
3451-
3452 return formats.at(idx);
never executed: return formats.at(idx);
0
3453}-
3454-
3455void QTextFormatCollection::setDefaultFont(const QFont &f)-
3456{-
3457 defaultFnt = f;-
3458 for (int i = 0; i < formats.count(); ++i)
i < formats.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
3459 if (formats[i].d)
formats[i].dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3460 formats[i].d->resolveFont(defaultFnt);
never executed: formats[i].d->resolveFont(defaultFnt);
0
3461}
never executed: end of block
0
3462-
3463#ifndef QT_NO_DEBUG_STREAM-
3464QDebug operator<<(QDebug dbg, const QTextLength &l)-
3465{-
3466 QDebugStateSaver saver(dbg);-
3467 dbg.nospace() << "QTextLength(QTextLength::Type(" << l.type() << "))";-
3468 return dbg;
never executed: return dbg;
0
3469}-
3470-
3471QDebug operator<<(QDebug dbg, const QTextFormat &f)-
3472{-
3473 QDebugStateSaver saver(dbg);-
3474 dbg.nospace() << "QTextFormat(QTextFormat::FormatType(" << f.type() << "))";-
3475 return dbg;
never executed: return dbg;
0
3476}-
3477-
3478#endif-
3479-
3480QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9