EditorManager: Make closeEditor public

And use it where appropriate

Change-Id: I0f37b8aada6eaa9be6743724b91a59173a01cb0c
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
Orgad Shaneh
2013-08-06 21:35:06 +03:00
committed by Orgad Shaneh
parent 5a02089e3c
commit 0b4300a68c
10 changed files with 15 additions and 25 deletions

View File

@@ -1009,11 +1009,11 @@ void EditorManager::setCurrentEditorFromContextChange()
setCurrentEditor(newCurrent); setCurrentEditor(newCurrent);
} }
void EditorManager::closeEditor(Core::IEditor *editor) void EditorManager::closeEditor(Core::IEditor *editor, bool askAboutModifiedEditors)
{ {
if (!editor) if (!editor)
return; return;
closeEditors(QList<IEditor *>() << editor); closeEditors(QList<IEditor *>() << editor, askAboutModifiedEditors);
} }
void EditorManager::closeEditor(DocumentModel::Entry *entry) void EditorManager::closeEditor(DocumentModel::Entry *entry)

View File

@@ -142,6 +142,7 @@ public:
bool saveEditor(IEditor *editor); bool saveEditor(IEditor *editor);
bool closeEditors(const QList<IEditor *> &editorsToClose, bool askAboutModifiedEditors = true); bool closeEditors(const QList<IEditor *> &editorsToClose, bool askAboutModifiedEditors = true);
void closeEditor(IEditor *editor, bool askAboutModifiedEditors = true);
MakeWritableResult makeFileWritable(IDocument *document); MakeWritableResult makeFileWritable(IDocument *document);
@@ -268,7 +269,6 @@ private:
static Internal::EditorView *viewForEditor(IEditor *editor); static Internal::EditorView *viewForEditor(IEditor *editor);
static Internal::SplitterOrView *findRoot(const Internal::EditorView *view, int *rootIndex = 0); static Internal::SplitterOrView *findRoot(const Internal::EditorView *view, int *rootIndex = 0);
void closeEditor(IEditor *editor);
void closeView(Internal::EditorView *view); void closeView(Internal::EditorView *view);
void emptyView(Internal::EditorView *view); void emptyView(Internal::EditorView *view);
static void splitNewWindow(Internal::EditorView *view); static void splitNewWindow(Internal::EditorView *view);

View File

@@ -115,7 +115,7 @@ TestCase::TestCase(const QByteArray &input)
TestCase::~TestCase() TestCase::~TestCase()
{ {
EditorManager::instance()->closeEditors(QList<Core::IEditor *>() << editor, false); EditorManager::instance()->closeEditor(editor, false);
QCoreApplication::processEvents(); // process any pending events QCoreApplication::processEvents(); // process any pending events
// Remove the test file from the code-model // Remove the test file from the code-model

View File

@@ -540,8 +540,7 @@ void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed()
QVERIFY(mm->snapshot().contains(file)); QVERIFY(mm->snapshot().contains(file));
// Close file/editor // Close file/editor
const QList<Core::IEditor*> editorsToClose = QList<Core::IEditor*>() << editor; em->closeEditor(editor, /*askAboutModifiedEditors=*/ false);
em->closeEditors(editorsToClose, /*askAboutModifiedEditors=*/ false);
// Check: File is removed from the snapshpt // Check: File is removed from the snapshpt
QVERIFY(!mm->workingCopy().contains(file)); QVERIFY(!mm->workingCopy().contains(file));

View File

@@ -1212,8 +1212,7 @@ bool CvsPlugin::describe(const QString &repositoryPath,
void CvsPlugin::submitCurrentLog() void CvsPlugin::submitCurrentLog()
{ {
m_submitActionTriggered = true; m_submitActionTriggered = true;
EditorManager::instance()->closeEditors(QList<IEditor*>() EditorManager::instance()->closeEditor(EditorManager::currentEditor());
<< EditorManager::currentEditor());
} }
// Run CVS. At this point, file arguments must be relative to // Run CVS. At this point, file arguments must be relative to

View File

@@ -124,10 +124,8 @@ DisassemblerAgentPrivate::DisassemblerAgentPrivate()
DisassemblerAgentPrivate::~DisassemblerAgentPrivate() DisassemblerAgentPrivate::~DisassemblerAgentPrivate()
{ {
if (editor) { if (editor)
EditorManager *editorManager = EditorManager::instance(); EditorManager::instance()->closeEditor(editor);
editorManager->closeEditors(QList<IEditor *>() << editor);
}
editor = 0; editor = 0;
delete locationMark; delete locationMark;
qDeleteAll(breakpointMarks); qDeleteAll(breakpointMarks);

View File

@@ -76,10 +76,8 @@ SourceAgentPrivate::SourceAgentPrivate()
SourceAgentPrivate::~SourceAgentPrivate() SourceAgentPrivate::~SourceAgentPrivate()
{ {
if (editor) { if (editor)
EditorManager *editorManager = EditorManager::instance(); EditorManager::instance()->closeEditor(editor);
editorManager->closeEditors(QList<IEditor *>() << editor);
}
editor = 0; editor = 0;
delete locationMark; delete locationMark;
} }

View File

@@ -1865,13 +1865,10 @@ void FakeVimPluginPrivate::handleDelayedQuit(bool forced, IEditor *editor)
// This tries to simulate vim behaviour. But the models of vim and // This tries to simulate vim behaviour. But the models of vim and
// Qt Creator core do not match well... // Qt Creator core do not match well...
EditorManager *editorManager = ICore::editorManager(); EditorManager *editorManager = ICore::editorManager();
if (editorManager->hasSplitter()) { if (editorManager->hasSplitter())
triggerAction(Core::Constants::REMOVE_CURRENT_SPLIT); triggerAction(Core::Constants::REMOVE_CURRENT_SPLIT);
} else { else
QList<IEditor *> editors; editorManager->closeEditor(editor, !forced);
editors.append(editor);
editorManager->closeEditors(editors, !forced);
}
} }
void FakeVimPluginPrivate::handleDelayedQuitAll(bool forced) void FakeVimPluginPrivate::handleDelayedQuitAll(bool forced)

View File

@@ -181,7 +181,7 @@ void GitSubmitEditor::updateFileModel()
} else { } else {
VcsBase::VcsBaseOutputWindow::instance()->append(errorMessage); VcsBase::VcsBaseOutputWindow::instance()->append(errorMessage);
m_forceClose = true; m_forceClose = true;
Core::EditorManager::instance()->closeEditors(QList<IEditor*>() << this); Core::EditorManager::instance()->closeEditor(this);
} }
} }

View File

@@ -1296,8 +1296,7 @@ void PerforcePlugin::describe(const QString & source, const QString &n)
void PerforcePlugin::submitCurrentLog() void PerforcePlugin::submitCurrentLog()
{ {
m_submitActionTriggered = true; m_submitActionTriggered = true;
Core::EditorManager *em = Core::EditorManager::instance(); Core::EditorManager::instance()->closeEditor(Core::EditorManager::currentEditor());
em->closeEditors(QList<Core::IEditor*>() << Core::EditorManager::currentEditor());
} }
void PerforcePlugin::cleanCommitMessageFile() void PerforcePlugin::cleanCommitMessageFile()