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