diff --git a/src/plugins/coreplugin/editormanager/editormanager_p.h b/src/plugins/coreplugin/editormanager/editormanager_p.h index 8c6619ffc2a..2a88a5daaaa 100644 --- a/src/plugins/coreplugin/editormanager/editormanager_p.h +++ b/src/plugins/coreplugin/editormanager/editormanager_p.h @@ -33,7 +33,6 @@ #include "ieditorfactory.h" #include -#include #include #include @@ -278,50 +277,5 @@ private: QList> m_closeEditorListeners; }; -/* For something that has a 'QStringList mimeTypes' (IEditorFactory - * or IExternalEditor), find the one best matching the mimetype passed in. - * Recurse over the parent classes of the mimetype to find them. */ -template -static void mimeTypeFactoryLookup(const Utils::MimeType &mimeType, - const QList &allFactories, - QList *list) -{ - QSet matches; - // search breadth-first through parent hierarchy, e.g. for hierarchy - // * application/x-ruby - // * application/x-executable - // * application/octet-stream - // * text/plain - QList queue; - QSet seen; - queue.append(mimeType); - seen.insert(mimeType.name()); - while (!queue.isEmpty()) { - Utils::MimeType mt = queue.takeFirst(); - // check for matching factories - foreach (EditorFactoryLike *factory, allFactories) { - if (!matches.contains(factory)) { - foreach (const QString &mimeName, factory->mimeTypes()) { - if (mt.matchesName(mimeName)) { - list->append(factory); - matches.insert(factory); - } - } - } - } - // add parent mime types - QStringList parentNames = mt.parentMimeTypes(); - foreach (const QString &parentName, parentNames) { - const Utils::MimeType parent = Utils::mimeTypeForName(parentName); - if (parent.isValid()) { - int seenSize = seen.size(); - seen.insert(parent.name()); - if (seen.size() != seenSize) // not seen before, so add - queue.append(parent); - } - } - } -} - } // Internal } // Core diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.cpp b/src/plugins/coreplugin/editormanager/ieditorfactory.cpp index fe21fb7a108..c889e39404d 100644 --- a/src/plugins/coreplugin/editormanager/ieditorfactory.cpp +++ b/src/plugins/coreplugin/editormanager/ieditorfactory.cpp @@ -26,7 +26,6 @@ #include "ieditorfactory.h" #include "ieditorfactory_p.h" #include "editormanager.h" -#include "editormanager_p.h" #include #include diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory_p.h b/src/plugins/coreplugin/editormanager/ieditorfactory_p.h index 74cd0ca029e..3da7cf2fa90 100644 --- a/src/plugins/coreplugin/editormanager/ieditorfactory_p.h +++ b/src/plugins/coreplugin/editormanager/ieditorfactory_p.h @@ -26,8 +26,10 @@ #pragma once #include +#include #include +#include namespace Core { @@ -38,5 +40,50 @@ namespace Internal { QHash userPreferredEditorFactories(); void setUserPreferredEditorFactories(const QHash &factories); +/* For something that has a 'QStringList mimeTypes' (IEditorFactory + * or IExternalEditor), find the one best matching the mimetype passed in. + * Recurse over the parent classes of the mimetype to find them. */ +template +static void mimeTypeFactoryLookup(const Utils::MimeType &mimeType, + const QList &allFactories, + QList *list) +{ + QSet matches; + // search breadth-first through parent hierarchy, e.g. for hierarchy + // * application/x-ruby + // * application/x-executable + // * application/octet-stream + // * text/plain + QList queue; + QSet seen; + queue.append(mimeType); + seen.insert(mimeType.name()); + while (!queue.isEmpty()) { + Utils::MimeType mt = queue.takeFirst(); + // check for matching factories + foreach (EditorFactoryLike *factory, allFactories) { + if (!matches.contains(factory)) { + foreach (const QString &mimeName, factory->mimeTypes()) { + if (mt.matchesName(mimeName)) { + list->append(factory); + matches.insert(factory); + } + } + } + } + // add parent mime types + QStringList parentNames = mt.parentMimeTypes(); + foreach (const QString &parentName, parentNames) { + const Utils::MimeType parent = Utils::mimeTypeForName(parentName); + if (parent.isValid()) { + int seenSize = seen.size(); + seen.insert(parent.name()); + if (seen.size() != seenSize) // not seen before, so add + queue.append(parent); + } + } + } +} + } // Internal } // Core diff --git a/src/plugins/coreplugin/editormanager/iexternaleditor.cpp b/src/plugins/coreplugin/editormanager/iexternaleditor.cpp index 13d21e22ce3..9fdb561587f 100644 --- a/src/plugins/coreplugin/editormanager/iexternaleditor.cpp +++ b/src/plugins/coreplugin/editormanager/iexternaleditor.cpp @@ -25,7 +25,7 @@ #include "iexternaleditor.h" -#include "editormanager_p.h" +#include "ieditorfactory_p.h" namespace Core {