ManaPlus
Public Member Functions | Data Fields
LangListModel Class Reference

#include <langlistmodel.h>

Inheritance diagram for LangListModel:
ExtendedListModel ListModel

Public Member Functions

 LangListModel ()
 
 ~LangListModel ()
 
int getNumberOfElements ()
 
std::string getElementAt (int i)
 
const ImagegetImageAt (int i)
 
- Public Member Functions inherited from ExtendedListModel
 ExtendedListModel ()
 
- Public Member Functions inherited from ListModel
 ListModel ()
 
virtual ~ListModel ()
 

Data Fields

ImagemIcons [langs_count]
 

Detailed Description

Definition at line 92 of file langlistmodel.h.

Constructor & Destructor Documentation

◆ LangListModel()

LangListModel::LangListModel ( )
inline

Definition at line 95 of file langlistmodel.h.

96  {
97  for (int f = 0; f < langs_count; f ++)
98  {
99  const std::string icon = LANG_NAME[f].icon;
100  if (!icon.empty())
101  {
102  mIcons[f] = Loader::getImage("graphics/flags/"
103  + icon);
104  }
105  else
106  {
107  mIcons[f] = nullptr;
108  }
109  }
110  }
Image * mIcons[langs_count]
const int langs_count
Definition: langlistmodel.h:42
const Language LANG_NAME[langs_count]
Definition: langlistmodel.h:44
Image * getImage(const std::string &idPath)
Definition: imageloader.cpp:86
std::string icon
Definition: langlistmodel.h:39

References Loader::getImage(), Language::icon, LANG_NAME, langs_count, and anonymous_namespace{languagedb.cpp}::mIcons.

◆ ~LangListModel()

LangListModel::~LangListModel ( )
inline

Definition at line 114 of file langlistmodel.h.

115  {
116  for (int f = 0; f < langs_count; f ++)
117  {
118  Image *const img = mIcons[f];
119  if (img != nullptr)
120  img->decRef();
121  }
122  }

References langs_count, and anonymous_namespace{languagedb.cpp}::mIcons.

Member Function Documentation

◆ getElementAt()

std::string LangListModel::getElementAt ( int  i)
inlinevirtual

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 127 of file langlistmodel.h.

128  {
129  if (i >= getNumberOfElements() || i < 0)
130  return "???";
131 
132  return gettext(LANG_NAME[i].name.c_str());
133  }
int getNumberOfElements()

References LANG_NAME, and Language::name.

◆ getImageAt()

const Image* LangListModel::getImageAt ( int  i)
inlinevirtual

Implements ExtendedListModel.

Definition at line 135 of file langlistmodel.h.

136  {
137  if (i >= getNumberOfElements() || i < 0)
138  return nullptr;
139  return mIcons[i];
140  }

References anonymous_namespace{languagedb.cpp}::mIcons.

◆ getNumberOfElements()

int LangListModel::getNumberOfElements ( )
inlinevirtual

Gets the number of elements in the list.

Returns
The number of elements in the list

Implements ListModel.

Definition at line 124 of file langlistmodel.h.

125  { return langs_count; }

References langs_count.

Field Documentation

◆ mIcons

Image* LangListModel::mIcons[langs_count]

Definition at line 142 of file langlistmodel.h.


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