aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/mimetypes/mimeglobpattern_p.h
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2021-10-21 09:13:03 +0200
committerEike Ziller <eike.ziller@qt.io>2021-10-21 09:13:03 +0200
commitbb9774de92dd2c8da85c5231ca5646b078cb42a3 (patch)
treee43470cf6f3a7c965b7dc8a349593dadd03ee65e /src/libs/utils/mimetypes/mimeglobpattern_p.h
parentf41bebc843a8b4ab1ab29562ba200b032b5ab5ac (diff)
parent5377253612801b2f92e0b55e40c3ce0dd2574b09 (diff)
Merge remote-tracking branch 'origin/6.0'
Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs qtcreator_ide_branding.pri Change-Id: If8baed5564470e550a0ba5c7720915217eec2412
Diffstat (limited to 'src/libs/utils/mimetypes/mimeglobpattern_p.h')
-rw-r--r--src/libs/utils/mimetypes/mimeglobpattern_p.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/libs/utils/mimetypes/mimeglobpattern_p.h b/src/libs/utils/mimetypes/mimeglobpattern_p.h
index ecbfb02ce9..990a5b07d2 100644
--- a/src/libs/utils/mimetypes/mimeglobpattern_p.h
+++ b/src/libs/utils/mimetypes/mimeglobpattern_p.h
@@ -73,16 +73,27 @@ public:
static const unsigned DefaultWeight = 50;
static const unsigned MinWeight = 1;
- explicit MimeGlobPattern(const QString &thePattern, const QString &theMimeType, unsigned theWeight = DefaultWeight, Qt::CaseSensitivity s = Qt::CaseInsensitive) :
- m_pattern(thePattern), m_mimeType(theMimeType), m_weight(theWeight), m_caseSensitivity(s)
+ explicit MimeGlobPattern(const QString &thePattern, const QString &theMimeType,
+ unsigned theWeight = DefaultWeight,
+ Qt::CaseSensitivity s = Qt::CaseInsensitive) :
+ m_pattern(s == Qt::CaseInsensitive ? thePattern.toLower() : thePattern),
+ m_mimeType(theMimeType),
+ m_weight(theWeight),
+ m_caseSensitivity(s),
+ m_patternType(detectPatternType(m_pattern))
{
- if (s == Qt::CaseInsensitive) {
- m_pattern = m_pattern.toLower();
- }
}
- ~MimeGlobPattern() {}
- bool matchFileName(const QString &filename) const;
+ void swap(MimeGlobPattern &other) noexcept
+ {
+ qSwap(m_pattern, other.m_pattern);
+ qSwap(m_mimeType, other.m_mimeType);
+ qSwap(m_weight, other.m_weight);
+ qSwap(m_caseSensitivity, other.m_caseSensitivity);
+ qSwap(m_patternType, other.m_patternType);
+ }
+
+ bool matchFileName(const QString &inputFileName) const;
inline const QString &pattern() const { return m_pattern; }
inline unsigned weight() const { return m_weight; }
@@ -90,10 +101,21 @@ public:
inline bool isCaseSensitive() const { return m_caseSensitivity == Qt::CaseSensitive; }
private:
+ enum PatternType {
+ SuffixPattern,
+ PrefixPattern,
+ LiteralPattern,
+ VdrPattern, // special handling for "[0-9][0-9][0-9].vdr" pattern
+ AnimPattern, // special handling for "*.anim[1-9j]" pattern
+ OtherPattern
+ };
+ PatternType detectPatternType(const QString &pattern) const;
+
QString m_pattern;
QString m_mimeType;
int m_weight;
Qt::CaseSensitivity m_caseSensitivity;
+ PatternType m_patternType;
};
class MimeGlobPatternList : public QList<MimeGlobPattern>