Commit ba4dd001 authored by mae's avatar mae
Browse files

when closing a document, auto-load "restored" editors if required

parent 6b9444e1
......@@ -713,8 +713,13 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
}
}
if (newCurrent)
if (newCurrent) {
activateEditor(view, newCurrent, NoActivate);
} else {
QModelIndex idx = m_d->m_editorModel->firstRestoredEditor();
if (idx.isValid())
activateEditor(idx, view);
}
}
......
......@@ -116,6 +116,14 @@ void EditorModel::addRestoredEditor(const QString &fileName, const QString &disp
addEntry(entry);
}
QModelIndex EditorModel::firstRestoredEditor() const
{
for (int i = 0; i < m_editors.count(); ++i)
if (!m_editors.at(i).editor)
return createIndex(i, 0);
return QModelIndex();
}
void EditorModel::addEntry(const Entry &entry)
{
QString fileName = entry.fileName();
......
......@@ -71,6 +71,7 @@ public:
void addEditor(IEditor *editor, bool isDuplicate = false);
void addRestoredEditor(const QString &fileName, const QString &displayName, const QByteArray &kind);
QModelIndex firstRestoredEditor() const;
struct Entry {
Entry():editor(0){}
......
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