From 694e07d193e7c5758a7d672b45668651b034003d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 31 May 2015 00:19:18 +0300 Subject: Convert InputAction enum into strong typed enum. --- src/gui/models/touchactionmodel.cpp | 8 ++++---- src/gui/models/touchactionmodel.h | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/gui/models') diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp index d9cced32a..7daff84ca 100644 --- a/src/gui/models/touchactionmodel.cpp +++ b/src/gui/models/touchactionmodel.cpp @@ -68,16 +68,16 @@ TouchActionsModel::TouchActionsModel() : } } -int TouchActionsModel::getActionFromSelection(const int sel) const +InputActionT TouchActionsModel::getActionFromSelection(const int sel) const { if (sel < 0 || sel > static_cast(mActionId.size())) - return -1; + return InputAction::NO_VALUE; return mActionId[sel]; } -int TouchActionsModel::getSelectionFromAction(const int action) const +int TouchActionsModel::getSelectionFromAction(const InputActionT action) const { - const std::map::const_iterator it + const std::map::const_iterator it = mActionToSelection.find(action); if (it == mActionToSelection.end()) return 0; diff --git a/src/gui/models/touchactionmodel.h b/src/gui/models/touchactionmodel.h index 287232aae..05234907c 100644 --- a/src/gui/models/touchactionmodel.h +++ b/src/gui/models/touchactionmodel.h @@ -21,6 +21,8 @@ #ifndef GUI_MODELS_TOUCHACTIONMODEL_H #define GUI_MODELS_TOUCHACTIONMODEL_H +#include "enums/input/inputaction.h" + #include "gui/models/namesmodel.h" #include "gui/widgets/setupitem.h" @@ -35,13 +37,13 @@ class TouchActionsModel final : public NamesModel ~TouchActionsModel() { } - int getActionFromSelection(const int sel) const; + InputActionT getActionFromSelection(const int sel) const; - int getSelectionFromAction(const int action) const; + int getSelectionFromAction(const InputActionT action) const; private: - std::vector mActionId; - std::map mActionToSelection; + std::vector mActionId; + std::map mActionToSelection; }; #endif // GUI_MODELS_TOUCHACTIONMODEL_H -- cgit v1.2.3-60-g2f50