ManaPlus
Public Member Functions | Protected Attributes
ExtendedNamesModel Class Reference

#include <extendednamesmodel.h>

Inheritance diagram for ExtendedNamesModel:
ExtendedListModel ListModel QuestsModel

Public Member Functions

 ExtendedNamesModel ()
 
 ~ExtendedNamesModel ()
 
int getNumberOfElements ()
 
std::string getElementAt (int i)
 
const ImagegetImageAt (int i)
 
StringVectgetNames ()
 
std::vector< Image * > & getImages ()
 
size_t size ()
 
void add (const std::string &str)
 
void clear ()
 
- Public Member Functions inherited from ExtendedListModel
 ExtendedListModel ()
 
- Public Member Functions inherited from ListModel
 ListModel ()
 
virtual ~ListModel ()
 

Protected Attributes

StringVect mNames
 
std::vector< Image * > mImages
 

Detailed Description

Definition at line 29 of file extendednamesmodel.h.

Constructor & Destructor Documentation

◆ ExtendedNamesModel()

ExtendedNamesModel::ExtendedNamesModel ( )

Definition at line 29 of file extendednamesmodel.cpp.

29  :
30  mNames(),
31  mImages()
32 {
33 }
std::vector< Image * > mImages

◆ ~ExtendedNamesModel()

ExtendedNamesModel::~ExtendedNamesModel ( )

Definition at line 35 of file extendednamesmodel.cpp.

36 {
37  clear();
38 }

References clear().

Member Function Documentation

◆ add()

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

Definition at line 53 of file extendednamesmodel.h.

54  { mNames.push_back(str); }

References mNames.

Referenced by MailWindow::addMail(), MailWindow::refreshMailNames(), and MailWindow::removeMail().

◆ clear()

void ExtendedNamesModel::clear ( )

Definition at line 60 of file extendednamesmodel.cpp.

61 {
62  mNames.clear();
63  FOR_EACH (STD_VECTOR<Image*>::iterator, it, mImages)
64  {
65  if (*it != nullptr)
66  (*it)->decRef();
67  }
68  mImages.clear();
69 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References FOR_EACH, mImages, and mNames.

Referenced by MailWindow::clear(), QuestsWindow::rebuild(), MailWindow::refreshMailNames(), MailWindow::removeMail(), and ~ExtendedNamesModel().

◆ getElementAt()

std::string ExtendedNamesModel::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 extendednamesmodel.cpp.

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

References CAST_SIZE, getNumberOfElements(), and mNames.

◆ getImageAt()

const Image * ExtendedNamesModel::getImageAt ( int  i)
virtual

Implements ExtendedListModel.

Definition at line 52 of file extendednamesmodel.cpp.

53 {
54  if (i >= CAST_S32(mImages.size()) || i < 0)
55  return nullptr;
56 
57  return mImages[CAST_SIZE(i)];
58 }
#define CAST_S32
Definition: cast.h:30

References CAST_S32, CAST_SIZE, and mImages.

◆ getImages()

std::vector<Image*>& ExtendedNamesModel::getImages ( )
inline

Definition at line 47 of file extendednamesmodel.h.

48  { return mImages; }

References mImages.

Referenced by QuestsWindow::rebuild().

◆ getNames()

StringVect& ExtendedNamesModel::getNames ( )
inline

Definition at line 44 of file extendednamesmodel.h.

45  { return mNames; }

References mNames.

Referenced by QuestsWindow::rebuild().

◆ getNumberOfElements()

int ExtendedNamesModel::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 extendednamesmodel.cpp.

41 {
42  return CAST_S32(mNames.size());
43 }

References CAST_S32, and mNames.

Referenced by getElementAt().

◆ size()

size_t ExtendedNamesModel::size ( )
inline

Definition at line 50 of file extendednamesmodel.h.

51  { return mNames.size(); }

References mNames.

Field Documentation

◆ mImages

std::vector<Image*> ExtendedNamesModel::mImages
protected

Definition at line 60 of file extendednamesmodel.h.

Referenced by clear(), getImageAt(), and getImages().

◆ mNames

StringVect ExtendedNamesModel::mNames
protected

Definition at line 59 of file extendednamesmodel.h.

Referenced by add(), clear(), getElementAt(), getNames(), getNumberOfElements(), and size().


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