diff options
author | David Faure <david.faure@kdab.com> | 2023-09-11 18:20:12 +0200 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2023-09-13 23:27:44 +0200 |
commit | 1f0bc1ade316547d01100dcca4f3f7187485f917 (patch) | |
tree | 635f1fa5fe366d1e8c6a17f8b0cf5698902c7245 /src/corelib/mimetypes/qmimeprovider_p.h | |
parent | 42e164f5ad7f279d3b7862d5882ba6705db596d2 (diff) |
QMimeDatabase: fix glob-deleteall support for the binary providers
This fixes the recently added QEXPECT_FAIL about glob-deleteall
in a local directory (with a binary cache). Before adding a glob match
we ask the more-local (higher-precedence) directories if they have
a glob-deleteall for that mimetype, and skip it then. This "asking"
is a virtual method, implemented for both XML and binary providers.
Change-Id: I6e4baf0120749f3331fd2d9254bea750a322b72d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/mimetypes/qmimeprovider_p.h')
-rw-r--r-- | src/corelib/mimetypes/qmimeprovider_p.h | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h index 755737eaaf..4fbd63af92 100644 --- a/src/corelib/mimetypes/qmimeprovider_p.h +++ b/src/corelib/mimetypes/qmimeprovider_p.h @@ -29,6 +29,7 @@ QT_BEGIN_NAMESPACE class QMimeMagicRuleMatcher; class QMimeTypeXMLData; +class QMimeProviderBase; class QMimeProviderBase { @@ -53,38 +54,16 @@ public: virtual QString icon(const QString &name) = 0; virtual QString genericIcon(const QString &name) = 0; virtual void ensureLoaded() { } - virtual void excludeMimeTypeGlobs(const QStringList &) { } QString directory() const { return m_directory; } + QMimeProviderBase *overrideProvider() const; + void setOverrideProvider(QMimeProviderBase *provider); + bool isMimeTypeGlobsExcluded(const QString &name) const; + QMimeDatabasePrivate *m_db; QString m_directory; - - /* - MimeTypes with "glob-deleteall" tags are handled differently by each provider - sub-class: - - QMimeBinaryProvider parses glob-deleteall tags lazily, i.e. only when hasGlobDeleteAll() - is called, and clears the glob patterns associated with mimetypes that have this tag - - QMimeXMLProvider parses glob-deleteall from the start, i.e. when a XML file is - parsed with QMimeTypeParser - - The two lists below are used to let both provider types (XML and Binary) communicate - about mimetypes with glob-deleteall. - */ - /* - List of mimetypes in _this_ Provider that have a "glob-deleteall" tag, - glob patterns for those mimetypes should be ignored in all _other_ lower - precedence Providers. - */ - QStringList m_mimeTypesWithDeletedGlobs; - - /* - List of mimetypes with glob patterns that are "overwritten" in _this_ Provider, - by a "glob-deleteall" tag in a mimetype definition in a _higher precedence_ - Provider. With QMimeBinaryProvider, we can't change the data in the binary mmap'ed - file, hence the need for this list. - */ - QStringList m_mimeTypesWithExcludedGlobs; + QMimeProviderBase *m_overrideProvider = nullptr; // more "local" than this one }; /* @@ -111,7 +90,6 @@ public: QString icon(const QString &name) override; QString genericIcon(const QString &name) override; void ensureLoaded() override; - void excludeMimeTypeGlobs(const QStringList &toExclude) override; private: struct CacheFile; @@ -121,7 +99,6 @@ private: bool matchSuffixTree(QMimeGlobMatchResult &result, CacheFile *cacheFile, int numEntries, int firstOffset, const QString &fileName, qsizetype charPos, bool caseSensitiveCheck); - bool isMimeTypeGlobsExcluded(const char *name); bool matchMagicRule(CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data); QLatin1StringView iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime); @@ -180,7 +157,6 @@ public: // Called by the mimetype xml parser void addMimeType(const QMimeTypeXMLData &mt); - void excludeMimeTypeGlobs(const QStringList &toExclude) override; void addGlobPattern(const QMimeGlobPattern &glob); void addParent(const QString &child, const QString &parent); void addAlias(const QString &alias, const QString &name); |