6#if QT_CONFIG(regularexpression)
7#include <QRegularExpression>
61QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(
const QString &
pattern)
const
68 const bool hasSquareBracket =
pattern.indexOf(u
'[') != -1;
69 const bool hasQuestionMark =
pattern.indexOf(u
'?') != -1;
71 if (!hasSquareBracket && !hasQuestionMark) {
77 if (
pattern.at(patternLength - 1) == u
'*')
79 }
else if (starCount == 0) {
81 return LiteralPattern;
85 if (
pattern ==
"[0-9][0-9][0-9].vdr"_L1)
88 if (
pattern ==
"*.anim[1-9j]"_L1)
110 ? inputFileName.
toLower() : inputFileName;
117 switch (m_patternType) {
118 case SuffixPattern: {
119 if (fileNameLength + 1 < patternLength)
122 const QChar *c1 = m_pattern.
unicode() + patternLength - 1;
125 while (cnt < patternLength && *c1-- == *
c2--)
127 return cnt == patternLength;
129 case PrefixPattern: {
130 if (fileNameLength + 1 < patternLength)
136 while (cnt < patternLength && *c1++ == *
c2++)
138 return cnt == patternLength;
143 return fileNameLength == 7
147 if (fileNameLength < 6)
150 const bool lastCharOK = (lastChar.
isDigit() && lastChar != u
'0')
156#if QT_CONFIG(regularexpression)
169 return pattern.lastIndexOf(u
'*') == 0
181 return pattern.lastIndexOf(u
'*') == 0
182 &&
pattern.lastIndexOf(u
'.') == 1
202 if (!patterns.contains(glob.
mimeType()))
230 result.addMatch(glob.mimeType(), glob.weight(),
pattern, suffixLen);
249 const QString simplePattern =
"*."_L1 + simpleExtension;
constexpr bool isDigit() const noexcept
Returns true if the character is a decimal digit (Number_DecimalDigit); otherwise returns false.
T value(const Key &key) const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
void append(parameter_type t)
void addGlob(const QMimeGlobPattern &glob)
PatternsMap m_fastPatterns
void removeMimeType(const QString &mimeType)
void matchingGlobs(const QString &fileName, QMimeGlobMatchResult &result) const
QMimeGlobPatternList m_highWeightGlobs
QMimeGlobPatternList m_lowWeightGlobs
void removeMimeType(const QString &mimeType)
"noglobs" is very rare occurrence, so it's ok if it's slow
bool hasPattern(const QString &mimeType, const QString &pattern) const
void match(QMimeGlobMatchResult &result, const QString &fileName) const
The QMimeGlobPattern class contains the glob pattern for file names for MIME type matching.
const QString & mimeType() const
const QString & pattern() const
bool matchFileName(const QString &inputFileName) const
bool isCaseSensitive() const
static QRegularExpression fromWildcard(QStringView pattern, Qt::CaseSensitivity cs=Qt::CaseInsensitive, WildcardConversionOptions options=DefaultWildcardConversion)
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const
Returns the number of characters in this string.
QString toLower() const &
const QChar * unicode() const
Returns a Unicode representation of the string.
Combined button and popup list for selecting options.
static bool isFastPattern(const QString &pattern)
static bool isSimplePattern(const QString &pattern)
GLint GLint GLint GLint GLint x
[0]
GLuint GLuint GLfloat weight
application x qt windows mime
[2]
The QMimeGlobMatchResult class accumulates results from glob matching.
void addMatch(const QString &mimeType, int weight, const QString &pattern, qsizetype knownSuffixLength=0)
qsizetype m_matchingPatternLength
QStringList m_allMatchingMimeTypes
qsizetype m_knownSuffixLength
QStringList m_matchingMimeTypes