ManaPlus
Public Member Functions | Private Attributes
SkillModel Class Reference

#include <skillmodel.h>

Inheritance diagram for SkillModel:
ListModel

Public Member Functions

 SkillModel ()
 
SkillInfogetSkillAt (const int i) const
 
std::string getElementAt (int i)
 
int getNumberOfElements ()
 
void addSkill (SkillInfo *const info)
 
void updateVisibilities ()
 
- Public Member Functions inherited from ListModel
 ListModel ()
 
virtual ~ListModel ()
 

Private Attributes

SkillList mSkills
 
SkillList mVisibleSkills
 

Detailed Description

Definition at line 35 of file skillmodel.h.

Constructor & Destructor Documentation

◆ SkillModel()

SkillModel::SkillModel ( )

Definition at line 32 of file skillmodel.cpp.

32  :
33  ListModel(),
34  mSkills(),
36 {
37 }
ListModel()
Definition: listmodel.h:82
SkillList mSkills
Definition: skillmodel.h:55
SkillList mVisibleSkills
Definition: skillmodel.h:56

Member Function Documentation

◆ addSkill()

void SkillModel::addSkill ( SkillInfo *const  info)
inline

Definition at line 49 of file skillmodel.h.

50  { mSkills.push_back(info); }
bool info(InputEvent &event)
Definition: commands.cpp:57

References Actions::info(), and mSkills.

Referenced by SkillDialog::addSkill(), and SkillDialog::loadSkill().

◆ getElementAt()

std::string SkillModel::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 46 of file skillmodel.cpp.

47 {
48  const SkillInfo *const info = getSkillAt(i);
49  if (info != nullptr)
50  return info->data->name;
51  return std::string();
52 }
SkillInfo * getSkillAt(const int i) const
Definition: skillmodel.cpp:39

References getSkillAt(), and Actions::info().

◆ getNumberOfElements()

int SkillModel::getNumberOfElements ( )
inlinevirtual

◆ getSkillAt()

SkillInfo * SkillModel::getSkillAt ( const int  i) const

◆ updateVisibilities()

void SkillModel::updateVisibilities ( )

Definition at line 54 of file skillmodel.cpp.

55 {
56  mVisibleSkills.clear();
57 
58  FOR_EACH (SkillList::const_iterator, it, mSkills)
59  {
60  if (((*it) != nullptr) && (*it)->visible == Visible_true)
61  mVisibleSkills.push_back((*it));
62  }
63 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
const bool Visible_true
Definition: visible.h:30

References FOR_EACH, mSkills, mVisibleSkills, and Visible_true.

Referenced by SkillDialog::addSkill(), SkillDialog::loadXmlFile(), SkillInfo::update(), SkillDialog::updateModels(), and SkillDialog::updateModelsHidden().

Field Documentation

◆ mSkills

SkillList SkillModel::mSkills
private

Definition at line 55 of file skillmodel.h.

Referenced by addSkill(), and updateVisibilities().

◆ mVisibleSkills

SkillList SkillModel::mVisibleSkills
private

Definition at line 56 of file skillmodel.h.

Referenced by getNumberOfElements(), getSkillAt(), and updateVisibilities().


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