From 33c3e1cb89f5a58ffabaedc5f99ff83d0ee022ab Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Mon, 6 Sep 2010 15:29:46 +0200
Subject: [PATCH] Add a "All Projects" Filter to the Load Project dialog

---
 src/plugins/coreplugin/mimedatabase.cpp           | 2 +-
 src/plugins/coreplugin/mimedatabase.h             | 2 ++
 src/plugins/projectexplorer/pluginfilefactory.cpp | 9 ++++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/plugins/coreplugin/mimedatabase.cpp b/src/plugins/coreplugin/mimedatabase.cpp
index ea92354a357..b98f010d39f 100644
--- a/src/plugins/coreplugin/mimedatabase.cpp
+++ b/src/plugins/coreplugin/mimedatabase.cpp
@@ -455,7 +455,7 @@ bool MimeType::setPreferredSuffix(const QString &s)
     return true;
 }
 
-static QString formatFilterString(const QString &description, const QList<QRegExp> &globs)
+QString MimeType::formatFilterString(const QString &description, const QList<QRegExp> &globs)
 {
     QString rc;
     if (globs.empty())  // Binary files
diff --git a/src/plugins/coreplugin/mimedatabase.h b/src/plugins/coreplugin/mimedatabase.h
index 13a9d3a370f..751447f6d89 100644
--- a/src/plugins/coreplugin/mimedatabase.h
+++ b/src/plugins/coreplugin/mimedatabase.h
@@ -176,6 +176,8 @@ public:
 
     friend QDebug operator<<(QDebug d, const MimeType &mt);
 
+    static QString formatFilterString(const QString &description, const QList<QRegExp> &globs);
+
 private:
     explicit MimeType(const MimeTypeData &d);
     unsigned matchesFileBySuffix(Internal::FileMatchContext &c) const;
diff --git a/src/plugins/projectexplorer/pluginfilefactory.cpp b/src/plugins/projectexplorer/pluginfilefactory.cpp
index a6c5961e819..c8bfe397ca6 100644
--- a/src/plugins/projectexplorer/pluginfilefactory.cpp
+++ b/src/plugins/projectexplorer/pluginfilefactory.cpp
@@ -87,6 +87,8 @@ QList<ProjectFileFactory *> ProjectFileFactory::createFactories(QString *filterS
     QList<IProjectManager*> projectManagers =
         ExtensionSystem::PluginManager::instance()->getObjects<IProjectManager>();
 
+    QList<QRegExp> allGlobPatterns;
+
     const QString filterSeparator = QLatin1String(";;");
     filterString->clear();
     foreach (IProjectManager *manager, projectManagers) {
@@ -94,8 +96,13 @@ QList<ProjectFileFactory *> ProjectFileFactory::createFactories(QString *filterS
         if (!filterString->isEmpty())
             *filterString += filterSeparator;
         const QString mimeType = manager->mimeType();
-        const QString pFilterString = Core::ICore::instance()->mimeDatabase()->findByType(mimeType).filterString();
+        Core::MimeType mime = Core::ICore::instance()->mimeDatabase()->findByType(mimeType);
+        const QString pFilterString = mime.filterString();
+        allGlobPatterns.append(mime.globPatterns());
         *filterString += pFilterString;
     }
+    QString allProjectFilter = Core::MimeType::formatFilterString(tr("All Projects"), allGlobPatterns);
+    allProjectFilter.append(filterSeparator);
+    filterString->prepend(allProjectFilter);
     return rc;
 }
-- 
GitLab