Core: Use std::function for info bar callbacks

Change-Id: Iae7cbef053bfe86a7692e09f66af91117815d2a6
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-09-03 10:34:52 +02:00
parent 2e17339b05
commit f70ba9930e
18 changed files with 61 additions and 96 deletions

View File

@@ -54,6 +54,7 @@
#include <QTextBlock>
using namespace Core;
using namespace ProjectExplorer;
using namespace TextEditor;
namespace CMakeProjectManager {
@@ -80,24 +81,20 @@ void CMakeEditor::finalizeInitialization()
InfoBarEntry info(infoRunCmake,
tr("Changes to cmake files are shown in the project tree after building."),
InfoBarEntry::GlobalSuppressionEnabled);
info.setCustomButtonInfo(tr("Build now"), this, SLOT(build()));
info.setCustomButtonInfo(tr("Build now"), [document]() {
foreach (Project *p, SessionManager::projects()) {
if (CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p)) {
if (cmakeProject->isProjectFile(document->filePath())) {
ProjectExplorerPlugin::instance()->buildProject(cmakeProject);
break;
}
}
}
});
infoBar->addInfo(info);
});
}
void CMakeEditor::build()
{
foreach (ProjectExplorer::Project *p, ProjectExplorer::SessionManager::projects()) {
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject) {
if (cmakeProject->isProjectFile(document()->filePath())) {
ProjectExplorer::ProjectExplorerPlugin::instance()->buildProject(cmakeProject);
break;
}
}
}
}
QString CMakeEditor::contextHelpId() const
{
int pos = position();