Qt6: Port QtWayland from QStringRef to QStringView

Task-number: QTBUG-84319
Change-Id: I5dc2f4506c149e5f2793cd7cab083278b93a980e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Karsten Heimrich 2020-06-11 13:41:55 +02:00
parent 9ef67d0769
commit 132579d38c
2 changed files with 4 additions and 4 deletions

View File

@ -307,7 +307,7 @@ void QWaylandWindow::setWindowTitle(const QString &title)
// three bytes when converted to utf-8 (which is what libwayland uses), so divide by three.
const int maxLength = libwaylandMaxBufferSize / 3 - 100;
auto truncated = QStringRef(&formatted).left(maxLength);
auto truncated = QStringView{formatted}.left(maxLength);
if (truncated.length() < formatted.length()) {
qCWarning(lcQpaWayland) << "Window titles longer than" << maxLength << "characters are not supported."
<< "Truncating window title (from" << formatted.length() << "chars)";

View File

@ -265,17 +265,17 @@ int QWaylandInputMethodEventBuilder::indexFromWayland(const QString &text, int l
return base;
if (length < 0) {
const QByteArray &utf8 = text.leftRef(base).toUtf8();
const QByteArray &utf8 = QStringView{text}.left(base).toUtf8();
return QString::fromUtf8(utf8.left(qMax(utf8.length() + length, 0))).length();
} else {
const QByteArray &utf8 = text.midRef(base).toUtf8();
const QByteArray &utf8 = QStringView{text}.mid(base).toUtf8();
return QString::fromUtf8(utf8.left(length)).length() + base;
}
}
int QWaylandInputMethodEventBuilder::indexToWayland(const QString &text, int length, int base)
{
return text.midRef(base, length).toUtf8().size();
return QStringView{text}.mid(base, length).toUtf8().size();
}
QT_END_NAMESPACE