##// END OF EJS Templates
Add a lambda in SeletionZoneAction to enable or disable the action
Add a lambda in SeletionZoneAction to enable or disable the action

File last commit:

r1115:c55ac7376de6
r1115:c55ac7376de6
Show More
SelectionZoneAction.cpp
41 lines | 1.2 KiB | text/x-c | CppLexer
/ gui / src / Actions / SelectionZoneAction.cpp
#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;
SelectionZoneAction::EnableFunction m_EnableFun = [](auto zones) { return true; };
};
SelectionZoneAction::SelectionZoneAction(const QString &name, ExecuteFunction fun)
: impl{spimpl::make_unique_impl<SelectionZoneActionPrivate>(name, std::move(fun))}
{
}
void SelectionZoneAction::setEnableFunction(EnableFunction fun)
{
impl->m_EnableFun = std::move(fun);
}
QString SelectionZoneAction::name() const noexcept
{
return impl->m_Name;
}
void SelectionZoneAction::execute(const QVector<VisualizationSelectionZoneItem *> &item)
{
impl->m_Fun(item);
}
bool SelectionZoneAction::isEnabled(const QVector<VisualizationSelectionZoneItem *> &item)
{
return impl->m_EnableFun(item);
}