Fix build issues with Qt6

Change from QStringRef to QStringView at various places.

Task-number: QTCREATORBUG-24098
Change-Id: Ia7a634fa26464fbb2962724d5f0e188cecc68801
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2020-09-18 13:18:30 +02:00
parent 2a70bc1d09
commit 6225d33c28
15 changed files with 46 additions and 41 deletions

View File

@@ -133,14 +133,14 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
break; break;
} }
case QXmlStreamReader::Characters: { case QXmlStreamReader::Characters: {
const QStringRef text = m_xmlReader.text(); const auto text = m_xmlReader.text();
if (m_currentTagName == CatchXml::ExpandedElement) { if (m_currentTagName == CatchXml::ExpandedElement) {
m_currentExpression.append(text); m_currentExpression.append(text);
} }
break; break;
} }
case QXmlStreamReader::EndElement: { case QXmlStreamReader::EndElement: {
const QStringRef currentTag = m_xmlReader.name(); const auto currentTag = m_xmlReader.name();
if (currentTag == CatchXml::SectionElement) { if (currentTag == CatchXml::SectionElement) {
sendResult(ResultType::TestEnd); sendResult(ResultType::TestEnd);

View File

@@ -49,7 +49,7 @@ static QString decode(const QString& original)
const QRegularExpressionMatch match = it.next(); const QRegularExpressionMatch match = it.next();
const QString value = match.captured(1); const QString value = match.captured(1);
if (value.startsWith('x')) if (value.startsWith('x'))
result.replace(match.captured(0), QChar(value.midRef(1).toInt(nullptr, 16))); result.replace(match.captured(0), QChar(value.mid(1).toInt(nullptr, 16)));
else else
result.replace(match.captured(0), QChar(value.toInt(nullptr, 10))); result.replace(match.captured(0), QChar(value.toInt(nullptr, 10)));
} }
@@ -267,7 +267,7 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
} }
case QXmlStreamReader::Characters: { case QXmlStreamReader::Characters: {
m_expectTag = false; m_expectTag = false;
QStringRef text = m_xmlReader.text().trimmed(); const QStringView text = m_xmlReader.text().trimmed();
if (text.isEmpty()) if (text.isEmpty())
break; break;
@@ -278,7 +278,7 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
case Description: case Description:
if (!m_description.isEmpty()) if (!m_description.isEmpty())
m_description.append('\n'); m_description.append('\n');
m_description.append(text); m_description.append(text.toString());
break; break;
case QtVersion: case QtVersion:
m_description = trQtVersion(text.toString()); m_description = trQtVersion(text.toString());
@@ -299,7 +299,7 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
case QXmlStreamReader::EndElement: { case QXmlStreamReader::EndElement: {
m_expectTag = true; m_expectTag = true;
m_cdataMode = None; m_cdataMode = None;
const QStringRef currentTag = m_xmlReader.name(); const QStringView currentTag = m_xmlReader.name();
if (currentTag == QStringLiteral("TestFunction")) { if (currentTag == QStringLiteral("TestFunction")) {
sendFinishMessage(true); sendFinishMessage(true);
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1); m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
@@ -434,7 +434,7 @@ void QtTestOutputReader::processResultOutput(const QString &result, const QStrin
if (!description.isEmpty()) { if (!description.isEmpty()) {
if (!m_description.isEmpty()) if (!m_description.isEmpty())
m_description.append('\n'); m_description.append('\n');
m_description.append(description.midRef(1)); // cut the first whitespace m_description.append(description.mid(1)); // cut the first whitespace
} }
m_formerTestCase = m_testCase; m_formerTestCase = m_testCase;
} }

View File

@@ -67,7 +67,7 @@ const QString QtTestResult::outputString(bool selected) const
int breakPos = desc.indexOf('('); int breakPos = desc.indexOf('(');
output.append(": ").append(desc.left(breakPos)); output.append(": ").append(desc.left(breakPos));
if (selected) if (selected)
output.append('\n').append(desc.midRef(breakPos)); output.append('\n').append(desc.mid(breakPos));
} }
break; break;
default: default:

View File

@@ -333,13 +333,13 @@ void AbstractSettings::readDocumentation()
QStringList keys; QStringList keys;
while (!(xml.atEnd() || xml.hasError())) { while (!(xml.atEnd() || xml.hasError())) {
if (xml.readNext() == QXmlStreamReader::StartElement) { if (xml.readNext() == QXmlStreamReader::StartElement) {
const QStringRef &name = xml.name(); const QStringView &name = xml.name();
if (name == Constants::DOCUMENTATION_XMLENTRY) { if (name == QLatin1String(Constants::DOCUMENTATION_XMLENTRY)) {
keys.clear(); keys.clear();
} else if (name == Constants::DOCUMENTATION_XMLKEY) { } else if (name == QLatin1String(Constants::DOCUMENTATION_XMLKEY)) {
if (xml.readNext() == QXmlStreamReader::Characters) if (xml.readNext() == QXmlStreamReader::Characters)
keys << xml.text().toString(); keys << xml.text().toString();
} else if (name == Constants::DOCUMENTATION_XMLDOC) { } else if (name == QLatin1String(Constants::DOCUMENTATION_XMLDOC)) {
if (xml.readNext() == QXmlStreamReader::Characters) { if (xml.readNext() == QXmlStreamReader::Characters) {
m_docu << xml.text().toString(); m_docu << xml.text().toString();
const int index = m_docu.size() - 1; const int index = m_docu.size() - 1;

View File

@@ -743,7 +743,7 @@ void BookmarkManager::addBookmark(const QString &s)
if (index3 != -1 || index2 != -1 || index1 != -1) { if (index3 != -1 || index2 != -1 || index1 != -1) {
const QString &filePath = s.mid(index1+1, index2-index1-1); const QString &filePath = s.mid(index1+1, index2-index1-1);
const QString &note = s.mid(index3 + 1); const QString &note = s.mid(index3 + 1);
const int lineNumber = s.midRef(index2 + 1, index3 - index2 - 1).toInt(); const int lineNumber = s.mid(index2 + 1, index3 - index2 - 1).toInt();
if (!filePath.isEmpty() && !findBookmark(FilePath::fromString(filePath), lineNumber)) { if (!filePath.isEmpty() && !findBookmark(FilePath::fromString(filePath), lineNumber)) {
auto b = new Bookmark(lineNumber, this); auto b = new Bookmark(lineNumber, this);
b->updateFileName(FilePath::fromString(filePath)); b->updateFileName(FilePath::fromString(filePath));

View File

@@ -101,7 +101,7 @@ static bool parse(const QString &fileName,
QXmlStreamReader reader(&file); QXmlStreamReader reader(&file);
while (!reader.atEnd()) { while (!reader.atEnd()) {
if (reader.readNext() == QXmlStreamReader::StartElement) { if (reader.readNext() == QXmlStreamReader::StartElement) {
const QStringRef elementName = reader.name(); const auto elementName = reader.name();
// Check start element // Check start element
if (elementCount == 0 && elementName != QLatin1String(pasterElementC)) { if (elementCount == 0 && elementName != QLatin1String(pasterElementC)) {
*errorMessage = FileShareProtocol::tr("%1 does not appear to be a paster file.").arg(fileName); *errorMessage = FileShareProtocol::tr("%1 does not appear to be a paster file.").arg(fileName);

View File

@@ -25,6 +25,7 @@
#include "pastebindotcomprotocol.h" #include "pastebindotcomprotocol.h"
#include <utils/porting.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
@@ -149,7 +150,7 @@ void PasteBinDotComProtocol::fetch(const QString &id)
QString link = QLatin1String(PASTEBIN_BASE) + QLatin1String(PASTEBIN_RAW); QString link = QLatin1String(PASTEBIN_BASE) + QLatin1String(PASTEBIN_RAW);
if (id.startsWith(QLatin1String("http://"))) if (id.startsWith(QLatin1String("http://")))
link.append(id.midRef(id.lastIndexOf(QLatin1Char('/')) + 1)); link.append(id.mid(id.lastIndexOf(QLatin1Char('/')) + 1));
else else
link.append(id); link.append(id);
@@ -227,7 +228,7 @@ QDebug operator<<(QDebug d, const QXmlStreamAttributes &al)
static inline ParseState nextOpeningState(ParseState current, const QXmlStreamReader &reader) static inline ParseState nextOpeningState(ParseState current, const QXmlStreamReader &reader)
{ {
const QStringRef &element = reader.name(); const auto element = reader.name();
switch (current) { switch (current) {
case OutSideTable: case OutSideTable:
// Trigger on main table only. // Trigger on main table only.
@@ -259,7 +260,7 @@ static inline ParseState nextOpeningState(ParseState current, const QXmlStreamRe
return ParseError; return ParseError;
} }
static inline ParseState nextClosingState(ParseState current, const QStringRef &element) static inline ParseState nextClosingState(ParseState current, const Utils::StringView &element)
{ {
switch (current) { switch (current) {
case OutSideTable: case OutSideTable:

View File

@@ -5551,7 +5551,7 @@ bool FakeVimHandler::Private::handleExSubstituteCommand(const ExCommand &cmd)
if (cmd.cmd.isEmpty()) { if (cmd.cmd.isEmpty()) {
// keep previous substitution flags on '&&' and '~&' // keep previous substitution flags on '&&' and '~&'
if (line.size() > 1 && line[1] == '&') if (line.size() > 1 && line[1] == '&')
g.lastSubstituteFlags += line.midRef(2); g.lastSubstituteFlags += line.mid(2);
else else
g.lastSubstituteFlags = line.mid(1); g.lastSubstituteFlags = line.mid(1);
if (line[0] == '~') if (line[0] == '~')

View File

@@ -27,9 +27,12 @@
#include "glsleditor.h" #include "glsleditor.h"
#include <glsl/glsllexer.h> #include <glsl/glsllexer.h>
#include <glsl/glslparser.h> #include <glsl/glslparser.h>
#include <texteditor/textdocumentlayout.h> #include <texteditor/textdocumentlayout.h>
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include <utils/porting.h>
#include <QDebug> #include <QDebug>
using namespace TextEditor; using namespace TextEditor;
@@ -151,7 +154,8 @@ void GlslHighlighter::highlightBlock(const QString &text)
highlightLine(text, tk.begin(), tk.length, formatForCategory(C_PREPROCESSOR)); highlightLine(text, tk.begin(), tk.length, formatForCategory(C_PREPROCESSOR));
highlightAsPreprocessor = true; highlightAsPreprocessor = true;
} else if (highlightCurrentWordAsPreprocessor && isPPKeyword(text.midRef(tk.begin(), tk.length))) { } else if (highlightCurrentWordAsPreprocessor
&& isPPKeyword(Utils::midView(text, tk.begin(), tk.length))) {
setFormat(tk.begin(), tk.length, formatForCategory(C_PREPROCESSOR)); setFormat(tk.begin(), tk.length, formatForCategory(C_PREPROCESSOR));
} else if (tk.is(GLSL::Parser::T_NUMBER)) { } else if (tk.is(GLSL::Parser::T_NUMBER)) {
@@ -256,7 +260,7 @@ void GlslHighlighter::highlightLine(const QString &text, int position, int lengt
} }
} }
bool GlslHighlighter::isPPKeyword(const QStringRef &text) const bool GlslHighlighter::isPPKeyword(const QStringView &text) const
{ {
switch (text.length()) switch (text.length())
{ {

View File

@@ -40,7 +40,7 @@ public:
protected: protected:
void highlightBlock(const QString &text) override; void highlightBlock(const QString &text) override;
void highlightLine(const QString &text, int position, int length, const QTextCharFormat &format); void highlightLine(const QString &text, int position, int length, const QTextCharFormat &format);
bool isPPKeyword(const QStringRef &text) const; bool isPPKeyword(const QStringView &text) const;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -54,7 +54,7 @@ static const int standardIconSizesValues[] = {16, 24, 32, 48, 64, 128, 256};
// Helpers to convert a size specifications from QString to QSize // Helpers to convert a size specifications from QString to QSize
// and vv. The format is '2x4' or '4' as shortcut for '4x4'. // and vv. The format is '2x4' or '4' as shortcut for '4x4'.
static QSize sizeFromString(const QStringRef &r) static QSize sizeFromString(const QString &r)
{ {
if (r.isEmpty()) if (r.isEmpty())
return {}; return {};
@@ -104,9 +104,9 @@ static QVector<QSize> stringToSizes(const QString &s)
{ {
QVector<QSize> result; QVector<QSize> result;
const QString trimmed = s.trimmed(); const QString trimmed = s.trimmed();
const QVector<QStringRef> &sizes = trimmed.splitRef(',', Qt::SkipEmptyParts); const QStringList &sizes = trimmed.split(',', Qt::SkipEmptyParts);
result.reserve(sizes.size()); result.reserve(sizes.size());
for (const QStringRef &sizeSpec : sizes) { for (const QString &sizeSpec : sizes) {
const QSize size = sizeFromString(sizeSpec); const QSize size = sizeFromString(sizeSpec);
if (!size.isValid() || size.isEmpty()) if (!size.isValid() || size.isEmpty())
return {}; return {};

View File

@@ -109,13 +109,13 @@ bool NimIndenter::startsBlock(const QString &line, int state) const
// electric characters start a new block, and are operators // electric characters start a new block, and are operators
if (previous.type == NimLexer::TokenType::Operator) { if (previous.type == NimLexer::TokenType::Operator) {
QStringRef ref = line.midRef(previous.begin, previous.length); QStringView ref = QStringView(line).mid(previous.begin, previous.length);
return ref.isEmpty() ? false : electricCharacters().contains(ref.at(0)); return ref.isEmpty() ? false : electricCharacters().contains(ref.at(0));
} }
// some keywords starts a new block // some keywords starts a new block
if (previous.type == NimLexer::TokenType::Keyword) { if (previous.type == NimLexer::TokenType::Keyword) {
QStringRef ref = line.midRef(previous.begin, previous.length); QStringView ref = QStringView(line).mid(previous.begin, previous.length);
return ref == QLatin1String("type") return ref == QLatin1String("type")
|| ref == QLatin1String("var") || ref == QLatin1String("var")
|| ref == QLatin1String("let") || ref == QLatin1String("let")
@@ -140,7 +140,7 @@ bool NimIndenter::endsBlock(const QString &line, int state) const
// Some keywords end a block // Some keywords end a block
if (previous.type == NimLexer::TokenType::Keyword) { if (previous.type == NimLexer::TokenType::Keyword) {
QStringRef ref = line.midRef(previous.begin, previous.length); QStringView ref = QStringView(line).mid(previous.begin, previous.length);
return ref == QLatin1String("return") return ref == QLatin1String("return")
|| ref == QLatin1String("break") || ref == QLatin1String("break")
|| ref == QLatin1String("continue"); || ref == QLatin1String("continue");

View File

@@ -182,9 +182,9 @@ QString ParseData::prettyStringForEvent(const QString &event)
type = ParseData::Private::tr("Instruction"); type = ParseData::Private::tr("Instruction");
else if (event.at(0) == 'D') else if (event.at(0) == 'D')
type = ParseData::Private::tr("Cache"); type = ParseData::Private::tr("Cache");
else if (event.leftRef(2) == "Bc") else if (event.left(2) == "Bc")
type = ParseData::Private::tr("Conditional branches"); type = ParseData::Private::tr("Conditional branches");
else if (event.leftRef(2) == "Bi") else if (event.left(2) == "Bi")
type = ParseData::Private::tr("Indirect branches"); type = ParseData::Private::tr("Indirect branches");
QStringList prettyString; QStringList prettyString;

View File

@@ -321,7 +321,7 @@ void Parser::Private::parseHeader(QIODevice *device)
} else if (line.startsWith("summary: ")) { } else if (line.startsWith("summary: ")) {
QString values = getValue(line, 9); QString values = getValue(line, 9);
uint i = 0; uint i = 0;
foreach (const QStringRef &value, values.splitRef(' ', Qt::SkipEmptyParts)) foreach (const QString &value, values.split(' ', Qt::SkipEmptyParts))
data->setTotalCost(i++, value.toULongLong()); data->setTotalCost(i++, value.toULongLong());
} else if (!line.trimmed().isEmpty()) { } else if (!line.trimmed().isEmpty()) {
// handle line and exit parseHeader // handle line and exit parseHeader

View File

@@ -303,7 +303,7 @@ XWhat Parser::Private::parseXWhat()
blockingReadNext(); blockingReadNext();
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "text") if (name == "text")
what.text = blockingReadElementText(); what.text = blockingReadElementText();
else if (name == "leakedbytes") else if (name == "leakedbytes")
@@ -325,7 +325,7 @@ XauxWhat Parser::Private::parseXauxWhat()
blockingReadNext(); blockingReadNext();
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "text") if (name == "text")
what.text = blockingReadElementText(); what.text = blockingReadElementText();
else if (name == "file") else if (name == "file")
@@ -433,7 +433,7 @@ void Parser::Private::parseError()
break; break;
if (reader.isStartElement()) if (reader.isStartElement())
lastAuxWhat++; lastAuxWhat++;
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "unique") { if (name == "unique") {
e.setUnique(parseHex(blockingReadElementText(), "unique")); e.setUnique(parseHex(blockingReadElementText(), "unique"));
} else if (name == "tid") { } else if (name == "tid") {
@@ -504,7 +504,7 @@ Frame Parser::Private::parseFrame()
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
if (reader.isStartElement()) { if (reader.isStartElement()) {
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "ip") if (name == "ip")
frame.setInstructionPointer(parseHex(blockingReadElementText(), "error/frame/ip")); frame.setInstructionPointer(parseHex(blockingReadElementText(), "error/frame/ip"));
else if (name == "obj") else if (name == "obj")
@@ -534,7 +534,7 @@ void Parser::Private::parseAnnounceThread()
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
if (reader.isStartElement()) { if (reader.isStartElement()) {
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "hthreadid") if (name == "hthreadid")
at.setHelgrindThreadId(parseInt64(blockingReadElementText(), "announcethread/hthreadid")); at.setHelgrindThreadId(parseInt64(blockingReadElementText(), "announcethread/hthreadid"));
else if (name == "stack") else if (name == "stack")
@@ -562,7 +562,7 @@ void Parser::Private::parseErrorCounts()
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
if (reader.isStartElement()) { if (reader.isStartElement()) {
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "unique") if (name == "unique")
unique = parseHex(blockingReadElementText(), "errorcounts/pair/unique"); unique = parseHex(blockingReadElementText(), "errorcounts/pair/unique");
else if (name == "count") else if (name == "count")
@@ -595,7 +595,7 @@ void Parser::Private::parseSuppressionCounts()
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
if (reader.isStartElement()) { if (reader.isStartElement()) {
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "name") if (name == "name")
pairName = blockingReadElementText(); pairName = blockingReadElementText();
else if (name == "count") else if (name == "count")
@@ -621,7 +621,7 @@ void Parser::Private::parseStatus()
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
if (reader.isStartElement()) { if (reader.isStartElement()) {
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "state") if (name == "state")
s.setState(parseState(blockingReadElementText())); s.setState(parseState(blockingReadElementText()));
else if (name == "time") else if (name == "time")
@@ -659,7 +659,7 @@ SuppressionFrame Parser::Private::parseSuppressionFrame()
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
if (reader.isStartElement()) { if (reader.isStartElement()) {
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "obj") if (name == "obj")
frame.setObject(blockingReadElementText()); frame.setObject(blockingReadElementText());
else if (name == "fun") else if (name == "fun")
@@ -681,7 +681,7 @@ Suppression Parser::Private::parseSuppression()
if (reader.isEndElement()) if (reader.isEndElement())
break; break;
if (reader.isStartElement()) { if (reader.isStartElement()) {
const QStringRef name = reader.name(); const auto name = reader.name();
if (name == "sname") if (name == "sname")
supp.setName(blockingReadElementText()); supp.setName(blockingReadElementText());
else if (name == "skind") else if (name == "skind")
@@ -707,7 +707,7 @@ void Parser::Private::parse(QIODevice *device)
try { try {
while (notAtEnd()) { while (notAtEnd()) {
blockingReadNext(); blockingReadNext();
QStringRef name = reader.name(); const auto name = reader.name();
if (name == "error") if (name == "error")
parseError(); parseError();
else if (name == "announcethread") else if (name == "announcethread")