forked from qt-creator/qt-creator
Show editor display names in "Open With" dialog instead of their Id's.
Change-Id: I5cf7b5b53ce05b422aec87f7cf347670133a81a9 Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
committed by
Eike Ziller
parent
eba7b13c00
commit
8bad963dee
@@ -70,11 +70,9 @@ void OpenWithDialog::setEditors(const QStringList &editors)
|
||||
editorListWidget->addItem(e);
|
||||
}
|
||||
|
||||
QString OpenWithDialog::editor() const
|
||||
int OpenWithDialog::editor() const
|
||||
{
|
||||
if (const QListWidgetItem *item = editorListWidget->currentItem())
|
||||
return item->text();
|
||||
return QString();
|
||||
return editorListWidget->currentRow();
|
||||
}
|
||||
|
||||
void OpenWithDialog::setCurrentEditor(int index)
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
OpenWithDialog(const QString &fileName, QWidget *parent);
|
||||
|
||||
void setEditors(const QStringList &);
|
||||
QString editor() const;
|
||||
int editor() const;
|
||||
|
||||
void setCurrentEditor(int index);
|
||||
|
||||
|
||||
@@ -1222,12 +1222,14 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName,
|
||||
if (!mt)
|
||||
return Id();
|
||||
QStringList allEditorIds;
|
||||
QStringList allEditorDisplayNames;
|
||||
QList<Id> externalEditorIds;
|
||||
// Built-in
|
||||
const EditorFactoryList editors = editorFactories(mt, false);
|
||||
const int size = editors.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
allEditorIds.push_back(editors.at(i)->id().toString());
|
||||
allEditorDisplayNames.push_back(editors.at(i)->displayName());
|
||||
}
|
||||
// External editors
|
||||
const ExternalEditorList exEditors = externalEditors(mt, false);
|
||||
@@ -1235,16 +1237,18 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName,
|
||||
for (int i = 0; i < esize; i++) {
|
||||
externalEditorIds.push_back(exEditors.at(i)->id());
|
||||
allEditorIds.push_back(exEditors.at(i)->id().toString());
|
||||
allEditorDisplayNames.push_back(exEditors.at(i)->displayName());
|
||||
}
|
||||
if (allEditorIds.empty())
|
||||
return Id();
|
||||
QTC_ASSERT(allEditorIds.size() == allEditorDisplayNames.size(), return Id());
|
||||
// Run dialog.
|
||||
OpenWithDialog dialog(fileName, ICore::mainWindow());
|
||||
dialog.setEditors(allEditorIds);
|
||||
dialog.setEditors(allEditorDisplayNames);
|
||||
dialog.setCurrentEditor(0);
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return Id();
|
||||
const Id selectedId = Id(dialog.editor());
|
||||
const Id selectedId = Id(allEditorIds.at(dialog.editor()));
|
||||
if (isExternalEditor)
|
||||
*isExternalEditor = externalEditorIds.contains(selectedId);
|
||||
return selectedId;
|
||||
|
||||
Reference in New Issue
Block a user