summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2020-08-12 13:16:27 +0200
committerKarsten Heimrich <karsten.heimrich@qt.io>2020-08-20 00:58:13 +0200
commit2766322de37adba37e0d0d4b0054e55edff01c6c (patch)
treed487d502ee944963e103e11c9726c3efcd8fe041 /examples
parenteb7d1cf098df56f8ebf62f02af611a627435a4a1 (diff)
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 <lars.knoll@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/tools/customtype/message.cpp5
-rw-r--r--examples/corelib/tools/customtype/message.h2
-rw-r--r--examples/widgets/gallery/widgetgallery.cpp4
-rw-r--r--examples/widgets/graphicsview/flowlayout/window.cpp4
-rw-r--r--examples/widgets/mainwindows/mainwindow/main.cpp6
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.cpp2
-rw-r--r--examples/widgets/tools/i18n/languagechooser.cpp6
-rw-r--r--examples/widgets/tools/i18n/languagechooser.h2
8 files changed, 15 insertions, 16 deletions
diff --git a/examples/corelib/tools/customtype/message.cpp b/examples/corelib/tools/customtype/message.cpp
index da44909893..948e323dbf 100644
--- a/examples/corelib/tools/customtype/message.cpp
+++ b/examples/corelib/tools/customtype/message.cpp
@@ -60,8 +60,7 @@ Message::Message(const QString &body, const QStringList &headers)
//! [custom type streaming operator]
QDebug operator<<(QDebug dbg, const Message &message)
{
- const QString body = message.body();
- QList<QStringRef> pieces = body.splitRef(QLatin1String("\r\n"), Qt::SkipEmptyParts);
+ QList<QStringView> pieces = message.body().split(u"\r\n", Qt::SkipEmptyParts);
if (pieces.isEmpty())
dbg.nospace() << "Message()";
else if (pieces.size() == 1)
@@ -73,7 +72,7 @@ QDebug operator<<(QDebug dbg, const Message &message)
//! [custom type streaming operator]
//! [getter functions]
-QString Message::body() const
+QStringView Message::body() const
{
return m_body;
}
diff --git a/examples/corelib/tools/customtype/message.h b/examples/corelib/tools/customtype/message.h
index bc30c45425..acc439b0f6 100644
--- a/examples/corelib/tools/customtype/message.h
+++ b/examples/corelib/tools/customtype/message.h
@@ -65,7 +65,7 @@ public:
Message(const QString &body, const QStringList &headers);
- QString body() const;
+ QStringView body() const;
QStringList headers() const;
private:
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("<html><head/><body><i>");
- for (const auto &line : plainText.splitRef(QLatin1Char('\n')))
- richText += QLatin1String("<center>") + line + QLatin1String("</center>");
+ for (const auto &line : QStringView{ plainText }.split(QLatin1Char('\n')))
+ richText += QString::fromLatin1("<center>%1</center>").arg(line);
richText += QLatin1String("</i></body></html>");
auto textEdit = createWidget1<QTextEdit>(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<QStringRef> words = sentence.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts);
- for (const QStringRef &word : words) {
+ const QList<QStringView> 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("<html><pre>") + contents + QStringLiteral("</pre></html>");
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;