forked from qt-creator/qt-creator
Utils: Fix build with Qt6
Do not use QStringRef related API, replace with QStringView where appropriate. Adapt to removal of QAbstractItemView::viewOptions(). Task-number: QTCREATORBUG-24098 Change-Id: I5a7a9821984583222083733f91b46df39c21d592 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
add_qtc_library(Utils
|
||||
DEPENDS Qt5::Xml
|
||||
PUBLIC_DEPENDS Qt5::Concurrent Qt5::Core Qt5::Network Qt5::Qml Qt5::Gui Qt5::Widgets
|
||||
PUBLIC_DEPENDS
|
||||
Qt5::Concurrent Qt5::Core Qt5::Network Qt5::Qml Qt5::Gui Qt5::Widgets
|
||||
Qt6Core5Compat
|
||||
DEFINES
|
||||
"QTC_REL_TOOLS_PATH=\"${RELATIVE_LIBEXEC_PATH}\""
|
||||
SOURCES
|
||||
|
@@ -152,7 +152,7 @@ QList<FormattedText> AnsiEscapeCodeHandler::parseText(const FormattedText &input
|
||||
}
|
||||
break;
|
||||
}
|
||||
m_pendingText += strippedText.midRef(0, escape.length());
|
||||
m_pendingText += strippedText.mid(0, escape.length());
|
||||
strippedText.remove(0, escape.length());
|
||||
|
||||
// \e[K is not supported. Just strip it.
|
||||
@@ -174,7 +174,7 @@ QList<FormattedText> AnsiEscapeCodeHandler::parseText(const FormattedText &input
|
||||
break;
|
||||
strNumber.clear();
|
||||
}
|
||||
m_pendingText += strippedText.midRef(0, 1);
|
||||
m_pendingText += strippedText.mid(0, 1);
|
||||
strippedText.remove(0, 1);
|
||||
}
|
||||
if (strippedText.isEmpty())
|
||||
|
@@ -78,7 +78,7 @@ static int commonOverlap(const QString &text1, const QString &text2)
|
||||
const int text2Count = text2.count();
|
||||
const int maxCount = qMin(text1Count, text2Count);
|
||||
while (i < maxCount) {
|
||||
if (text1.midRef(text1Count - maxCount + i) == text2.leftRef(maxCount - i))
|
||||
if (QStringView(text1).mid(text1Count - maxCount + i) == QStringView(text2).left(maxCount - i))
|
||||
return maxCount - i;
|
||||
i++;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ QList<Diff> Differ::moveWhitespaceIntoEqualities(const QList<Diff> &input)
|
||||
}
|
||||
if (j > 0) {
|
||||
// diff starts with j whitespaces, move them to the previous diff
|
||||
previousDiff.text.append(diff.text.leftRef(j));
|
||||
previousDiff.text.append(diff.text.left(j));
|
||||
diff.text = diff.text.mid(j);
|
||||
}
|
||||
}
|
||||
|
@@ -192,10 +192,10 @@ bool FileInProjectFinder::findFileOrDirectory(const QString &originalPath, FileH
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto segments = originalPath.splitRef('/', Qt::SkipEmptyParts);
|
||||
const auto segments = originalPath.split('/', Qt::SkipEmptyParts);
|
||||
const PathMappingNode *node = &m_pathMapRoot;
|
||||
for (const auto &segment : segments) {
|
||||
auto it = node->children.find(segment.toString());
|
||||
auto it = node->children.find(segment);
|
||||
if (it == node->children.end()) {
|
||||
node = nullptr;
|
||||
break;
|
||||
|
@@ -123,7 +123,7 @@ bool MimeGlobPattern::matchFileName(const QString &inputFilename) const
|
||||
if (starCount == 1 && m_pattern.at(pattern_len - 1) == QLatin1Char('*')) {
|
||||
if (len + 1 < pattern_len) return false;
|
||||
if (m_pattern.at(0) == QLatin1Char('*'))
|
||||
return filename.indexOf(m_pattern.midRef(1, pattern_len - 2)) != -1;
|
||||
return filename.indexOf(QStringView(m_pattern).mid(1, pattern_len - 2)) != -1;
|
||||
|
||||
const QChar *c1 = m_pattern.unicode();
|
||||
const QChar *c2 = filename.unicode();
|
||||
|
@@ -107,7 +107,8 @@ static const char matchMaskAttributeC[] = "mask";
|
||||
Overwrite to process the sequence of parsed data
|
||||
*/
|
||||
|
||||
MimeTypeParserBase::ParseState MimeTypeParserBase::nextState(ParseState currentState, const QStringRef &startElement)
|
||||
MimeTypeParserBase::ParseState MimeTypeParserBase::nextState(ParseState currentState,
|
||||
const QStringView &startElement)
|
||||
{
|
||||
switch (currentState) {
|
||||
case ParseBeginning:
|
||||
@@ -320,7 +321,7 @@ bool MimeTypeParserBase::parse(const QByteArray &content, const QString &fileNam
|
||||
// continue switch QXmlStreamReader::Token...
|
||||
case QXmlStreamReader::EndElement: // Finished element
|
||||
{
|
||||
const QStringRef elementName = reader.name();
|
||||
const QStringView elementName = reader.name();
|
||||
if (elementName == QLatin1String(mimeTypeTagC)) {
|
||||
if (!ignoreCurrentMimeType) {
|
||||
if (!process(MimeType(data), errorMessage))
|
||||
|
@@ -91,7 +91,7 @@ private:
|
||||
ParseError
|
||||
};
|
||||
|
||||
static ParseState nextState(ParseState currentState, const QStringRef &startElement);
|
||||
static ParseState nextState(ParseState currentState, const QStringView &startElement);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -67,8 +67,15 @@ void NavigationTreeView::scrollTo(const QModelIndex &index, QAbstractItemView::S
|
||||
QRect itemRect = visualRect(index);
|
||||
|
||||
QAbstractItemDelegate *delegate = itemDelegate(index);
|
||||
if (delegate)
|
||||
itemRect.setWidth(delegate->sizeHint(viewOptions(), index).width());
|
||||
if (delegate) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
const QStyleOptionViewItem option = viewOptions();
|
||||
#else
|
||||
QStyleOptionViewItem option;
|
||||
initViewItemOption(&option);
|
||||
#endif
|
||||
itemRect.setWidth(delegate->sizeHint(option, index).width());
|
||||
}
|
||||
|
||||
if (itemRect.x() - indentation() < 0) {
|
||||
// scroll so left edge minus one indent of item is visible
|
||||
|
@@ -188,13 +188,13 @@ private:
|
||||
enum Element { QtCreatorElement, DataElement, VariableElement,
|
||||
SimpleValueElement, ListValueElement, MapValueElement, UnknownElement };
|
||||
|
||||
Element element(const QStringRef &r) const;
|
||||
Element element(const QStringView &r) const;
|
||||
static inline bool isValueElement(Element e)
|
||||
{ return e == SimpleValueElement || e == ListValueElement || e == MapValueElement; }
|
||||
QVariant readSimpleValue(QXmlStreamReader &r, const QXmlStreamAttributes &attributes) const;
|
||||
|
||||
bool handleStartElement(QXmlStreamReader &r);
|
||||
bool handleEndElement(const QStringRef &name);
|
||||
bool handleEndElement(const QStringView &name);
|
||||
|
||||
static QString formatWarning(const QXmlStreamReader &r, const QString &message);
|
||||
|
||||
@@ -233,7 +233,7 @@ QVariantMap ParseContext::parse(QFile &file)
|
||||
|
||||
bool ParseContext::handleStartElement(QXmlStreamReader &r)
|
||||
{
|
||||
const QStringRef name = r.name();
|
||||
const QStringView name = r.name();
|
||||
const Element e = element(name);
|
||||
if (e == VariableElement) {
|
||||
m_currentVariableName = r.readElementText();
|
||||
@@ -268,7 +268,7 @@ bool ParseContext::handleStartElement(QXmlStreamReader &r)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParseContext::handleEndElement(const QStringRef &name)
|
||||
bool ParseContext::handleEndElement(const QStringView &name)
|
||||
{
|
||||
const Element e = element(name);
|
||||
if (ParseContext::isValueElement(e)) {
|
||||
@@ -297,7 +297,7 @@ QString ParseContext::formatWarning(const QXmlStreamReader &r, const QString &me
|
||||
return result;
|
||||
}
|
||||
|
||||
ParseContext::Element ParseContext::element(const QStringRef &r) const
|
||||
ParseContext::Element ParseContext::element(const QStringView &r) const
|
||||
{
|
||||
if (r == valueElement)
|
||||
return SimpleValueElement;
|
||||
@@ -317,7 +317,7 @@ ParseContext::Element ParseContext::element(const QStringRef &r) const
|
||||
QVariant ParseContext::readSimpleValue(QXmlStreamReader &r, const QXmlStreamAttributes &attributes) const
|
||||
{
|
||||
// Simple value
|
||||
const QStringRef type = attributes.value(typeAttribute);
|
||||
const QStringView type = attributes.value(typeAttribute);
|
||||
const QString text = r.readElementText();
|
||||
if (type == QLatin1String("QChar")) { // Workaround: QTBUG-12345
|
||||
QTC_ASSERT(text.size() == 1, return QVariant());
|
||||
|
@@ -352,7 +352,7 @@ static QStringList splitArgsUnix(const QString &args, bool abortOnMeta,
|
||||
goto quoteerr;
|
||||
c = args.unicode()[pos++];
|
||||
} while (c != QLatin1Char('\''));
|
||||
cret += args.midRef(spos, pos - spos - 1);
|
||||
cret += args.mid(spos, pos - spos - 1);
|
||||
hadWord = true;
|
||||
} else if (c == QLatin1Char('"')) {
|
||||
for (;;) {
|
||||
|
Reference in New Issue
Block a user