Commit 0b4300a6 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

EditorManager: Make closeEditor public

And use it where appropriate

Change-Id: I0f37b8aada6eaa9be6743724b91a59173a01cb0c
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 5a02089e
......@@ -1009,11 +1009,11 @@ void EditorManager::setCurrentEditorFromContextChange()
setCurrentEditor(newCurrent);
}
void EditorManager::closeEditor(Core::IEditor *editor)
void EditorManager::closeEditor(Core::IEditor *editor, bool askAboutModifiedEditors)
{
if (!editor)
return;
closeEditors(QList<IEditor *>() << editor);
closeEditors(QList<IEditor *>() << editor, askAboutModifiedEditors);
}
void EditorManager::closeEditor(DocumentModel::Entry *entry)
......
......@@ -142,6 +142,7 @@ public:
bool saveEditor(IEditor *editor);
bool closeEditors(const QList<IEditor *> &editorsToClose, bool askAboutModifiedEditors = true);
void closeEditor(IEditor *editor, bool askAboutModifiedEditors = true);
MakeWritableResult makeFileWritable(IDocument *document);
......@@ -268,7 +269,6 @@ private:
static Internal::EditorView *viewForEditor(IEditor *editor);
static Internal::SplitterOrView *findRoot(const Internal::EditorView *view, int *rootIndex = 0);
void closeEditor(IEditor *editor);
void closeView(Internal::EditorView *view);
void emptyView(Internal::EditorView *view);
static void splitNewWindow(Internal::EditorView *view);
......
......@@ -115,7 +115,7 @@ TestCase::TestCase(const QByteArray &input)
TestCase::~TestCase()
{
EditorManager::instance()->closeEditors(QList<Core::IEditor *>() << editor, false);
EditorManager::instance()->closeEditor(editor, false);
QCoreApplication::processEvents(); // process any pending events
// Remove the test file from the code-model
......
......@@ -540,8 +540,7 @@ void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed()
QVERIFY(mm->snapshot().contains(file));
// Close file/editor
const QList<Core::IEditor*> editorsToClose = QList<Core::IEditor*>() << editor;
em->closeEditors(editorsToClose, /*askAboutModifiedEditors=*/ false);
em->closeEditor(editor, /*askAboutModifiedEditors=*/ false);
// Check: File is removed from the snapshpt
QVERIFY(!mm->workingCopy().contains(file));
......
......@@ -1212,8 +1212,7 @@ bool CvsPlugin::describe(const QString &repositoryPath,
void CvsPlugin::submitCurrentLog()
{
m_submitActionTriggered = true;
EditorManager::instance()->closeEditors(QList<IEditor*>()
<< EditorManager::currentEditor());
EditorManager::instance()->closeEditor(EditorManager::currentEditor());
}
// Run CVS. At this point, file arguments must be relative to
......
......@@ -124,10 +124,8 @@ DisassemblerAgentPrivate::DisassemblerAgentPrivate()
DisassemblerAgentPrivate::~DisassemblerAgentPrivate()
{
if (editor) {
EditorManager *editorManager = EditorManager::instance();
editorManager->closeEditors(QList<IEditor *>() << editor);
}
if (editor)
EditorManager::instance()->closeEditor(editor);
editor = 0;
delete locationMark;
qDeleteAll(breakpointMarks);
......
......@@ -76,10 +76,8 @@ SourceAgentPrivate::SourceAgentPrivate()
SourceAgentPrivate::~SourceAgentPrivate()
{
if (editor) {
EditorManager *editorManager = EditorManager::instance();
editorManager->closeEditors(QList<IEditor *>() << editor);
}
if (editor)
EditorManager::instance()->closeEditor(editor);
editor = 0;
delete locationMark;
}
......
......@@ -1865,13 +1865,10 @@ void FakeVimPluginPrivate::handleDelayedQuit(bool forced, IEditor *editor)
// This tries to simulate vim behaviour. But the models of vim and
// Qt Creator core do not match well...
EditorManager *editorManager = ICore::editorManager();
if (editorManager->hasSplitter()) {
if (editorManager->hasSplitter())
triggerAction(Core::Constants::REMOVE_CURRENT_SPLIT);
} else {
QList<IEditor *> editors;
editors.append(editor);
editorManager->closeEditors(editors, !forced);
}
else
editorManager->closeEditor(editor, !forced);
}
void FakeVimPluginPrivate::handleDelayedQuitAll(bool forced)
......
......@@ -181,7 +181,7 @@ void GitSubmitEditor::updateFileModel()
} else {
VcsBase::VcsBaseOutputWindow::instance()->append(errorMessage);
m_forceClose = true;
Core::EditorManager::instance()->closeEditors(QList<IEditor*>() << this);
Core::EditorManager::instance()->closeEditor(this);
}
}
......
......@@ -1296,8 +1296,7 @@ void PerforcePlugin::describe(const QString & source, const QString &n)
void PerforcePlugin::submitCurrentLog()
{
m_submitActionTriggered = true;
Core::EditorManager *em = Core::EditorManager::instance();
em->closeEditors(QList<Core::IEditor*>() << Core::EditorManager::currentEditor());
Core::EditorManager::instance()->closeEditor(Core::EditorManager::currentEditor());
}
void PerforcePlugin::cleanCommitMessageFile()
......
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