Commit 013e10fd authored by Eike Ziller's avatar Eike Ziller
Browse files

MimeDatabase: Add allGlobPatterns and allFiltersString



Change-Id: I255d1ef3140b220de9bdc279788abf3fecb16af9
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent b4f494f6
......@@ -40,6 +40,7 @@
#include "mimeprovider_p.h"
#include "mimetype_p.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QSet>
......@@ -51,6 +52,8 @@
#include <algorithm>
#include <functional>
static const char ALL_FILES_FILTER[] = QT_TRANSLATE_NOOP("Core", "All Files (*)");
using namespace Utils;
using namespace Utils::Internal;
......@@ -311,6 +314,36 @@ void MimeDatabase::addMimeTypes(const QString &fileName)
xmlProvider->addFile(fileName);
}
QString MimeDatabase::allFiltersString(QString *allFilesFilter)
{
MimeDatabase mdb;
QSet<QString> uniqueFilters;
foreach (const MimeType &mt, mdb.allMimeTypes())
uniqueFilters.insert(mt.filterString());
QStringList filters;
foreach (const QString &filter, uniqueFilters)
filters.append(filter);
filters.sort();
static const QString allFiles =
QCoreApplication::translate("Core", ALL_FILES_FILTER);
if (allFilesFilter)
*allFilesFilter = allFiles;
// Prepend all files filter
filters.prepend(allFiles);
return filters.join(QLatin1String(";;"));
}
QStringList MimeDatabase::allGlobPatterns()
{
MimeDatabase mdb;
QStringList patterns;
foreach (const MimeType &mt, mdb.allMimeTypes())
patterns.append(mt.globPatterns());
return patterns;
}
/*!
\fn MimeType MimeDatabase::mimeTypeForName(const QString &nameOrAlias) const;
Returns a MIME type for \a nameOrAlias or an invalid one if none found.
......
......@@ -84,6 +84,8 @@ public:
// Qt Creator additions
static void addMimeTypes(const QString &fileName);
static QString allFiltersString(QString *allFilesFilter = 0);
static QStringList allGlobPatterns();
private:
Internal::MimeDatabasePrivate *d;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment