ManaPlus
Public Member Functions | Private Attributes
TouchActionsModel Class Reference

#include <touchactionmodel.h>

Inheritance diagram for TouchActionsModel:
NamesModel ListModel

Public Member Functions

 TouchActionsModel ()
 
InputActionT getActionFromSelection (const int sel) const
 
int getSelectionFromAction (const InputActionT action) const
 
- Public Member Functions inherited from NamesModel
 NamesModel ()
 
 ~NamesModel ()
 
int getNumberOfElements ()
 
std::string getElementAt (int i)
 
StringVectgetNames ()
 
size_t size () const
 
void clear ()
 
void add (const std::string &str)
 
void fillFromArray (const char *const *const arr, const std::size_t size)
 
void fillFromVector (const StringVect &vect)
 
- Public Member Functions inherited from ListModel
 ListModel ()
 
virtual ~ListModel ()
 

Private Attributes

std::vector< InputActionTmActionId
 
std::map< InputActionT, int > mActionToSelection
 

Additional Inherited Members

- Protected Attributes inherited from NamesModel
StringVect mNames
 

Detailed Description

Definition at line 31 of file touchactionmodel.h.

Constructor & Destructor Documentation

◆ TouchActionsModel()

TouchActionsModel::TouchActionsModel ( )

Definition at line 49 of file touchactionmodel.cpp.

49  :
50  NamesModel(),
51  mActionId(),
53 {
54  STD_VECTOR<SetupActionData*> data;
55 
56  for (int f = 0, fsz = touchActionDataSize; f < fsz; f ++)
57  {
58  int k = 0;
59  while (!touchActionData[f][k].name.empty())
60  {
61  data.push_back(&touchActionData[f][k]);
62  k ++;
63  }
64  }
65 
66  std::sort(data.begin(), data.end(), touchActionSorter);
67  int cnt = 0;
68  FOR_EACH (STD_VECTOR<SetupActionData*>::iterator, it, data)
69  {
70  const SetupActionData *const data1 = *it;
71  mNames.push_back(data1->name);
72  mActionId.push_back(data1->actionId);
73  mActionToSelection[data1->actionId] = cnt;
74  cnt ++;
75  }
76 }
StringVect mNames
Definition: namesmodel.h:62
std::vector< InputActionT > mActionId
std::map< InputActionT, int > mActionToSelection
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
uint32_t data
std::string name
const InputActionT actionId
SetupActionData *const touchActionData[]
const int touchActionDataSize
static class SortTouchActionFunctor touchActionSorter

References SetupActionData::actionId, data, FOR_EACH, mActionId, mActionToSelection, NamesModel::mNames, SetupActionData::name, touchActionData, touchActionDataSize, and touchActionSorter.

Member Function Documentation

◆ getActionFromSelection()

InputActionT TouchActionsModel::getActionFromSelection ( const int  sel) const

Definition at line 78 of file touchactionmodel.cpp.

79 {
80  if (sel < 0 || sel > static_cast<signed int>(mActionId.size()))
81  return InputAction::NO_VALUE;
82  return mActionId[sel];
83 }

References mActionId, and InputAction::NO_VALUE.

Referenced by SetupActionDropDown::fromWidget().

◆ getSelectionFromAction()

int TouchActionsModel::getSelectionFromAction ( const InputActionT  action) const

Definition at line 85 of file touchactionmodel.cpp.

86 {
87  const std::map<InputActionT, int>::const_iterator it
88  = mActionToSelection.find(action);
89  if (it == mActionToSelection.end())
90  return 0;
91  return (*it).second;
92 }

References mActionToSelection.

Referenced by SetupActionDropDown::createControls(), and SetupActionDropDown::toWidget().

Field Documentation

◆ mActionId

std::vector<InputActionT> TouchActionsModel::mActionId
private

Definition at line 43 of file touchactionmodel.h.

Referenced by getActionFromSelection(), and TouchActionsModel().

◆ mActionToSelection

std::map<InputActionT, int> TouchActionsModel::mActionToSelection
private

Definition at line 44 of file touchactionmodel.h.

Referenced by getSelectionFromAction(), and TouchActionsModel().


The documentation for this class was generated from the following files: