From 2766322de37adba37e0d0d4b0054e55edff01c6c Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Wed, 12 Aug 2020 13:16:27 +0200 Subject: Move QStringRef and remains to Qt5Compat Export some private functions from QUtf8 to resolve undefined symbols in Qt5Compat after moving QStringRef. Task-number: QTBUG-84437 Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b Reviewed-by: Lars Knoll --- examples/widgets/gallery/widgetgallery.cpp | 4 ++-- examples/widgets/graphicsview/flowlayout/window.cpp | 4 ++-- examples/widgets/mainwindows/mainwindow/main.cpp | 6 +++--- examples/widgets/painting/shared/arthurwidgets.cpp | 2 +- examples/widgets/tools/i18n/languagechooser.cpp | 6 +++--- examples/widgets/tools/i18n/languagechooser.h | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) (limited to 'examples/widgets') diff --git a/examples/widgets/gallery/widgetgallery.cpp b/examples/widgets/gallery/widgetgallery.cpp index 3bbe8943d1..b2973fad4c 100644 --- a/examples/widgets/gallery/widgetgallery.cpp +++ b/examples/widgets/gallery/widgetgallery.cpp @@ -335,8 +335,8 @@ QToolBox *WidgetGallery::createTextToolBox() "How I wonder what you are!\n"); // Create centered/italic HTML rich text QString richText = QLatin1String(""); - for (const auto &line : plainText.splitRef(QLatin1Char('\n'))) - richText += QLatin1String("
") + line + QLatin1String("
"); + for (const auto &line : QStringView{ plainText }.split(QLatin1Char('\n'))) + richText += QString::fromLatin1("
%1
").arg(line); richText += QLatin1String("
"); auto textEdit = createWidget1(richText, "textEdit"); diff --git a/examples/widgets/graphicsview/flowlayout/window.cpp b/examples/widgets/graphicsview/flowlayout/window.cpp index dd4e3661da..d0dee2081c 100644 --- a/examples/widgets/graphicsview/flowlayout/window.cpp +++ b/examples/widgets/graphicsview/flowlayout/window.cpp @@ -59,8 +59,8 @@ Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window) FlowLayout *lay = new FlowLayout; const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown." " I am bothered when I do not know others. (Confucius)")); - const QList words = sentence.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts); - for (const QStringRef &word : words) { + const QList words = QStringView{ sentence }.split(QLatin1Char(' '), Qt::SkipEmptyParts); + for (const QStringView &word : words) { QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); QLabel *label = new QLabel(word.toString()); label->setFrameStyle(QFrame::Box | QFrame::Plain); diff --git a/examples/widgets/mainwindows/mainwindow/main.cpp b/examples/widgets/mainwindows/mainwindow/main.cpp index ae4634e3be..dcaabd195f 100644 --- a/examples/widgets/mainwindows/mainwindow/main.cpp +++ b/examples/widgets/mainwindows/mainwindow/main.cpp @@ -151,15 +151,15 @@ static ParseCommandLineArgumentsResult return CommandLineArgumentsError; if (++i == argumentCount) return CommandLineArgumentsError; - const QString sizeStr = arguments.at(i); + const QStringView sizeStr{ arguments.at(i) }; const int idx = sizeStr.indexOf(QLatin1Char('x')); if (idx == -1) return CommandLineArgumentsError; bool ok; - const int w = sizeStr.leftRef(idx).toInt(&ok); + const int w = sizeStr.left(idx).toInt(&ok); if (!ok) return CommandLineArgumentsError; - const int h = sizeStr.midRef(idx + 1).toInt(&ok); + const int h = sizeStr.mid(idx + 1).toInt(&ok); if (!ok) return CommandLineArgumentsError; result->insert(name, QSize(w, h)); diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp index bd8a6d7b62..667246b79a 100644 --- a/examples/widgets/painting/shared/arthurwidgets.cpp +++ b/examples/widgets/painting/shared/arthurwidgets.cpp @@ -381,7 +381,7 @@ void ArthurFrame::showSource() const QString html = QStringLiteral("
") + contents + QStringLiteral("
"); QTextBrowser *sourceViewer = new QTextBrowser; - sourceViewer->setWindowTitle(tr("Source: %1").arg(m_sourceFileName.midRef(5))); + sourceViewer->setWindowTitle(tr("Source: %1").arg(QStringView{ m_sourceFileName }.mid(5))); sourceViewer->setParent(this, Qt::Dialog); sourceViewer->setAttribute(Qt::WA_DeleteOnClose); sourceViewer->setLineWrapMode(QTextEdit::NoWrap); diff --git a/examples/widgets/tools/i18n/languagechooser.cpp b/examples/widgets/tools/i18n/languagechooser.cpp index 51dfce915f..2f82fc678b 100644 --- a/examples/widgets/tools/i18n/languagechooser.cpp +++ b/examples/widgets/tools/i18n/languagechooser.cpp @@ -97,12 +97,12 @@ LanguageChooser::LanguageChooser(const QString &defaultLang, QWidget *parent) setWindowTitle("I18N"); } -bool LanguageChooser::languageMatch(const QString &lang, const QString &qmFile) +bool LanguageChooser::languageMatch(QStringView lang, QStringView qmFile) { //qmFile: i18n_xx.qm - const QString prefix = "i18n_"; + const QStringView prefix{ u"i18n_" }; const int langTokenLength = 2; /*FIXME: is checking two chars enough?*/ - return qmFile.midRef(qmFile.indexOf(prefix) + prefix.length(), langTokenLength) == lang.leftRef(langTokenLength); + return qmFile.mid(qmFile.indexOf(prefix) + prefix.length(), langTokenLength) == lang.left(langTokenLength); } bool LanguageChooser::eventFilter(QObject *object, QEvent *event) diff --git a/examples/widgets/tools/i18n/languagechooser.h b/examples/widgets/tools/i18n/languagechooser.h index 733cc50fd3..6193ab8756 100644 --- a/examples/widgets/tools/i18n/languagechooser.h +++ b/examples/widgets/tools/i18n/languagechooser.h @@ -83,7 +83,7 @@ private: static QStringList findQmFiles(); static QString languageName(const QString &qmFile); static QColor colorForLanguage(const QString &language); - static bool languageMatch(const QString &lang, const QString &qmFile); + static bool languageMatch(QStringView lang, QStringView qmFile); QGroupBox *groupBox; QDialogButtonBox *buttonBox; -- cgit v1.2.3