diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-08-18 06:34:18 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-08-18 06:34:18 (GMT) |
commit | fd6740b6ade6e7f8e51a9cc558b723e7fae15ccf (patch) | |
tree | aa2ba4ce64d047d73c29ab0616e8a89d352c3abd /src/gui/text/qtextformat.cpp | |
parent | d24029e3d4639f1300e7a68858936911df969f69 (diff) | |
parent | 572e165dcb8cc8fcdfaa4ab9bdab050f6a6cc173 (diff) | |
download | Qt-fd6740b6ade6e7f8e51a9cc558b723e7fae15ccf.zip Qt-fd6740b6ade6e7f8e51a9cc558b723e7fae15ccf.tar.gz Qt-fd6740b6ade6e7f8e51a9cc558b723e7fae15ccf.tar.bz2 |
Merge commit 'qt/master'
Conflicts:
doc/src/examples.qdoc
doc/src/plugins-howto.qdoc
doc/src/topics.qdoc
examples/phonon/musicplayer/mainwindow.cpp
src/3rdparty/freetype/src/base/ftobjs.c
src/corelib/global/qglobal.h
src/corelib/tools/qalgorithms.h
src/corelib/tools/qshareddata.cpp
src/corelib/tools/qsharedpointer.cpp
src/corelib/tools/tools.pri
src/corelib/xml/qxmlstream.h
src/gui/painting/painting.pri
src/gui/widgets/qdatetimeedit.cpp
tests/auto/qdesktopservices/qdesktopservices.pro
tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
tests/auto/qtextcodec/test/test.pro
Diffstat (limited to 'src/gui/text/qtextformat.cpp')
-rw-r--r-- | src/gui/text/qtextformat.cpp | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index 82c81ef..6a77fa5 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE \brief The QTextLength class encapsulates the different types of length used in a QTextDocument. - \ingroup text + \ingroup richtext-processing When we specify a value for the length of an element in a text document, we often need to provide some other information so that the length is @@ -267,10 +267,11 @@ private: static uint variantHash(const QVariant &variant) { - switch (variant.type()) { + switch (variant.userType()) { case QVariant::Invalid: return 0; case QVariant::Bool: return variant.toBool(); case QVariant::Int: return variant.toInt(); + case QMetaType::Float: return static_cast<int>(variant.toFloat()); case QVariant::Double: return static_cast<int>(variant.toDouble()); case QVariant::String: return qHash(variant.toString()); case QVariant::Color: return qHash(qvariant_cast<QColor>(variant).rgb()); @@ -325,7 +326,7 @@ void QTextFormatPrivate::recalcFont() const f.setFamily(props.at(i).value.toString()); break; case QTextFormat::FontPointSize: - f.setPointSizeF(props.at(i).value.toDouble()); + f.setPointSizeF(props.at(i).value.toReal()); break; case QTextFormat::FontPixelSize: f.setPixelSize(props.at(i).value.toInt()); @@ -352,10 +353,10 @@ void QTextFormatPrivate::recalcFont() const f.setStrikeOut(props.at(i).value.toBool()); break; case QTextFormat::FontLetterSpacing: - f.setLetterSpacing(QFont::PercentageSpacing, props.at(i).value.toDouble()); + f.setLetterSpacing(QFont::PercentageSpacing, props.at(i).value.toReal()); break; case QTextFormat::FontWordSpacing: - f.setWordSpacing(props.at(i).value.toDouble()); + f.setWordSpacing(props.at(i).value.toReal()); break; case QTextFormat::FontCapitalization: f.setCapitalization(static_cast<QFont::Capitalization> (props.at(i).value.toInt())); @@ -414,7 +415,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt) \brief The QTextFormat class provides formatting information for a QTextDocument. - \ingroup text + \ingroup richtext-processing \ingroup shared A QTextFormat is a generic class used for describing the format of @@ -447,7 +448,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt) associate the format with a QTextObject. It is used to represent lists, frames, and tables inside the document. - \sa {Text Processing Classes} + \sa {Rich Text Processing} */ /*! @@ -852,7 +853,7 @@ bool QTextFormat::boolProperty(int propertyId) const if (!d) return false; const QVariant prop = d->property(propertyId); - if (prop.type() != QVariant::Bool) + if (prop.userType() != QVariant::Bool) return false; return prop.toBool(); } @@ -868,7 +869,7 @@ int QTextFormat::intProperty(int propertyId) const if (!d) return 0; const QVariant prop = d->property(propertyId); - if (prop.type() != QVariant::Int) + if (prop.userType() != QVariant::Int) return 0; return prop.toInt(); } @@ -885,7 +886,7 @@ qreal QTextFormat::doubleProperty(int propertyId) const if (!d) return 0.; const QVariant prop = d->property(propertyId); - if (prop.type() != QVariant::Double && prop.type() != QMetaType::Float) + if (prop.userType() != QVariant::Double && prop.userType() != QMetaType::Float) return 0.; return qVariantValue<qreal>(prop); } @@ -902,7 +903,7 @@ QString QTextFormat::stringProperty(int propertyId) const if (!d) return QString(); const QVariant prop = d->property(propertyId); - if (prop.type() != QVariant::String) + if (prop.userType() != QVariant::String) return QString(); return prop.toString(); } @@ -920,7 +921,7 @@ QColor QTextFormat::colorProperty(int propertyId) const if (!d) return QColor(); const QVariant prop = d->property(propertyId); - if (prop.type() != QVariant::Color) + if (prop.userType() != QVariant::Color) return QColor(); return qvariant_cast<QColor>(prop); } @@ -937,7 +938,7 @@ QPen QTextFormat::penProperty(int propertyId) const if (!d) return QPen(Qt::NoPen); const QVariant prop = d->property(propertyId); - if (prop.type() != QVariant::Pen) + if (prop.userType() != QVariant::Pen) return QPen(Qt::NoPen); return qvariant_cast<QPen>(prop); } @@ -954,7 +955,7 @@ QBrush QTextFormat::brushProperty(int propertyId) const if (!d) return QBrush(Qt::NoBrush); const QVariant prop = d->property(propertyId); - if (prop.type() != QVariant::Brush) + if (prop.userType() != QVariant::Brush) return QBrush(Qt::NoBrush); return qvariant_cast<QBrush>(prop); } @@ -984,13 +985,13 @@ QVector<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const if (!d) return vector; const QVariant prop = d->property(propertyId); - if (prop.type() != QVariant::List) + if (prop.userType() != QVariant::List) return vector; QList<QVariant> propertyList = prop.toList(); for (int i=0; i<propertyList.size(); ++i) { QVariant var = propertyList.at(i); - if (var.type() == QVariant::TextLength) + if (var.userType() == QVariant::TextLength) vector.append(qvariant_cast<QTextLength>(var)); } @@ -1078,7 +1079,7 @@ int QTextFormat::objectIndex() const if (!d) return -1; const QVariant prop = d->property(ObjectIndex); - if (prop.type() != QVariant::Int) // #### + if (prop.userType() != QVariant::Int) // #### return -1; return prop.toInt(); } @@ -1183,7 +1184,7 @@ bool QTextFormat::operator==(const QTextFormat &rhs) const \brief The QTextCharFormat class provides formatting information for characters in a QTextDocument. - \ingroup text + \ingroup richtext-processing The character format of text in a document specifies the visual properties of the text, as well as information about its role in a hypertext document. @@ -1654,9 +1655,9 @@ void QTextCharFormat::setUnderlineStyle(UnderlineStyle style) QString QTextCharFormat::anchorName() const { QVariant prop = property(AnchorName); - if (prop.type() == QVariant::StringList) + if (prop.userType() == QVariant::StringList) return prop.toStringList().value(0); - else if (prop.type() != QVariant::String) + else if (prop.userType() != QVariant::String) return QString(); return prop.toString(); } @@ -1672,9 +1673,9 @@ QString QTextCharFormat::anchorName() const QStringList QTextCharFormat::anchorNames() const { QVariant prop = property(AnchorName); - if (prop.type() == QVariant::StringList) + if (prop.userType() == QVariant::StringList) return prop.toStringList(); - else if (prop.type() != QVariant::String) + else if (prop.userType() != QVariant::String) return QStringList(); return QStringList(prop.toString()); } @@ -1796,7 +1797,7 @@ QFont QTextCharFormat::font() const \brief The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument. - \ingroup text + \ingroup richtext-processing A document is composed of a list of blocks, represented by QTextBlock objects. Each block can contain an item of some kind, such as a @@ -2087,7 +2088,7 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const \brief The QTextListFormat class provides formatting information for lists in a QTextDocument. - \ingroup text + \ingroup richtext-processing A list is composed of one or more items, represented as text blocks. The list's format specifies the appearance of items in the list. @@ -2197,7 +2198,7 @@ QTextListFormat::QTextListFormat(const QTextFormat &fmt) \brief The QTextFrameFormat class provides formatting information for frames in a QTextDocument. - \ingroup text + \ingroup richtext-processing A text frame groups together one or more blocks of text, providing a layer of structure larger than the paragraph. The format of a frame specifies @@ -2523,7 +2524,7 @@ qreal QTextFrameFormat::rightMargin() const \brief The QTextTableFormat class provides formatting information for tables in a QTextDocument. - \ingroup text + \ingroup richtext-processing A table is a group of cells ordered into rows and columns. Each table contains at least one row and one column. Each cell contains a block. @@ -2729,7 +2730,7 @@ QTextTableFormat::QTextTableFormat(const QTextFormat &fmt) \brief The QTextImageFormat class provides formatting information for images in a QTextDocument. - \ingroup text + \ingroup richtext-processing Inline images are represented by an object replacement character (0xFFFC in Unicode) which has an associated QTextImageFormat. The @@ -2998,7 +2999,7 @@ QTextTableCellFormat::QTextTableCellFormat(const QTextFormat &fmt) \brief The QTextTableCellFormat class provides formatting information for table cells in a QTextDocument. - \ingroup text + \ingroup richtext-processing The table cell format of a table cell in a document specifies the visual properties of the table cell. |