diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-04-25 14:10:21 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-04-26 09:01:26 +0200 |
commit | 63b042fb219a42194485e152acf6d305e4594c5c (patch) | |
tree | 1fc9ddb37dc81ea6fe1e644aa92a3ac9a823f92b /src/widgets/accessible | |
parent | a7dc1e280bdb63f893c720947f05ce5e24893f6f (diff) |
QtWidgets: stop using QLatin1Char constructor for creating char literals
Required for porting away from QLatin1Char/QLatin1String in scope of
QTBUG-98434.
As a drive-by, fix qsizetype -> int narrowing conversion warnings for
the touched lines.
Change-Id: I133b80334b66e0a5ab9546dd8e1ff0631e79601e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/accessible')
-rw-r--r-- | src/widgets/accessible/qaccessiblewidget.cpp | 12 | ||||
-rw-r--r-- | src/widgets/accessible/qaccessiblewidgets.cpp | 8 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index ae545a5ce2..1a8d2febec 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -112,18 +112,18 @@ static QString buddyString(const QWidget *widget) /* This function will return the offset of the '&' in the text that would be preceding the accelerator character. If this text does not have an accelerator, -1 will be returned. */ -static int qt_accAmpIndex(const QString &text) +static qsizetype qt_accAmpIndex(const QString &text) { #ifndef QT_NO_SHORTCUT if (text.isEmpty()) return -1; - int fa = 0; - while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) { + qsizetype fa = 0; + while ((fa = text.indexOf(u'&', fa)) != -1) { ++fa; if (fa < text.length()) { // ignore "&&" - if (text.at(fa) == QLatin1Char('&')) { + if (text.at(fa) == u'&') { ++fa; continue; @@ -144,7 +144,7 @@ static int qt_accAmpIndex(const QString &text) QString qt_accStripAmp(const QString &text) { QString newText(text); - int ampIndex = qt_accAmpIndex(newText); + qsizetype ampIndex = qt_accAmpIndex(newText); if (ampIndex != -1) newText.remove(ampIndex, 1); @@ -154,7 +154,7 @@ QString qt_accStripAmp(const QString &text) QString qt_accHotKey(const QString &text) { #ifndef QT_NO_SHORTCUT - int ampIndex = qt_accAmpIndex(text); + qsizetype ampIndex = qt_accAmpIndex(text); if (ampIndex != -1) return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1); #else diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index d9ba34c145..fdabc051c8 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -761,7 +761,7 @@ class AttributeFormatterRef { public: template <typename RHS> void operator=(RHS &&rhs) - { string += QLatin1String(key) + QLatin1Char(':') + std::forward<RHS>(rhs) + QLatin1Char(';'); } + { string += QLatin1String(key) + u':' + std::forward<RHS>(rhs) + u';'; } }; /*! @@ -769,7 +769,7 @@ public: \brief Small string-builder class that supports a map-like API to serialize key-value pairs. \code AttributeFormatter attrs; - attrs["foo"] = QLatinString("hello") + world + QLatin1Char('!'); + attrs["foo"] = QLatinString("hello") + world + u'!'; \endcode The key type is always \c{const char*}, and the right-hand-side can be any QStringBuilder expression. @@ -858,7 +858,7 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end family = family.replace(u'=', QLatin1String("\\=")); family = family.replace(u';', QLatin1String("\\;")); family = family.replace(u'\"', QLatin1String("\\\"")); - attrs["font-family"] = QLatin1Char('"') + family + QLatin1Char('"'); + attrs["font-family"] = u'"' + family + u'"'; } int fontSize = int(charFormatFont.pointSize()); @@ -966,7 +966,7 @@ QString QAccessibleTextWidget::text(int startOffset, int endOffset) const cursor.setPosition(startOffset, QTextCursor::MoveAnchor); cursor.setPosition(endOffset, QTextCursor::KeepAnchor); - return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), QLatin1Char('\n')); + return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), u'\n'); } QPoint QAccessibleTextWidget::scrollBarPosition() const |