ManaPlus
Public Member Functions | Private Attributes
IconsModel Class Reference

#include <iconsmodel.h>

Inheritance diagram for IconsModel:
ListModel

Public Member Functions

 IconsModel ()
 
int getNumberOfElements ()
 
std::string getElementAt (int i)
 
- Public Member Functions inherited from ListModel
 ListModel ()
 
virtual ~ListModel ()
 

Private Attributes

StringVect mStrings
 

Detailed Description

Definition at line 38 of file iconsmodel.h.

Constructor & Destructor Documentation

◆ IconsModel()

IconsModel::IconsModel ( )
inline

Definition at line 41 of file iconsmodel.h.

41  :
42  mStrings()
43  {
44  const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
45  std::list<std::string> tempStrings;
46 
47  for (std::map<int, ItemInfo*>::const_iterator
48  i = items.begin(), i_end = items.end();
49  i != i_end; ++i)
50  {
51  if (i->first < 0)
52  continue;
53 
54  const ItemInfo &info = (*i->second);
55  const std::string &name = info.getName();
56  if (name != "unnamed" && !info.getName().empty()
57  && info.getName() != "unnamed")
58  {
59  tempStrings.push_back(name);
60  }
61  }
62  tempStrings.sort();
63  mStrings.push_back("");
64  FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
65  mStrings.push_back(*i);
66  }
StringVect mStrings
Definition: iconsmodel.h:82
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
bool info(InputEvent &event)
Definition: commands.cpp:57
const ItemDB::ItemInfos & getItemInfos()
Definition: itemdb.cpp:829

References FOR_EACH, ItemDB::getItemInfos(), Actions::info(), and mStrings.

Member Function Documentation

◆ getElementAt()

std::string IconsModel::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 75 of file iconsmodel.h.

76  {
77  if (i < 0 || i >= getNumberOfElements())
78  return "???";
79  return mStrings.at(i);
80  }
int getNumberOfElements()
Definition: iconsmodel.h:70

References getNumberOfElements(), and mStrings.

◆ getNumberOfElements()

int IconsModel::getNumberOfElements ( )
inlinevirtual

Gets the number of elements in the list.

Returns
The number of elements in the list

Implements ListModel.

Definition at line 70 of file iconsmodel.h.

71  {
72  return CAST_S32(mStrings.size());
73  }
#define CAST_S32
Definition: cast.h:30

References CAST_S32, and mStrings.

Referenced by getElementAt().

Field Documentation

◆ mStrings

StringVect IconsModel::mStrings
private

Definition at line 82 of file iconsmodel.h.

Referenced by getElementAt(), getNumberOfElements(), and IconsModel().


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