Public Member Functions | Private Attributes
WorldListModel Class Reference

#include <worldlistmodel.h>

Inheritance diagram for WorldListModel:

Public Member Functions

 WorldListModel (const Worlds &worlds)
int getNumberOfElements ()
std::string getElementAt (int i)
- Public Member Functions inherited from ListModel
 ListModel ()
virtual ~ListModel ()

Private Attributes

Worlds mWorlds

Detailed Description

The list model for the server list.

Definition at line 37 of file worldlistmodel.h.

Constructor & Destructor Documentation

◆ WorldListModel()

WorldListModel::WorldListModel ( const Worlds worlds)

Definition at line 40 of file worldlistmodel.h.

40  :
41  mWorlds(worlds)
42  {
43  }

Member Function Documentation

◆ getElementAt()

std::string WorldListModel::getElementAt ( int  i)

Gets an element at a certain index in the list.

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

Implements ListModel.

Definition at line 52 of file worldlistmodel.h.

53  {
54  const WorldInfo *const si = mWorlds[i];
55  if (si != nullptr)
56  {
57  return std::string(si->name).append(" (").append(
58  toString(si->online_users)).append(")");
59  }
60  return "???";
61  }
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
std::string name
Definition: worldinfo.h:53
int online_users
Definition: worldinfo.h:55

References mWorlds, WorldInfo::name, WorldInfo::online_users, and Catch::toString().

◆ getNumberOfElements()

int WorldListModel::getNumberOfElements ( )

Gets the number of elements in the list.

The number of elements in the list

Implements ListModel.

Definition at line 47 of file worldlistmodel.h.

48  {
49  return CAST_S32(mWorlds.size());
50  }
#define CAST_S32
Definition: cast.h:30

References CAST_S32, and mWorlds.

Field Documentation

◆ mWorlds

Worlds WorldListModel::mWorlds

Definition at line 63 of file worldlistmodel.h.

Referenced by getElementAt(), and getNumberOfElements().

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