Update mime database from Qt

qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8
  Port from container.count()/length() to size()

Change-Id: Iedb5ceb04cecb314f9403518ff9a36f84edbb57d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2024-08-27 11:47:44 +02:00
parent 90531ba114
commit c2b0f91d0b
3 changed files with 12 additions and 12 deletions

View File

@@ -34,9 +34,9 @@ void MimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const QS
bool replace = weight > m_weight; bool replace = weight > m_weight;
if (!replace) { if (!replace) {
// Compare the length of the match // Compare the length of the match
if (pattern.length() < m_matchingPatternLength) if (pattern.size() < m_matchingPatternLength)
return; // too short, ignore return; // too short, ignore
else if (pattern.length() > m_matchingPatternLength) { else if (pattern.size() > m_matchingPatternLength) {
// longer: clear any previous match (like *.bz2, when pattern is *.tar.bz2) // longer: clear any previous match (like *.bz2, when pattern is *.tar.bz2)
replace = true; replace = true;
} }
@@ -44,7 +44,7 @@ void MimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const QS
if (replace) { if (replace) {
m_matchingMimeTypes.clear(); m_matchingMimeTypes.clear();
// remember the new "longer" length // remember the new "longer" length
m_matchingPatternLength = pattern.length(); m_matchingPatternLength = pattern.size();
m_weight = weight; m_weight = weight;
} }
if (!m_matchingMimeTypes.contains(mimeType)) { if (!m_matchingMimeTypes.contains(mimeType)) {
@@ -59,7 +59,7 @@ void MimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const QS
MimeGlobPattern::PatternType MimeGlobPattern::detectPatternType(const QString &pattern) const MimeGlobPattern::PatternType MimeGlobPattern::detectPatternType(const QString &pattern) const
{ {
const int patternLength = pattern.length(); const int patternLength = pattern.size();
if (!patternLength) if (!patternLength)
return OtherPattern; return OtherPattern;
@@ -108,10 +108,10 @@ bool MimeGlobPattern::matchFileName(const QString &inputFileName) const
const QString fileName = m_caseSensitivity == Qt::CaseInsensitive const QString fileName = m_caseSensitivity == Qt::CaseInsensitive
? inputFileName.toLower() : inputFileName; ? inputFileName.toLower() : inputFileName;
const int patternLength = m_pattern.length(); const int patternLength = m_pattern.size();
if (!patternLength) if (!patternLength)
return false; return false;
const int fileNameLength = fileName.length(); const int fileNameLength = fileName.size();
switch (m_patternType) { switch (m_patternType) {
case SuffixPattern: { case SuffixPattern: {
@@ -167,7 +167,7 @@ static bool isSimplePattern(const QString &pattern)
{ {
// starts with "*.", has no other '*' // starts with "*.", has no other '*'
return pattern.lastIndexOf(u'*') == 0 return pattern.lastIndexOf(u'*') == 0
&& pattern.length() > 1 && pattern.size() > 1
&& pattern.at(1) == u'.' // (other dots are OK, like *.tar.bz2) && pattern.at(1) == u'.' // (other dots are OK, like *.tar.bz2)
// and contains no other special character // and contains no other special character
&& !pattern.contains(u'?') && !pattern.contains(u'?')
@@ -233,7 +233,7 @@ void MimeGlobPatternList::match(MimeGlobMatchResult &result,
continue; continue;
if (glob.matchFileName(fileName)) { if (glob.matchFileName(fileName)) {
const QString pattern = glob.pattern(); const QString pattern = glob.pattern();
const int suffixLen = isSimplePattern(pattern) ? pattern.length() - 2 : 0; const int suffixLen = isSimplePattern(pattern) ? pattern.size() - 2 : 0;
result.addMatch(glob.mimeType(), glob.weight(), pattern, suffixLen); result.addMatch(glob.mimeType(), glob.weight(), pattern, suffixLen);
} }
} }

View File

@@ -225,7 +225,7 @@ void MimeBinaryProvider::addFileNameMatches(const QString &fileName, MimeGlobMat
numRoots, numRoots,
firstRootOffset, firstRootOffset,
lowerFileName, lowerFileName,
lowerFileName.length() - 1, lowerFileName.size() - 1,
false); false);
if (result.m_matchingMimeTypes.isEmpty()) if (result.m_matchingMimeTypes.isEmpty())
matchSuffixTree(result, matchSuffixTree(result,
@@ -233,7 +233,7 @@ void MimeBinaryProvider::addFileNameMatches(const QString &fileName, MimeGlobMat
numRoots, numRoots,
firstRootOffset, firstRootOffset,
fileName, fileName,
fileName.length() - 1, fileName.size() - 1,
true); true);
} }
// Check complex globs (e.g. "callgrind.out[0-9]*" or "README*") // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
@@ -482,7 +482,7 @@ void MimeBinaryProvider::addAllMimeTypes(QList<MimeType> &result)
{ {
loadMimeTypeList(); loadMimeTypeList();
if (result.isEmpty()) { if (result.isEmpty()) {
result.reserve(m_mimetypeNames.count()); result.reserve(m_mimetypeNames.size());
for (const QString &name : std::as_const(m_mimetypeNames)) for (const QString &name : std::as_const(m_mimetypeNames))
result.append(mimeTypeForNameUnchecked(name)); result.append(mimeTypeForNameUnchecked(name));
} else { } else {

View File

@@ -24,7 +24,7 @@ static QString suffixFromPattern(const QString &pattern)
{ {
// Not a simple suffix if it looks like: README or *. or *.* or *.JP*G or *.JP? // Not a simple suffix if it looks like: README or *. or *.* or *.JP*G or *.JP?
if (pattern.startsWith("*."_L1) && if (pattern.startsWith("*."_L1) &&
pattern.length() > 2 && pattern.size() > 2 &&
pattern.indexOf(u'*', 2) < 0 && pattern.indexOf(u'?', 2) < 0) { pattern.indexOf(u'*', 2) < 0 && pattern.indexOf(u'?', 2) < 0) {
return pattern.mid(2); return pattern.mid(2);
} }