KDECore
kmimeglobsfileparser.cpp
Go to the documentation of this file.
36 const QStringList globFiles = KGlobal::dirs()->findAllResources("xdgdata-mime", QString::fromLatin1("globs"));
47 KMimeGlobsFileParser::AllGlobs KMimeGlobsFileParser::parseGlobFiles(const QStringList& globFiles, QStringList& parsedFiles)
52 // At each level, we must be able to override (not just add to) the information that we read at higher levels
57 QString fileNamev2 = fileName + QLatin1Char('2'); // NOTE: this relies on u-m-d always generating the old globs file
76 // If we're not going to get the "cs" flag because smi is too old, then we need to emulate it for *.C at least.
77 const bool caseSensitiveHackNeeded = (KMimeType::sharedMimeInfoVersion() <= KDE_MAKE_VERSION(0, 60, 0));
123 if (caseSensitiveHackNeeded && (pattern == QLatin1String("*.C") || pattern == QLatin1String("*.c") || pattern == QLatin1String("core")))
136 // kDebug() << "Adding pattern" << pattern << "to mimetype" << mimeTypeName << "from globs file, with weight" << weight;
138 // kDebug() << " Adding pattern" << pattern << "to mimetype" << mimeTypeName << "from globs file, with weight" << weight << "flags" << flags;
167 //kDebug() << "pattern" << pattern << "glob.weight=" << glob.weight << "isFast=" << isFastPattern(pattern) << glob.flags;
169 // Store each patterns into either m_fastPatternDict (*.txt, *.html etc. with default weight 50)
173 if (glob.weight == 50 && isFastPattern(pattern) && ((glob.flags & KMimeTypeRepository::CaseSensitive) == 0)) {
#define KDE_MAKE_VERSION(a, b, c)
Make a number from the major, minor and release number of a KDE version.
Definition: kdeversion.h.cmake:75
bool hasNext() const
bool hasPattern(const QString &mime, const QString &pattern) const
Definition: kmimeglobsfileparser_p.h:57
QString readLine(qint64 maxlen)
const T & previous()
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
void removeMime(const QString &mime)
Definition: kmimeglobsfileparser.cpp:216
bool contains(const QString &str, Qt::CaseSensitivity cs) const
PatternsMap patternsMap() const
Definition: kmimeglobsfileparser.cpp:193
static int sharedMimeInfoVersion()
Returns the version of the installed update-mime-database program (from freedesktop.org shared-mime-info).
Definition: kmimetype.cpp:738
void addGlob(const Glob &glob)
Definition: kmimeglobsfileparser.cpp:158
bool exists() const
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
T value(int i) const
void clear()
int count(const T &value) const
GlobList m_highWeightGlobs
Definition: kmimeglobsfileparser_p.h:93
void append(const T &value)
bool atEnd() const
bool isEmpty() const
iterator begin()
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
Item next()
void toBack()
QString toLower() const
static bool parseGlobFile(QIODevice *file, Format format, AllGlobs &globs)
Definition: kmimeglobsfileparser.cpp:71
bool contains(QChar ch, Qt::CaseSensitivity cs) const
KMimeGlobsFileParser()
Definition: kmimeglobsfileparser.cpp:30
static bool isFastPattern(const QString &pattern)
Definition: kmimeglobsfileparser.cpp:147
static AllGlobs parseGlobFiles(const QStringList &globFiles, QStringList &parsedFiles)
Definition: kmimeglobsfileparser.cpp:47
bool hasPrevious() const
GlobList m_lowWeightGlobs
Definition: kmimeglobsfileparser_p.h:94
QString mid(int position, int n) const
QString fromLatin1(const char *str, int size)
QStringList findAllResources(const char *type, const QString &filter=QString(), SearchOptions options=NoSearchOptions) const
Tries to find all resources with the specified type.
Definition: kstandarddirs.cpp:900
iterator end()
QHash< QString, QStringList > m_fastPatterns
Definition: kmimeglobsfileparser_p.h:92
Result of the globs parsing, as data structures ready for efficient mimetype matching.
Definition: kmimeglobsfileparser_p.h:85
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.