SelectionZoneAction.cpp
77 lines
| 2.3 KiB
| text/x-c
|
CppLexer
r1111 | #include <Actions/SelectionZoneAction.h> | |||
#include <Visualization/VisualizationSelectionZoneItem.h> | ||||
Q_LOGGING_CATEGORY(LOG_SelectionZoneAction, "SelectionZoneAction") | ||||
struct SelectionZoneAction::SelectionZoneActionPrivate { | ||||
r1118 | explicit SelectionZoneActionPrivate(const QString &name, const QStringList &subMenuList, | |||
r1111 | SelectionZoneAction::ExecuteFunction fun) | |||
r1118 | : m_Name{name}, m_SubMenuList{subMenuList}, m_Fun{std::move(fun)} | |||
r1111 | { | |||
} | ||||
QString m_Name; | ||||
r1118 | QStringList m_SubMenuList; | |||
r1117 | QKeySequence m_DisplayedShortcut; | |||
r1111 | SelectionZoneAction::ExecuteFunction m_Fun; | |||
r1115 | SelectionZoneAction::EnableFunction m_EnableFun = [](auto zones) { return true; }; | |||
r1382 | bool m_FilteringAllowed = true; | |||
r1111 | }; | |||
SelectionZoneAction::SelectionZoneAction(const QString &name, ExecuteFunction fun) | ||||
r1118 | : impl{spimpl::make_unique_impl<SelectionZoneActionPrivate>(name, QStringList{}, | |||
std::move(fun))} | ||||
{ | ||||
} | ||||
SelectionZoneAction::SelectionZoneAction(const QStringList &subMenuList, const QString &name, | ||||
SelectionZoneAction::ExecuteFunction fun) | ||||
: impl{spimpl::make_unique_impl<SelectionZoneActionPrivate>(name, subMenuList, | ||||
std::move(fun))} | ||||
r1111 | { | |||
} | ||||
r1115 | void SelectionZoneAction::setEnableFunction(EnableFunction fun) | |||
{ | ||||
impl->m_EnableFun = std::move(fun); | ||||
} | ||||
r1117 | void SelectionZoneAction::setDisplayedShortcut(const QKeySequence &shortcut) | |||
{ | ||||
impl->m_DisplayedShortcut = shortcut; | ||||
} | ||||
QKeySequence SelectionZoneAction::displayedShortcut() const | ||||
{ | ||||
return impl->m_DisplayedShortcut; | ||||
} | ||||
r1111 | QString SelectionZoneAction::name() const noexcept | |||
{ | ||||
return impl->m_Name; | ||||
} | ||||
r1118 | QStringList SelectionZoneAction::subMenuList() const noexcept | |||
{ | ||||
return impl->m_SubMenuList; | ||||
} | ||||
r1382 | void SelectionZoneAction::setAllowedFiltering(bool value) | |||
{ | ||||
impl->m_FilteringAllowed = value; | ||||
} | ||||
bool SelectionZoneAction::isFilteringAllowed() const | ||||
{ | ||||
return impl->m_FilteringAllowed; | ||||
} | ||||
r1111 | void SelectionZoneAction::execute(const QVector<VisualizationSelectionZoneItem *> &item) | |||
{ | ||||
impl->m_Fun(item); | ||||
} | ||||
r1115 | ||||
bool SelectionZoneAction::isEnabled(const QVector<VisualizationSelectionZoneItem *> &item) | ||||
{ | ||||
return impl->m_EnableFun(item); | ||||
} | ||||