Core: Replace ICoreListener by std::functions

ICoreListener::coreAboutToClose() remains in the core,
ICoreListener::editorAboutToClose() is handled by a new
EditorManager::addCloseEditorListener() function.

This removes the need for some boiler plate code resulting
from the need to implement the interface in custom classes
(DesignModeCoreListener, EditorClosingCoreListener,
PojectEplorer::CoreListener and VcsBase::CoreListener).

EditorManager::addCloseEditorListener

Change-Id: Ie554c987b5455b555be6d77b77e4013639201d22
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
hjk
2015-08-26 14:39:15 +02:00
parent ed25b429f6
commit e6a98f368e
25 changed files with 89 additions and 445 deletions

View File

@@ -31,16 +31,18 @@
#include "vcsplugin.h"
#include "vcsbaseconstants.h"
#include "vcsbasesubmiteditor.h"
#include "commonsettingspage.h"
#include "nicknamedialog.h"
#include "vcsoutputwindow.h"
#include "vcsprojectcache.h"
#include "corelistener.h"
#include "wizard/vcscommandpage.h"
#include "wizard/vcsconfigurationpage.h"
#include "wizard/vcsjsextension.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/jsexpander.h>
#include <coreplugin/vcsmanager.h>
@@ -64,8 +66,7 @@ VcsPlugin *VcsPlugin::m_instance = 0;
VcsPlugin::VcsPlugin() :
m_settingsPage(0),
m_nickNameModel(0),
m_coreListener(0)
m_nickNameModel(0)
{
m_instance = this;
}
@@ -81,8 +82,12 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
m_coreListener = new CoreListener;
addAutoReleasedObject(m_coreListener);
EditorManager::addCloseEditorListener([this](IEditor *editor) -> bool {
bool result = true;
if (auto se = qobject_cast<VcsBaseSubmitEditor *>(editor))
emit submitEditorAboutToClose(se, &result);
return result;
});
m_settingsPage = new CommonOptionsPage;
addAutoReleasedObject(m_settingsPage);
@@ -139,11 +144,6 @@ VcsPlugin *VcsPlugin::instance()
return m_instance;
}
CoreListener *VcsPlugin::coreListener() const
{
return m_coreListener;
}
CommonVcsSettings VcsPlugin::settings() const
{
return m_settingsPage->settings();