diff options
-rw-r--r-- | src/gui/painting/qpainter.cpp | 6 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtextoption.cpp | 33 | ||||
-rw-r--r-- | src/gui/text/qtextoption.h | 14 | ||||
-rw-r--r-- | src/widgets/widgets/qplaintextedit.cpp | 30 | ||||
-rw-r--r-- | src/widgets/widgets/qplaintextedit.h | 12 | ||||
-rw-r--r-- | src/widgets/widgets/qtextedit.cpp | 29 | ||||
-rw-r--r-- | src/widgets/widgets/qtextedit.h | 12 | ||||
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 4 |
10 files changed, 118 insertions, 26 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index fb3c845e77..667c3b0fb5 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7419,7 +7419,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, if (option->flags() & QTextOption::IncludeTrailingSpaces) tf |= Qt::TextIncludeTrailingSpaces; - if (option->tabStop() >= 0 || !option->tabArray().isEmpty()) + if (option->tabStopDistance() >= 0 || !option->tabArray().isEmpty()) tf |= Qt::TextExpandTabs; } @@ -7536,8 +7536,8 @@ start_lengthVariant: engine.option = *option; } - if (engine.option.tabStop() < 0 && tabstops > 0) - engine.option.setTabStop(tabstops); + if (engine.option.tabStopDistance() < 0 && tabstops > 0) + engine.option.setTabStopDistance(tabstops); if (engine.option.tabs().isEmpty() && ta) { QList<qreal> tabs; diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 7341fa8e83..66e038122c 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -203,7 +203,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() inContentsChange = false; blockCursorAdjustment = false; - defaultTextOption.setTabStop(80); // same as in qtextengine.cpp + defaultTextOption.setTabStopDistance(80); // same as in qtextengine.cpp defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); defaultCursorMoveStyle = Qt::LogicalMoveStyle; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index a9d23d8e4b..faddb3552d 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -3043,7 +3043,7 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const } } } - QFixed tab = QFixed::fromReal(option.tabStop()); + QFixed tab = QFixed::fromReal(option.tabStopDistance()); if (tab <= 0) tab = 80; // default tab *= dpiScale; diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index 87e31eeb2c..2a16f50f33 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -144,7 +144,7 @@ QTextOption &QTextOption::operator=(const QTextOption &o) Sets the tab positions for the text layout to those specified by \a tabStops. - \sa tabArray(), setTabStop(), setTabs() + \sa tabArray(), setTabStopDistance(), setTabs() */ void QTextOption::setTabArray(const QList<qreal> &tabStops) { @@ -332,22 +332,45 @@ QList<QTextOption::Tab> QTextOption::tabs() const \sa flags() */ +#if QT_DEPRECATED_SINCE(5, 10) /*! \fn qreal QTextOption::tabStop() const + \deprecated in Qt 5.10. Use tabStopDistance() instead. Returns the distance in device units between tab stops. Convenient function for the above method - \sa setTabStop(), tabArray(), setTabs(), tabs() + \sa setTabStopDistance(), tabArray(), setTabs(), tabs() */ /*! \fn void QTextOption::setTabStop(qreal tabStop) + \deprecated in Qt 5.10. Use setTabStopDistance() instead. Sets the default distance in device units between tab stops to the value specified by \a tabStop. - \sa tabStop(), setTabArray(), setTabs(), tabs() + \sa tabStopDistance(), setTabArray(), setTabs(), tabs() +*/ +#endif + +/*! + \fn qreal QTextOption::tabStopDistance() const + \since 5.10 + + Returns the distance in device units between tab stops. + + \sa setTabStopDistance(), tabArray(), setTabs(), tabs() +*/ + +/*! + \fn void QTextOption::setTabStopDistance(qreal tabStopDistance) + \since 5.10 + + Sets the default distance in device units between tab stops to the value specified + by \a tabStopDistance. + + \sa tabStopDistance(), setTabArray(), setTabs(), tabs() */ /*! @@ -426,7 +449,7 @@ QList<QTextOption::Tab> QTextOption::tabs() const \fn void setTabs(const QList<Tab> &tabStops) Set the Tab properties to \a tabStops. - \sa tabStop(), tabs() + \sa tabStopDistance(), tabs() */ /*! @@ -434,7 +457,7 @@ QList<QTextOption::Tab> QTextOption::tabs() const \fn QList<QTextOption::Tab> QTextOption::tabs() const Returns a list of tab positions defined for the text layout. - \sa tabStop(), setTabs(), setTabStop() + \sa tabStopDistance(), setTabs(), setTabStop() */ diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h index 9ef9cee9bb..8b57278633 100644 --- a/src/gui/text/qtextoption.h +++ b/src/gui/text/qtextoption.h @@ -117,8 +117,13 @@ public: inline void setFlags(Flags flags); inline Flags flags() const { return Flags(f); } - inline void setTabStop(qreal tabStop); - inline qreal tabStop() const { return tab; } +#if QT_DEPRECATED_SINCE(5, 10) + QT_DEPRECATED inline void setTabStop(qreal tabStop); + QT_DEPRECATED inline qreal tabStop() const { return tabStopDistance(); } +#endif + + inline void setTabStopDistance(qreal tabStopDistance); + inline qreal tabStopDistance() const { return tab; } void setTabArray(const QList<qreal> &tabStops); QList<qreal> tabArray() const; @@ -149,7 +154,12 @@ inline void QTextOption::setAlignment(Qt::Alignment aalignment) inline void QTextOption::setFlags(Flags aflags) { f = aflags; } +#if QT_DEPRECATED_SINCE(5, 10) inline void QTextOption::setTabStop(qreal atabStop) +{ setTabStopDistance(atabStop); } +#endif + +inline void QTextOption::setTabStopDistance(qreal atabStop) { tab = atabStop; } QT_END_NAMESPACE diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 173be7aa88..e19d4d4702 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -2453,29 +2453,51 @@ void QPlainTextEdit::setOverwriteMode(bool overwrite) d->control->setOverwriteMode(overwrite); } +#if QT_DEPRECATED_SINCE(5, 10) /*! \property QPlainTextEdit::tabStopWidth \brief the tab stop width in pixels + \deprecated in Qt 5.10. Use tabStopDistance instead. By default, this property contains a value of 80. */ int QPlainTextEdit::tabStopWidth() const { - Q_D(const QPlainTextEdit); - return qRound(d->control->document()->defaultTextOption().tabStop()); + return qRound(tabStopDistance()); } void QPlainTextEdit::setTabStopWidth(int width) { + setTabStopDistance(width); +} +#endif + +/*! + \property QPlainTextEdit::tabStopDistance + \brief the tab stop distance in pixels + \since 5.10 + + By default, this property contains a value of 80. +*/ + +qreal QPlainTextEdit::tabStopDistance() const +{ + Q_D(const QPlainTextEdit); + return d->control->document()->defaultTextOption().tabStopDistance(); +} + +void QPlainTextEdit::setTabStopDistance(qreal distance) +{ Q_D(QPlainTextEdit); QTextOption opt = d->control->document()->defaultTextOption(); - if (opt.tabStop() == width || width < 0) + if (opt.tabStopDistance() == distance || distance < 0) return; - opt.setTabStop(width); + opt.setTabStopDistance(distance); d->control->document()->setDefaultTextOption(opt); } + /*! \property QPlainTextEdit::cursorWidth diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index d773c4791c..09e714fd3c 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -74,7 +74,10 @@ class Q_WIDGETS_EXPORT QPlainTextEdit : public QAbstractScrollArea Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText NOTIFY textChanged USER true) Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode) +#if QT_DEPRECATED_SINCE(5, 10) Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth) +#endif + Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance) Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth) Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags) Q_PROPERTY(int blockCount READ blockCount) @@ -168,8 +171,13 @@ public: bool overwriteMode() const; void setOverwriteMode(bool overwrite); - int tabStopWidth() const; - void setTabStopWidth(int width); +#if QT_DEPRECATED_SINCE(5, 10) + QT_DEPRECATED int tabStopWidth() const; + QT_DEPRECATED void setTabStopWidth(int width); +#endif + + qreal tabStopDistance() const; + void setTabStopDistance(qreal distance); int cursorWidth() const; void setCursorWidth(int width); diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 6973cec429..3eaf60116e 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1954,27 +1954,48 @@ void QTextEdit::setOverwriteMode(bool overwrite) d->control->setOverwriteMode(overwrite); } +#if QT_DEPRECATED_SINCE(5, 10) /*! \property QTextEdit::tabStopWidth \brief the tab stop width in pixels \since 4.1 + \deprecated in Qt 5.10. Use tabStopDistance instead. By default, this property contains a value of 80 pixels. */ int QTextEdit::tabStopWidth() const { - Q_D(const QTextEdit); - return qRound(d->control->document()->defaultTextOption().tabStop()); + return qRound(tabStopDistance()); } void QTextEdit::setTabStopWidth(int width) { + setTabStopDistance(width); +} +#endif + +/*! + \property QTextEdit::tabStopDistance + \brief the tab stop distance in pixels + \since 5.10 + + By default, this property contains a value of 80 pixels. +*/ + +qreal QTextEdit::tabStopDistance() const +{ + Q_D(const QTextEdit); + return d->control->document()->defaultTextOption().tabStopDistance(); +} + +void QTextEdit::setTabStopDistance(qreal distance) +{ Q_D(QTextEdit); QTextOption opt = d->control->document()->defaultTextOption(); - if (opt.tabStop() == width || width < 0) + if (opt.tabStopDistance() == distance || distance < 0) return; - opt.setTabStop(width); + opt.setTabStopDistance(distance); d->control->document()->setDefaultTextOption(opt); } diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 745b644511..a3e5bd2a8a 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -77,7 +77,10 @@ class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea #endif Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText DESIGNABLE false) Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode) +#if QT_DEPRECATED_SINCE(5, 10) Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth) +#endif + Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance) Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText) Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth) Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags) @@ -187,8 +190,13 @@ public: bool overwriteMode() const; void setOverwriteMode(bool overwrite); - int tabStopWidth() const; - void setTabStopWidth(int width); +#if QT_DEPRECATED_SINCE(5, 10) + QT_DEPRECATED int tabStopWidth() const; + QT_DEPRECATED void setTabStopWidth(int width); +#endif + + qreal tabStopDistance() const; + void setTabStopDistance(qreal distance); int cursorWidth() const; void setCursorWidth(int width); diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index b8af5271ea..b68a014bff 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -1312,7 +1312,7 @@ void tst_QTextLayout::testDefaultTabs() QCOMPARE(line.cursorToX(31), 480.); QTextOption option = layout.textOption(); - option.setTabStop(90); + option.setTabStopDistance(90); layout.setTextOption(option); layout.beginLayout(); line = layout.createLine(); @@ -1351,7 +1351,7 @@ void tst_QTextLayout::testTabs() layout.setCacheEnabled(true); QTextOption option = layout.textOption(); - option.setTabStop(150); + option.setTabStopDistance(150); layout.setTextOption(option); layout.beginLayout(); |