SelectionZoneAction.cpp
41 lines
| 1.2 KiB
| text/x-c
|
CppLexer
r1076 | #include <Actions/SelectionZoneAction.h> | |||
#include <Visualization/VisualizationSelectionZoneItem.h> | ||||
Q_LOGGING_CATEGORY(LOG_SelectionZoneAction, "SelectionZoneAction") | ||||
struct SelectionZoneAction::SelectionZoneActionPrivate { | ||||
explicit SelectionZoneActionPrivate(const QString &name, | ||||
SelectionZoneAction::ExecuteFunction fun) | ||||
: m_Name{name}, m_Fun{std::move(fun)} | ||||
{ | ||||
} | ||||
QString m_Name; | ||||
SelectionZoneAction::ExecuteFunction m_Fun; | ||||
r1080 | SelectionZoneAction::EnableFunction m_EnableFun = [](auto zones) { return true; }; | |||
r1076 | }; | |||
SelectionZoneAction::SelectionZoneAction(const QString &name, ExecuteFunction fun) | ||||
: impl{spimpl::make_unique_impl<SelectionZoneActionPrivate>(name, std::move(fun))} | ||||
{ | ||||
} | ||||
r1080 | void SelectionZoneAction::setEnableFunction(EnableFunction fun) | |||
{ | ||||
impl->m_EnableFun = std::move(fun); | ||||
} | ||||
r1076 | QString SelectionZoneAction::name() const noexcept | |||
{ | ||||
return impl->m_Name; | ||||
} | ||||
void SelectionZoneAction::execute(const QVector<VisualizationSelectionZoneItem *> &item) | ||||
{ | ||||
impl->m_Fun(item); | ||||
} | ||||
r1080 | ||||
bool SelectionZoneAction::isEnabled(const QVector<VisualizationSelectionZoneItem *> &item) | ||||
{ | ||||
return impl->m_EnableFun(item); | ||||
} | ||||