ManaPlus
Public Member Functions | Protected Attributes
NamesModel Class Reference

#include <namesmodel.h>

Inheritance diagram for NamesModel:
ListModel FontsModel SoundsModel ThemesModel TouchActionsModel

Public Member Functions

 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 ()
 

Protected Attributes

StringVect mNames
 

Detailed Description

Definition at line 31 of file namesmodel.h.

Constructor & Destructor Documentation

◆ NamesModel()

NamesModel::NamesModel ( )

Definition at line 30 of file namesmodel.cpp.

30  :
31  ListModel(),
32  mNames()
33 {
34 }
ListModel()
Definition: listmodel.h:82
StringVect mNames
Definition: namesmodel.h:62

◆ ~NamesModel()

NamesModel::~NamesModel ( )

Definition at line 36 of file namesmodel.cpp.

37 {
38 }

Member Function Documentation

◆ add()

void NamesModel::add ( const std::string &  str)
inline

Definition at line 53 of file namesmodel.h.

54  { mNames.push_back(str); }

References mNames.

Referenced by TextSelectDialog::addText(), Setup_Visual::Setup_Visual(), and EmoteWindow::show().

◆ clear()

void NamesModel::clear ( )
inline

Definition at line 50 of file namesmodel.h.

51  { mNames.clear(); }

References mNames.

Referenced by EmoteWindow::show().

◆ fillFromArray()

void NamesModel::fillFromArray ( const char *const *const  arr,
const std::size_t  size 
)

Definition at line 52 of file namesmodel.cpp.

54 {
55  if (arr == nullptr)
56  return;
57  for (size_t f = 0; f < sz; f ++)
58  mNames.push_back(gettext(arr[f]));
59 }

References mNames.

Referenced by EmoteWindow::postInit(), Setup_Misc::Setup_Misc(), Setup_Perfomance::Setup_Perfomance(), Setup_Players::Setup_Players(), Setup_Touch::Setup_Touch(), and Setup_Visual::Setup_Visual().

◆ fillFromVector()

void NamesModel::fillFromVector ( const StringVect vect)

Definition at line 61 of file namesmodel.cpp.

62 {
63  FOR_EACH(StringVectCIter, it, vect)
64  {
65  const std::string str = *it;
66  if (!str.empty())
67  mNames.push_back(str);
68  }
69 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:31

References FOR_EACH, and mNames.

◆ getElementAt()

std::string NamesModel::getElementAt ( int  i)
virtual

Gets an element at a certain index in the list.

Parameters
iAn index in the list.
Returns
An element as a string at the a certain index.

Implements ListModel.

Definition at line 45 of file namesmodel.cpp.

46 {
47  if (i >= getNumberOfElements() || i < 0)
48  return "???";
49  return mNames[CAST_SIZE(i)];
50 }
#define CAST_SIZE
Definition: cast.h:34
int getNumberOfElements()
Definition: namesmodel.cpp:40

References CAST_SIZE, getNumberOfElements(), and mNames.

Referenced by TextSelectDialog::action().

◆ getNames()

StringVect& NamesModel::getNames ( )
inline

Definition at line 44 of file namesmodel.h.

45  { return mNames; }

References mNames.

Referenced by Setup_Joystick::action(), and Setup_Joystick::Setup_Joystick().

◆ getNumberOfElements()

int NamesModel::getNumberOfElements ( )
virtual

Gets the number of elements in the list.

Returns
The number of elements in the list

Implements ListModel.

Definition at line 40 of file namesmodel.cpp.

41 {
42  return CAST_S32(mNames.size());
43 }
#define CAST_S32
Definition: cast.h:30

References CAST_S32, and mNames.

Referenced by TextSelectDialog::action(), and getElementAt().

◆ size()

size_t NamesModel::size ( ) const
inline

Definition at line 47 of file namesmodel.h.

48  { return mNames.size(); }

References mNames.

Referenced by TextSelectDialog::action(), and Setup_Joystick::Setup_Joystick().

Field Documentation

◆ mNames

StringVect NamesModel::mNames
protected

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