diff options
Diffstat (limited to 'src/gui/text/qtextformat.h')
-rw-r--r-- | src/gui/text/qtextformat.h | 140 |
1 files changed, 78 insertions, 62 deletions
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index e12f033596..2fa86ed0d1 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTEXTFORMAT_H #define QTEXTFORMAT_H @@ -73,11 +37,6 @@ class QTextCursor; class QTextDocument; class QTextLength; -#ifndef QT_NO_DATASTREAM -Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &); -Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &); -#endif - #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QTextLength &); #endif @@ -118,16 +77,11 @@ private: friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &); friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &); }; -Q_DECLARE_TYPEINFO(QTextLength, QT_VERSION >= QT_VERSION_CHECK(6,0,0) ? Q_PRIMITIVE_TYPE : Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QTextLength, Q_PRIMITIVE_TYPE); inline QTextLength::QTextLength(Type atype, qreal avalue) : lengthType(atype), fixedValueOrPercentage(avalue) {} -#ifndef QT_NO_DATASTREAM -Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &); -Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &); -#endif - #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QTextFormat &); #endif @@ -141,9 +95,6 @@ public: BlockFormat = 1, CharFormat = 2, ListFormat = 3, -#if QT_DEPRECATED_SINCE(5, 3) - TableFormat = 4, -#endif FrameFormat = 5, UserFormat = 100 @@ -195,7 +146,9 @@ public: FontStyleName = 0x1FE8, FontLetterSpacingType = 0x1FE9, FontStretch = 0x1FEA, +#if QT_DEPRECATED_SINCE(6, 0) FontFamily = 0x2000, +#endif FontPointSize = 0x2001, FontSizeAdjustment = 0x2002, FontSizeIncrement = FontSizeAdjustment, // old name, compat @@ -213,6 +166,9 @@ public: TextOutline = 0x2022, TextUnderlineStyle = 0x2023, TextToolTip = 0x2024, + TextSuperScriptBaseline = 0x2025, + TextSubScriptBaseline = 0x2026, + TextBaselineOffset = 0x2027, IsAnchor = 0x2030, AnchorHref = 0x2031, @@ -222,6 +178,8 @@ public: // Should not be referenced in user code. OldFontLetterSpacingType = 0x2033, OldFontStretch = 0x2034, + OldTextUnderlineColor = 0x2010, + OldFontFamily = 0x2000, // same as FontFamily ObjectType = 0x2f00, @@ -230,6 +188,7 @@ public: ListIndent = 0x3001, ListNumberPrefix = 0x3002, ListNumberSuffix = 0x3003, + ListStart = 0x3004, // table and frame properties FrameBorder = 0x4000, @@ -282,6 +241,7 @@ public: ImageWidth = 0x5010, ImageHeight = 0x5011, ImageQuality = 0x5014, + ImageMaxWidth = 0x5015, // internal /* @@ -327,7 +287,7 @@ public: ~QTextFormat(); void swap(QTextFormat &other) - { qSwap(d, other.d); qSwap(format_type, other.format_type); } + { d.swap(other.d); std::swap(format_type, other.format_type); } void merge(const QTextFormat &other); @@ -453,20 +413,32 @@ public: void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior = FontPropertiesAll); QFont font() const; - inline void setFontFamily(const QString &family) - { setProperty(FontFamily, family); } - inline QString fontFamily() const - { return stringProperty(FontFamily); } +#if QT_DEPRECATED_SINCE(6, 1) + QT_DEPRECATED_VERSION_X_6_1("Use setFontFamilies instead") inline void setFontFamily(const QString &family) + { setProperty(FontFamilies, QVariant(QStringList(family))); } + QT_DEPRECATED_VERSION_X_6_1("Use fontFamilies instead") inline QString fontFamily() const + { return property(FontFamilies).toStringList().first(); } +#endif inline void setFontFamilies(const QStringList &families) { setProperty(FontFamilies, QVariant(families)); } +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) inline QVariant fontFamilies() const { return property(FontFamilies); } +#else + inline QStringList fontFamilies() const + { return property(FontFamilies).toStringList(); } +#endif inline void setFontStyleName(const QString &styleName) { setProperty(FontStyleName, styleName); } +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) inline QVariant fontStyleName() const { return property(FontStyleName); } +#else + inline QStringList fontStyleName() const + { return property(FontStyleName).toStringList(); } +#endif inline void setFontPointSize(qreal size) { setProperty(FontPointSize, size); } @@ -570,6 +542,21 @@ public: inline QString toolTip() const { return stringProperty(TextToolTip); } + inline void setSuperScriptBaseline(qreal baseline) + { setProperty(TextSuperScriptBaseline, baseline); } + inline qreal superScriptBaseline() const + { return hasProperty(TextSuperScriptBaseline) ? doubleProperty(TextSuperScriptBaseline) : 50.0; } + + inline void setSubScriptBaseline(qreal baseline) + { setProperty(TextSubScriptBaseline, baseline); } + inline qreal subScriptBaseline() const + { return hasProperty(TextSubScriptBaseline) ? doubleProperty(TextSubScriptBaseline) : 100.0 / 6.0; } + + inline void setBaselineOffset(qreal baseline) + { setProperty(TextBaselineOffset, baseline); } + inline qreal baselineOffset() const + { return hasProperty(TextBaselineOffset) ? doubleProperty(TextBaselineOffset) : 0.0; } + inline void setAnchor(bool anchor) { setProperty(IsAnchor, anchor); } inline bool isAnchor() const @@ -594,6 +581,8 @@ public: protected: explicit QTextCharFormat(const QTextFormat &fmt); friend class QTextFormat; + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextCharFormat &); + friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextCharFormat &); }; Q_DECLARE_SHARED(QTextCharFormat) @@ -687,7 +676,7 @@ public: { return boolProperty(BlockNonBreakableLines); } inline void setPageBreakPolicy(PageBreakFlags flags) - { setProperty(PageBreakPolicy, int(flags)); } + { setProperty(PageBreakPolicy, int(flags.toInt())); } inline PageBreakFlags pageBreakPolicy() const { return PageBreakFlags(intProperty(PageBreakPolicy)); } @@ -702,12 +691,14 @@ public: protected: explicit QTextBlockFormat(const QTextFormat &fmt); friend class QTextFormat; + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextBlockFormat &); + friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextBlockFormat &); }; Q_DECLARE_SHARED(QTextBlockFormat) inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment) -{ setProperty(BlockAlignment, int(aalignment)); } +{ setProperty(BlockAlignment, int(aalignment.toInt())); } inline void QTextBlockFormat::setIndent(int aindent) { setProperty(BlockIndent, aindent); } @@ -764,6 +755,9 @@ public: inline QString numberSuffix() const { return stringProperty(ListNumberSuffix); } + inline void setStart(int indent); + inline int start() const { return intProperty(ListStart); } + protected: explicit QTextListFormat(const QTextFormat &fmt); friend class QTextFormat; @@ -783,6 +777,11 @@ inline void QTextListFormat::setNumberPrefix(const QString &np) inline void QTextListFormat::setNumberSuffix(const QString &ns) { setProperty(ListNumberSuffix, ns); } +inline void QTextListFormat::setStart(int astart) +{ + setProperty(ListStart, astart); +} + class Q_GUI_EXPORT QTextImageFormat : public QTextCharFormat { public: @@ -798,17 +797,27 @@ public: inline qreal width() const { return doubleProperty(ImageWidth); } + inline void setMaximumWidth(QTextLength maxWidth); + inline QTextLength maximumWidth() const + { return lengthProperty(ImageMaxWidth); } + inline void setHeight(qreal height); inline qreal height() const { return doubleProperty(ImageHeight); } - inline void setQuality(int quality = 100); + inline void setQuality(int quality); +#if QT_DEPRECATED_SINCE(6, 3) + QT_DEPRECATED_VERSION_X_6_3("Pass a quality value, the default is 100") inline void setQuality() + { setQuality(100); } +#endif inline int quality() const { return intProperty(ImageQuality); } protected: explicit QTextImageFormat(const QTextFormat &format); friend class QTextFormat; + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextListFormat &); + friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextListFormat &); }; Q_DECLARE_SHARED(QTextImageFormat) @@ -819,6 +828,9 @@ inline void QTextImageFormat::setName(const QString &aname) inline void QTextImageFormat::setWidth(qreal awidth) { setProperty(ImageWidth, awidth); } +inline void QTextImageFormat::setMaximumWidth(QTextLength maxWidth) +{ setProperty(ImageMaxWidth, maxWidth); } + inline void QTextImageFormat::setHeight(qreal aheight) { setProperty(ImageHeight, aheight); } @@ -905,13 +917,15 @@ public: { return lengthProperty(FrameHeight); } inline void setPageBreakPolicy(PageBreakFlags flags) - { setProperty(PageBreakPolicy, int(flags)); } + { setProperty(PageBreakPolicy, int(flags.toInt())); } inline PageBreakFlags pageBreakPolicy() const { return PageBreakFlags(intProperty(PageBreakPolicy)); } protected: explicit QTextFrameFormat(const QTextFormat &fmt); friend class QTextFormat; + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFrameFormat &); + friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFrameFormat &); }; Q_DECLARE_SHARED(QTextFrameFormat) @@ -1003,7 +1017,7 @@ inline void QTextTableFormat::setCellPadding(qreal apadding) { setProperty(TableCellPadding, apadding); } inline void QTextTableFormat::setAlignment(Qt::Alignment aalignment) -{ setProperty(BlockAlignment, int(aalignment)); } +{ setProperty(BlockAlignment, int(aalignment.toInt())); } class Q_GUI_EXPORT QTextTableCellFormat : public QTextCharFormat { @@ -1094,6 +1108,8 @@ public: protected: explicit QTextTableCellFormat(const QTextFormat &fmt); + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextTableCellFormat &); + friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextTableCellFormat &); friend class QTextFormat; }; |