Do not show external editors in mime settings

External editors are never used to open files, except on explicit
request with "Open with", so should not be considered in the settings'
"Handler" column

Change-Id: I8fe7b9d260754ce84d52db554d6ee25d1af3bfe2
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2018-06-19 14:50:45 +02:00
parent 96b214eb40
commit c4fb356772
4 changed files with 6 additions and 18 deletions

View File

@@ -952,7 +952,7 @@ Id EditorManagerPrivate::getOpenWithEditorId(const QString &fileName, bool *isEx
allEditorDisplayNames.push_back(editors.at(i)->displayName());
}
// External editors
const ExternalEditorList exEditors = IExternalEditor::externalEditors(mt, false);
const ExternalEditorList exEditors = IExternalEditor::externalEditors(mt);
const int esize = exEditors.size();
for (int i = 0; i < esize; i++) {
externalEditorIds.push_back(exEditors.at(i)->id());
@@ -2475,7 +2475,7 @@ void EditorManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
const Utils::MimeType mt = Utils::mimeTypeForFile(fileName);
if (mt.isValid()) {
const EditorFactoryList factories = IEditorFactory::editorFactories(mt, false);
const ExternalEditorList extEditors = IExternalEditor::externalEditors(mt, false);
const ExternalEditorList extEditors = IExternalEditor::externalEditors(mt);
anyMatches = !factories.empty() || !extEditors.empty();
if (anyMatches) {
// Add all suitable editors

View File

@@ -73,12 +73,11 @@ const ExternalEditorList IExternalEditor::allExternalEditors()
return g_externalEditors;
}
const ExternalEditorList IExternalEditor::externalEditors(const Utils::MimeType &mimeType,
bool bestMatchOnly)
const ExternalEditorList IExternalEditor::externalEditors(const Utils::MimeType &mimeType)
{
ExternalEditorList rc;
const ExternalEditorList allEditors = IExternalEditor::allExternalEditors();
Internal::mimeTypeFactoryLookup(mimeType, allEditors, bestMatchOnly, &rc);
Internal::mimeTypeFactoryLookup(mimeType, allEditors, /*bestmatchonly=*/false, &rc);
return rc;
}

View File

@@ -47,8 +47,7 @@ public:
~IExternalEditor() override;
static const ExternalEditorList allExternalEditors();
static const ExternalEditorList externalEditors(const Utils::MimeType &mimeType,
bool bestMatchOnly = true);
static const ExternalEditorList externalEditors(const Utils::MimeType &mimeType);
virtual QStringList mimeTypes() const = 0;
virtual Id id() const = 0;

View File

@@ -143,18 +143,8 @@ void MimeTypeSettingsModel::load()
});
foreach (const Utils::MimeType &mimeType, m_mimeTypes) {
QString value;
const QList<IEditorFactory *> factories = IEditorFactory::editorFactories(mimeType);
if (!factories.isEmpty()) {
value = factories.front()->displayName();
} else {
const QList<IExternalEditor *> externalEditors = IExternalEditor::externalEditors(
mimeType);
if (!externalEditors.isEmpty())
value = externalEditors.front()->displayName();
else
value = tr("Undefined");
}
const QString value = factories.isEmpty() ? "" : factories.front()->displayName();
m_handlersByMimeType.insert(mimeType.name(), value);
}
endResetModel();