Commit 05d8ddf5 authored by con's avatar con
Browse files

Allow empty editor id with openEditorWithContents.

Tries to figure out the editor type from the title pattern in that case.
parent 9a472466
......@@ -1282,28 +1282,11 @@ IEditor *EditorManager::openEditorWithContents(const QString &editorId,
if (debugEditorManager)
qDebug() << Q_FUNC_INFO << editorId << titlePattern << contents;
if (editorId.isEmpty())
return 0;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
IEditor *edt = createEditor(editorId);
if (!edt) {
QApplication::restoreOverrideCursor();
return 0;
}
if (!edt->createNew(contents)) {
QApplication::restoreOverrideCursor();
delete edt;
edt = 0;
return 0;
}
QString title = edt->displayName();
QString title;
if (titlePattern) {
const QChar dollar = QLatin1Char('$');
const QChar dot = QLatin1Char('.');
QString base = *titlePattern;
if (base.isEmpty())
......@@ -1315,7 +1298,6 @@ IEditor *EditorManager::openEditorWithContents(const QString &editorId,
QString name = editor->file()->fileName();
if (name.isEmpty()) {
name = editor->displayName();
name.remove(QLatin1Char('*'));
} else {
name = QFileInfo(name).completeBaseName();
}
......@@ -1331,6 +1313,23 @@ IEditor *EditorManager::openEditorWithContents(const QString &editorId,
}
*titlePattern = title;
}
IEditor *edt = createEditor(editorId, title);
if (!edt) {
QApplication::restoreOverrideCursor();
return 0;
}
if (!edt->createNew(contents)) {
QApplication::restoreOverrideCursor();
delete edt;
edt = 0;
return 0;
}
if (title.isEmpty())
title = edt->displayName();
edt->setDisplayName(title);
addEditor(edt);
QApplication::restoreOverrideCursor();
......
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