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