forked from qt-creator/qt-creator
Update mime database from Qt
qtbase/b6251958932be5966258f362dc9bb7c7475d2d0a QtCore: Replace remaining uses of QLatin1String with QLatin1StringView Change-Id: I316351af0d91a727f2775c252176b77988335c74 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -255,7 +255,7 @@ void MimeMagicRule::init(QString *errorString)
|
||||
if (Q_UNLIKELY(!ok)) {
|
||||
m_type = Invalid;
|
||||
if (errorString)
|
||||
*errorString = "Invalid magic rule value \""_L1 + QLatin1String(m_value) + u'"';
|
||||
*errorString = "Invalid magic rule value \""_L1 + QLatin1StringView(m_value) + u'"';
|
||||
return;
|
||||
}
|
||||
m_numberMask = !m_mask.isEmpty() ? m_mask.toUInt(&ok, 0) : 0; // autodetect base
|
||||
@@ -269,7 +269,7 @@ void MimeMagicRule::init(QString *errorString)
|
||||
if (Q_UNLIKELY(m_mask.size() < 4 || !m_mask.startsWith("0x"))) {
|
||||
m_type = Invalid;
|
||||
if (errorString)
|
||||
*errorString = "Invalid magic rule mask \""_L1 + QLatin1String(m_mask) + u'"';
|
||||
*errorString = "Invalid magic rule mask \""_L1 + QLatin1StringView(m_mask) + u'"';
|
||||
return;
|
||||
}
|
||||
const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData(
|
||||
@@ -277,7 +277,7 @@ void MimeMagicRule::init(QString *errorString)
|
||||
if (Q_UNLIKELY(tempMask.size() != m_pattern.size())) {
|
||||
m_type = Invalid;
|
||||
if (errorString)
|
||||
*errorString = "Invalid magic rule mask size \""_L1 + QLatin1String(m_mask) + u'"';
|
||||
*errorString = "Invalid magic rule mask size \""_L1 + QLatin1StringView(m_mask) + u'"';
|
||||
return;
|
||||
}
|
||||
m_mask = tempMask;
|
||||
|
@@ -255,7 +255,7 @@ void MimeBinaryProvider::matchGlobList(MimeGlobMatchResult &result,
|
||||
const int weight = flagsAndWeight & 0xff;
|
||||
const bool caseSensitive = flagsAndWeight & 0x100;
|
||||
const Qt::CaseSensitivity qtCaseSensitive = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
||||
const QString pattern = QLatin1String(cacheFile->getCharStar(globOffset));
|
||||
const QString pattern = QLatin1StringView(cacheFile->getCharStar(globOffset));
|
||||
|
||||
const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);
|
||||
if (m_overriddenMimeTypes.contains(QLatin1String(mimeType)))
|
||||
@@ -264,7 +264,7 @@ void MimeBinaryProvider::matchGlobList(MimeGlobMatchResult &result,
|
||||
MimeGlobPattern glob(pattern, QString() /*unused*/, weight, qtCaseSensitive);
|
||||
|
||||
if (glob.matchFileName(fileName))
|
||||
result.addMatch(QLatin1String(mimeType), weight, pattern);
|
||||
result.addMatch(QLatin1StringView(mimeType), weight, pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ bool MimeBinaryProvider::matchSuffixTree(MimeGlobMatchResult &result,
|
||||
const int weight = flagsAndWeight & 0xff;
|
||||
const bool caseSensitive = flagsAndWeight & 0x100;
|
||||
if (caseSensitiveCheck || !caseSensitive) {
|
||||
result.addMatch(QLatin1String(mimeType), weight,
|
||||
result.addMatch(QLatin1StringView(mimeType), weight,
|
||||
u'*' + QStringView{fileName}.mid(charPos + 1),
|
||||
fileName.size() - charPos - 2);
|
||||
success = true;
|
||||
@@ -374,7 +374,7 @@ void MimeBinaryProvider::findByMagic(const QByteArray &data, int *accuracyPtr, M
|
||||
*accuracyPtr = m_cacheFile->getUint32(off);
|
||||
// Return the first match. We have no rules for conflicting magic data...
|
||||
// (mime.cache itself is sorted, but what about local overrides with a lower prio?)
|
||||
candidate = mimeTypeForNameUnchecked(QLatin1String(mimeType));
|
||||
candidate = mimeTypeForNameUnchecked(QLatin1StringView(mimeType));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -433,7 +433,7 @@ QString MimeBinaryProvider::resolveAlias(const QString &name)
|
||||
} else {
|
||||
const int mimeOffset = m_cacheFile->getUint32(off + 4);
|
||||
const char *mimeType = m_cacheFile->getCharStar(mimeOffset);
|
||||
return QLatin1String(mimeType);
|
||||
return QLatin1StringView(mimeType);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
@@ -575,7 +575,8 @@ bool MimeBinaryProvider::loadMimeTypePrivate(MimeTypePrivate &data)
|
||||
}
|
||||
|
||||
// Binary search in the icons or generic-icons list
|
||||
QLatin1String MimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime)
|
||||
QLatin1StringView MimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posListOffset,
|
||||
const QByteArray &inputMime)
|
||||
{
|
||||
const int iconsListOffset = cacheFile->getUint32(posListOffset);
|
||||
const int numIcons = cacheFile->getUint32(iconsListOffset);
|
||||
@@ -593,16 +594,16 @@ QLatin1String MimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posListO
|
||||
end = medium - 1;
|
||||
else {
|
||||
const int iconOffset = cacheFile->getUint32(off + 4);
|
||||
return QLatin1String(cacheFile->getCharStar(iconOffset));
|
||||
return QLatin1StringView(cacheFile->getCharStar(iconOffset));
|
||||
}
|
||||
}
|
||||
return QLatin1String();
|
||||
return QLatin1StringView();
|
||||
}
|
||||
|
||||
void MimeBinaryProvider::loadIcon(MimeTypePrivate &data)
|
||||
{
|
||||
const QByteArray inputMime = data.name.toLatin1();
|
||||
const QLatin1String icon = iconForMime(m_cacheFile, PosIconsListOffset, inputMime);
|
||||
const QLatin1StringView icon = iconForMime(m_cacheFile, PosIconsListOffset, inputMime);
|
||||
if (!icon.isEmpty()) {
|
||||
data.iconName = icon;
|
||||
}
|
||||
@@ -611,7 +612,7 @@ void MimeBinaryProvider::loadIcon(MimeTypePrivate &data)
|
||||
void MimeBinaryProvider::loadGenericIcon(MimeTypePrivate &data)
|
||||
{
|
||||
const QByteArray inputMime = data.name.toLatin1();
|
||||
const QLatin1String icon = iconForMime(m_cacheFile, PosGenericIconsListOffset, inputMime);
|
||||
const QLatin1StringView icon = iconForMime(m_cacheFile, PosGenericIconsListOffset, inputMime);
|
||||
if (!icon.isEmpty()) {
|
||||
data.genericIconName = icon;
|
||||
}
|
||||
|
@@ -108,7 +108,7 @@ private:
|
||||
int charPos,
|
||||
bool caseSensitiveCheck);
|
||||
bool matchMagicRule(CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data);
|
||||
QLatin1String iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime);
|
||||
QLatin1StringView iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime);
|
||||
void loadMimeTypeList();
|
||||
bool checkCacheChanged();
|
||||
|
||||
|
@@ -76,13 +76,13 @@ MimeTypeParserBase::ParseState MimeTypeParserBase::nextState(ParseState currentS
|
||||
{
|
||||
switch (currentState) {
|
||||
case ParseBeginning:
|
||||
if (startElement == QLatin1String(mimeInfoTagC))
|
||||
if (startElement == QLatin1StringView(mimeInfoTagC))
|
||||
return ParseMimeInfo;
|
||||
if (startElement == QLatin1String(mimeTypeTagC))
|
||||
if (startElement == QLatin1StringView(mimeTypeTagC))
|
||||
return ParseMimeType;
|
||||
return ParseError;
|
||||
case ParseMimeInfo:
|
||||
return startElement == QLatin1String(mimeTypeTagC) ? ParseMimeType : ParseError;
|
||||
return startElement == QLatin1StringView(mimeTypeTagC) ? ParseMimeType : ParseError;
|
||||
case ParseMimeType:
|
||||
case ParseComment:
|
||||
case ParseGenericIcon:
|
||||
@@ -93,29 +93,29 @@ MimeTypeParserBase::ParseState MimeTypeParserBase::nextState(ParseState currentS
|
||||
case ParseAlias:
|
||||
case ParseOtherMimeTypeSubTag:
|
||||
case ParseMagicMatchRule:
|
||||
if (startElement == QLatin1String(mimeTypeTagC)) // Sequence of <mime-type>
|
||||
if (startElement == QLatin1StringView(mimeTypeTagC)) // Sequence of <mime-type>
|
||||
return ParseMimeType;
|
||||
if (startElement == QLatin1String(commentTagC))
|
||||
if (startElement == QLatin1StringView(commentTagC))
|
||||
return ParseComment;
|
||||
if (startElement == QLatin1String(genericIconTagC))
|
||||
if (startElement == QLatin1StringView(genericIconTagC))
|
||||
return ParseGenericIcon;
|
||||
if (startElement == QLatin1String(iconTagC))
|
||||
if (startElement == QLatin1StringView(iconTagC))
|
||||
return ParseIcon;
|
||||
if (startElement == QLatin1String(globTagC))
|
||||
if (startElement == QLatin1StringView(globTagC))
|
||||
return ParseGlobPattern;
|
||||
if (startElement == QLatin1String(globDeleteAllTagC))
|
||||
if (startElement == QLatin1StringView(globDeleteAllTagC))
|
||||
return ParseGlobDeleteAll;
|
||||
if (startElement == QLatin1String(subClassTagC))
|
||||
if (startElement == QLatin1StringView(subClassTagC))
|
||||
return ParseSubClass;
|
||||
if (startElement == QLatin1String(aliasTagC))
|
||||
if (startElement == QLatin1StringView(aliasTagC))
|
||||
return ParseAlias;
|
||||
if (startElement == QLatin1String(magicTagC))
|
||||
if (startElement == QLatin1StringView(magicTagC))
|
||||
return ParseMagic;
|
||||
if (startElement == QLatin1String(matchTagC))
|
||||
if (startElement == QLatin1StringView(matchTagC))
|
||||
return ParseMagicMatchRule;
|
||||
return ParseOtherMimeTypeSubTag;
|
||||
case ParseMagic:
|
||||
if (startElement == QLatin1String(matchTagC))
|
||||
if (startElement == QLatin1StringView(matchTagC))
|
||||
return ParseMagicMatchRule;
|
||||
break;
|
||||
case ParseError:
|
||||
@@ -152,10 +152,10 @@ struct CreateMagicMatchRuleResult
|
||||
|
||||
static CreateMagicMatchRuleResult createMagicMatchRule(const QXmlStreamAttributes &atts)
|
||||
{
|
||||
const auto type = atts.value(QLatin1String(matchTypeAttributeC));
|
||||
const auto value = atts.value(QLatin1String(matchValueAttributeC));
|
||||
const auto offsets = atts.value(QLatin1String(matchOffsetAttributeC));
|
||||
const auto mask = atts.value(QLatin1String(matchMaskAttributeC));
|
||||
const auto type = atts.value(QLatin1StringView(matchTypeAttributeC));
|
||||
const auto value = atts.value(QLatin1StringView(matchValueAttributeC));
|
||||
const auto offsets = atts.value(QLatin1StringView(matchOffsetAttributeC));
|
||||
const auto mask = atts.value(QLatin1StringView(matchMaskAttributeC));
|
||||
return CreateMagicMatchRuleResult(type, value, offsets, mask);
|
||||
}
|
||||
#endif
|
||||
@@ -182,7 +182,7 @@ bool MimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
const QXmlStreamAttributes atts = reader.attributes();
|
||||
switch (ps) {
|
||||
case ParseMimeType: { // start parsing a MIME type name
|
||||
const QString name = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
|
||||
const QString name = atts.value(QLatin1StringView(mimeTypeAttributeC)).toString();
|
||||
if (name.isEmpty()) {
|
||||
reader.raiseError(QStringLiteral("Missing 'type'-attribute"));
|
||||
} else {
|
||||
@@ -191,15 +191,15 @@ bool MimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
}
|
||||
break;
|
||||
case ParseGenericIcon:
|
||||
data.genericIconName = atts.value(QLatin1String(nameAttributeC)).toString();
|
||||
data.genericIconName = atts.value(QLatin1StringView(nameAttributeC)).toString();
|
||||
break;
|
||||
case ParseIcon:
|
||||
data.iconName = atts.value(QLatin1String(nameAttributeC)).toString();
|
||||
data.iconName = atts.value(QLatin1StringView(nameAttributeC)).toString();
|
||||
break;
|
||||
case ParseGlobPattern: {
|
||||
const QString pattern = atts.value(QLatin1String(patternAttributeC)).toString();
|
||||
unsigned weight = atts.value(QLatin1String(weightAttributeC)).toInt();
|
||||
const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)) == "true"_L1;
|
||||
const QString pattern = atts.value(QLatin1StringView(patternAttributeC)).toString();
|
||||
unsigned weight = atts.value(QLatin1StringView(weightAttributeC)).toInt();
|
||||
const bool caseSensitive = atts.value(QLatin1StringView(caseSensitiveAttributeC)) == "true"_L1;
|
||||
|
||||
if (weight == 0)
|
||||
weight = MimeGlobPattern::DefaultWeight;
|
||||
@@ -215,14 +215,14 @@ bool MimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
data.globPatterns.clear();
|
||||
break;
|
||||
case ParseSubClass: {
|
||||
const QString inheritsFrom = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
|
||||
const QString inheritsFrom = atts.value(QLatin1StringView(mimeTypeAttributeC)).toString();
|
||||
if (!inheritsFrom.isEmpty())
|
||||
processParent(data.name, inheritsFrom);
|
||||
}
|
||||
break;
|
||||
case ParseComment: {
|
||||
// comments have locale attributes.
|
||||
QString locale = atts.value(QLatin1String(localeAttributeC)).toString();
|
||||
QString locale = atts.value(QLatin1StringView(localeAttributeC)).toString();
|
||||
const QString comment = reader.readElementText();
|
||||
if (locale.isEmpty())
|
||||
locale = QString::fromLatin1("default");
|
||||
@@ -230,14 +230,14 @@ bool MimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
}
|
||||
break;
|
||||
case ParseAlias: {
|
||||
const QString alias = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
|
||||
const QString alias = atts.value(QLatin1StringView(mimeTypeAttributeC)).toString();
|
||||
if (!alias.isEmpty())
|
||||
processAlias(alias, data.name);
|
||||
}
|
||||
break;
|
||||
case ParseMagic: {
|
||||
priority = 50;
|
||||
const auto priorityS = atts.value(QLatin1String(priorityAttributeC));
|
||||
const auto priorityS = atts.value(QLatin1StringView(priorityAttributeC));
|
||||
if (!priorityS.isEmpty()) {
|
||||
if (!parseNumber(priorityS, &priority, errorMessage))
|
||||
return false;
|
||||
@@ -274,15 +274,15 @@ bool MimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
case QXmlStreamReader::EndElement: // Finished element
|
||||
{
|
||||
const auto elementName = reader.name();
|
||||
if (elementName == QLatin1String(mimeTypeTagC)) {
|
||||
if (elementName == QLatin1StringView(mimeTypeTagC)) {
|
||||
if (!process(MimeType(data), errorMessage))
|
||||
return false;
|
||||
data.clear();
|
||||
} else if (elementName == QLatin1String(matchTagC)) {
|
||||
} else if (elementName == QLatin1StringView(matchTagC)) {
|
||||
// Closing a <match> tag, pop stack
|
||||
currentRules.pop();
|
||||
//qDebug() << " MATCH closed. Stack size is now" << currentRules.size();
|
||||
} else if (elementName == QLatin1String(magicTagC)) {
|
||||
} else if (elementName == QLatin1StringView(magicTagC)) {
|
||||
//qDebug() << "MAGIC ended, we got" << rules.count() << "rules, with prio" << priority;
|
||||
// Finished a <magic> sequence
|
||||
MimeMagicRuleMatcher ruleMatcher(data.name, priority);
|
||||
|
Reference in New Issue
Block a user