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;
}
case QXmlStreamReader::Characters: {
const QStringRef text = m_xmlReader.text();
const auto text = m_xmlReader.text();
if (m_currentTagName == CatchXml::ExpandedElement) {
m_currentExpression.append(text);
}
break;
}
case QXmlStreamReader::EndElement: {
const QStringRef currentTag = m_xmlReader.name();
const auto currentTag = m_xmlReader.name();
if (currentTag == CatchXml::SectionElement) {
sendResult(ResultType::TestEnd);

View File

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

View File

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

View File

@@ -333,13 +333,13 @@ void AbstractSettings::readDocumentation()
QStringList keys;
while (!(xml.atEnd() || xml.hasError())) {
if (xml.readNext() == QXmlStreamReader::StartElement) {
const QStringRef &name = xml.name();
if (name == Constants::DOCUMENTATION_XMLENTRY) {
const QStringView &name = xml.name();
if (name == QLatin1String(Constants::DOCUMENTATION_XMLENTRY)) {
keys.clear();
} else if (name == Constants::DOCUMENTATION_XMLKEY) {
} else if (name == QLatin1String(Constants::DOCUMENTATION_XMLKEY)) {
if (xml.readNext() == QXmlStreamReader::Characters)
keys << xml.text().toString();
} else if (name == Constants::DOCUMENTATION_XMLDOC) {
} else if (name == QLatin1String(Constants::DOCUMENTATION_XMLDOC)) {
if (xml.readNext() == QXmlStreamReader::Characters) {
m_docu << xml.text().toString();
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) {
const QString &filePath = s.mid(index1+1, index2-index1-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)) {
auto b = new Bookmark(lineNumber, this);
b->updateFileName(FilePath::fromString(filePath));

View File

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

View File

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

View File

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

View File

@@ -27,9 +27,12 @@
#include "glsleditor.h"
#include <glsl/glsllexer.h>
#include <glsl/glslparser.h>
#include <texteditor/textdocumentlayout.h>
#include <texteditor/textdocument.h>
#include <utils/porting.h>
#include <QDebug>
using namespace TextEditor;
@@ -151,7 +154,8 @@ void GlslHighlighter::highlightBlock(const QString &text)
highlightLine(text, tk.begin(), tk.length, formatForCategory(C_PREPROCESSOR));
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));
} 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())
{

View File

@@ -40,7 +40,7 @@ public:
protected:
void highlightBlock(const QString &text) override;
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

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
// 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())
return {};
@@ -104,9 +104,9 @@ static QVector<QSize> stringToSizes(const QString &s)
{
QVector<QSize> result;
const QString trimmed = s.trimmed();
const QVector<QStringRef> &sizes = trimmed.splitRef(',', Qt::SkipEmptyParts);
const QStringList &sizes = trimmed.split(',', Qt::SkipEmptyParts);
result.reserve(sizes.size());
for (const QStringRef &sizeSpec : sizes) {
for (const QString &sizeSpec : sizes) {
const QSize size = sizeFromString(sizeSpec);
if (!size.isValid() || size.isEmpty())
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
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));
}
// some keywords starts a new block
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")
|| ref == QLatin1String("var")
|| ref == QLatin1String("let")
@@ -140,7 +140,7 @@ bool NimIndenter::endsBlock(const QString &line, int state) const
// Some keywords end a block
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")
|| ref == QLatin1String("break")
|| ref == QLatin1String("continue");

View File

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

View File

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

View File

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