Port platform plugins to QStringView

Task-number: QTBUG-84319
Change-Id: If409ba1c99f30c7ab32c7cc826c7f303ccf18c1d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Lars Knoll 2020-05-27 12:17:46 +02:00 committed by Karsten Heimrich
parent 9b8d4a9e45
commit 29ad4f8c09
10 changed files with 17 additions and 11 deletions

View File

@ -39,6 +39,8 @@ qt_internal_add_plugin(QAndroidIntegrationPlugin
qandroidplatformtheme.cpp qandroidplatformtheme.h
qandroidplatformwindow.cpp qandroidplatformwindow.h
qandroidsystemlocale.cpp qandroidsystemlocale.h
DEFINES
QT_USE_QSTRINGBUILDER
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
${QT_SOURCE_TREE}/src/3rdparty/android

View File

@ -40,6 +40,8 @@ qt_internal_add_plugin(QAndroidIntegrationPlugin
qandroidplatformtheme.cpp qandroidplatformtheme.h
qandroidplatformwindow.cpp qandroidplatformwindow.h
qandroidsystemlocale.cpp qandroidsystemlocale.h
DEFINES
QT_USE_QSTRINGBUILDER
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
${QT_SOURCE_TREE}/src/3rdparty/android

View File

@ -14,6 +14,8 @@ INCLUDEPATH += \
$$PWD \
$$QT_SOURCE_TREE/src/3rdparty/android
DEFINES += QT_USE_QSTRINGBUILDER
SOURCES += $$PWD/main.cpp \
$$PWD/androidcontentfileengine.cpp \
$$PWD/androiddeadlockprotector.cpp \

View File

@ -1224,7 +1224,7 @@ jint QAndroidInputContext::getCursorCapsMode(jint /*reqModes*/)
QString surroundingText = query->value(Qt::ImSurroundingText).toString();
surroundingText.truncate(localPos);
if (focusObjectIsComposing())
surroundingText += m_composingText.leftRef(m_composingCursor - m_composingTextStart);
surroundingText += QStringView{m_composingText}.left(m_composingCursor - m_composingTextStart);
// Add a character to see if it is at the end of the sentence or not
QTextBoundaryFinder finder(QTextBoundaryFinder::Sentence, surroundingText + QLatin1Char('A'));
finder.setPosition(surroundingText.length());
@ -1330,7 +1330,7 @@ QString QAndroidInputContext::getTextAfterCursor(jint length, jint /*flags*/)
if (focusObjectIsComposing()) {
// Controls do not report preedit text, so we have to add it
const int cursorPosInsidePreedit = m_composingCursor - m_composingTextStart;
text = m_composingText.midRef(cursorPosInsidePreedit) + text;
text = QStringView{m_composingText}.mid(cursorPosInsidePreedit) + text;
} else {
// We must not return selected text if there is any
QSharedPointer<QInputMethodQueryEvent> query =
@ -1370,7 +1370,7 @@ QString QAndroidInputContext::getTextBeforeCursor(jint length, jint /*flags*/)
if (focusObjectIsComposing()) {
// Controls do not report preedit text, so we have to add it
const int cursorPosInsidePreedit = m_composingCursor - m_composingTextStart;
text += m_composingText.leftRef(cursorPosInsidePreedit);
text += QStringView{m_composingText}.left(cursorPosInsidePreedit);
} else {
// We must not return selected text if there is any
QSharedPointer<QInputMethodQueryEvent> query =
@ -1529,7 +1529,7 @@ jboolean QAndroidInputContext::setComposingRegion(jint start, jint end)
const int additionalSuffixLen = after.length() - (text.length() - cursorPos);
if (additionalSuffixLen > 0)
text += after.rightRef(additionalSuffixLen);
text += QStringView{after}.right(additionalSuffixLen);
}
if (start < textOffset) {

View File

@ -191,7 +191,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
+ (id) lineNumberForIndex: (int)index forText:(const QString &)text
{
QStringRef textBefore = QStringRef(&text, 0, index);
auto textBefore = QStringView(text).left(index);
int newlines = textBefore.count(QLatin1Char('\n'));
return @(newlines);
}

View File

@ -136,7 +136,7 @@ static inline int getContextCapabilities(const QStringList &paramList)
int contextCapabilities = SCREEN_APPLICATION_CONTEXT;
for (const QString &param : paramList) {
if (param.startsWith(contextCapabilitiesPrefix)) {
QStringRef value = param.midRef(contextCapabilitiesPrefix.length());
auto value = QStringView{param}.mid(contextCapabilitiesPrefix.length());
bool ok = false;
contextCapabilities = value.toInt(&ok, 0);
if (!ok)

View File

@ -90,7 +90,7 @@ static QSize determineScreenSize(screen_display_t display, bool primaryScreen) {
const QString envPhySizeStr = qgetenv("QQNX_PHYSICAL_SCREEN_SIZE");
if (!envPhySizeStr.isEmpty()) {
const auto envPhySizeStrList = envPhySizeStr.splitRef(QLatin1Char(','));
const auto envPhySizeStrList = QStringView{envPhySizeStr}.split(QLatin1Char(','));
const int envWidth = envPhySizeStrList.size() == 2 ? envPhySizeStrList[0].toInt() : -1;
const int envHeight = envPhySizeStrList.size() == 2 ? envPhySizeStrList[1].toInt() : -1;

View File

@ -167,7 +167,7 @@ bool parseIntOption(const QString &parameter,const QLatin1String &option,
if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != u'=')
return false;
bool ok;
const QStringRef valueRef = parameter.rightRef(valueLength);
const auto valueRef = QStringView{parameter}.right(valueLength);
const int value = valueRef.toInt(&ok);
if (ok) {
if (value >= minimumValue && value <= maximumValue)

View File

@ -1413,7 +1413,7 @@ static QString customMimeType(const QString &mimeType, int *lindex = nullptr)
const int endPos = mimeType.indexOf(u';', beginPos + 1);
const int indexStartPos = beginPos + 7;
if (lindex)
*lindex = mimeType.midRef(indexStartPos, endPos == -1 ? endPos : endPos - indexStartPos).toInt();
*lindex = QStringView{mimeType}.mid(indexStartPos, endPos == -1 ? endPos : endPos - indexStartPos).toInt();
} else {
if (lindex)
*lindex = -1;

View File

@ -195,10 +195,10 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
reinterpret_cast<const char16_t *>(data.constData()), data.size() / 2);
if (!str.isNull()) {
if (format == QLatin1String("text/uri-list")) {
const auto urls = str.splitRef(QLatin1Char('\n'));
const auto urls = QStringView{str}.split(QLatin1Char('\n'));
QList<QVariant> list;
list.reserve(urls.size());
for (const QStringRef &s : urls) {
for (const QStringView &s : urls) {
const QUrl url(s.trimmed().toString());
if (url.isValid())
list.append(url);