From a11267c5320324cce19496313e2f7f8cdce9d8f7 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 8 Jan 2020 20:18:17 +0100 Subject: QTextBrowser: deprecate signal highlighted(QString) Deprecate QTextBrowser::highlighted(QString) to avoid the use of qOverloadOf<>. Task-number: QTBUG-80906 Change-Id: I757622c976f7540ecef9225026299ebb0b90d007 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qtextbrowser.cpp | 37 ++++++++++++++++++------------------ src/widgets/widgets/qtextbrowser.h | 3 +++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 0ba74a20e0..78fde94fad 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -152,6 +152,16 @@ public: QTextCursor prevFocus; int lastKeypadScrollValue; #endif + void emitHighlighted(const QUrl &url) + { + Q_Q(QTextBrowser); + emit q->highlighted(url); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + emit q->highlighted(url.toString()); +#endif + } }; Q_DECLARE_TYPEINFO(QTextBrowserPrivate::HistoryEntry, Q_MOVABLE_TYPE); @@ -256,24 +266,20 @@ void QTextBrowserPrivate::_q_activateAnchor(const QString &href) void QTextBrowserPrivate::_q_highlightLink(const QString &anchor) { - Q_Q(QTextBrowser); if (anchor.isEmpty()) { #ifndef QT_NO_CURSOR if (viewport->cursor().shape() != Qt::PointingHandCursor) oldCursor = viewport->cursor(); viewport->setCursor(oldCursor); #endif - emit q->highlighted(QUrl()); - emit q->highlighted(QString()); + emitHighlighted(QUrl()); } else { #ifndef QT_NO_CURSOR viewport->setCursor(Qt::PointingHandCursor); #endif const QUrl url = resolveUrl(anchor); - emit q->highlighted(url); - // convenience to ease connecting to QStatusBar::showMessage(const QString &) - emit q->highlighted(url.toString()); + emitHighlighted(url); } } @@ -383,8 +389,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url, QTextDocument::ResourceType } #ifdef QT_KEYPAD_NAVIGATION lastKeypadScrollValue = vbar->value(); - emit q->highlighted(QUrl()); - emit q->highlighted(QString()); + emitHighlighted(QUrl()); #endif #ifndef QT_NO_CURSOR @@ -559,8 +564,7 @@ void QTextBrowserPrivate::keypadMove(bool next) // Ensure that the new selection is highlighted. const QString href = control->anchorAtCursor(); QUrl url = resolveUrl(href); - emit q->highlighted(url); - emit q->highlighted(url.toString()); + emitHighlighted(url); } else { // Scroll vbar->setValue(scrollYOffset); @@ -575,8 +579,7 @@ void QTextBrowserPrivate::keypadMove(bool next) hbar->setValue(savedXOffset); vbar->setValue(scrollYOffset); - emit q->highlighted(QUrl()); - emit q->highlighted(QString()); + emitHighlighted(QUrl()); } } #endif @@ -619,8 +622,7 @@ void QTextBrowserPrivate::restoreHistoryEntry(const HistoryEntry &entry) Q_Q(QTextBrowser); const QString href = prevFocus.charFormat().anchorHref(); QUrl url = resolveUrl(href); - emit q->highlighted(url); - emit q->highlighted(url.toString()); + emitHighlighted(url); #endif } @@ -927,6 +929,7 @@ void QTextBrowser::doSetSource(const QUrl &url, QTextDocument::ResourceType type /*! \fn void QTextBrowser::highlighted(const QString &link) \overload + \obsolete Convenience signal that allows connecting to a slot that takes just a QString, like for example QStatusBar's @@ -1127,8 +1130,7 @@ bool QTextBrowser::focusNextPrevChild(bool next) if (d->prevFocus != d->control->textCursor() && d->control->textCursor().hasSelection()) { const QString href = d->control->anchorAtCursor(); QUrl url = d->resolveUrl(href); - emit highlighted(url); - emit highlighted(url.toString()); + emitHighlighted(url); } d->prevFocus = d->control->textCursor(); #endif @@ -1136,8 +1138,7 @@ bool QTextBrowser::focusNextPrevChild(bool next) } else { #ifdef QT_KEYPAD_NAVIGATION // We assume we have no highlight now. - emit highlighted(QUrl()); - emit highlighted(QString()); + emitHighlighted(QUrl()); #endif } return QTextEdit::focusNextPrevChild(next); diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h index 33e5b3980c..4b3ec491ee 100644 --- a/src/widgets/widgets/qtextbrowser.h +++ b/src/widgets/widgets/qtextbrowser.h @@ -107,7 +107,10 @@ Q_SIGNALS: void historyChanged(); void sourceChanged(const QUrl &); void highlighted(const QUrl &); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_VERSION_X_5_15("Use QTextBrowser::highlighted(QUrl) instead") void highlighted(const QString &); +#endif void anchorClicked(const QUrl &); protected: -- cgit v1.2.3