Model storing all available games for display in a QTreeView or QTableView. More...
#include <games_model.h>
Public Member Functions | |
| GamesModel (const QMap< int, QString > &_rooms, const QMap< int, GameTypeMap > &_gameTypes, QObject *parent=nullptr) | |
| Constructs a GamesModel. | |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| int | columnCount (const QModelIndex &=QModelIndex()) const override |
| QVariant | data (const QModelIndex &index, int role) const override |
| QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
| const ServerInfo_Game & | getGame (int row) |
| Returns a reference to a specific game by row index. | |
| void | updateGameList (const ServerInfo_Game &game) |
| Updates the game list with a new or updated game. | |
| int | roomColIndex () |
| Returns the index of the room column. | |
| int | startTimeColIndex () |
| Returns the index of the start time column. | |
| const QMap< int, GameTypeMap > & | getGameTypes () |
| Returns the map of game types per room. | |
Static Public Member Functions | |
| static const QString | getGameCreatedString (const int secs) |
| Formats the game creation time into a human-readable string. | |
Static Public Attributes | |
| static const int | SORT_ROLE = Qt::UserRole + 1 |
Private Attributes | |
| QList< ServerInfo_Game > | gameList |
| QMap< int, QString > | rooms |
| QMap< int, GameTypeMap > | gameTypes |
Static Private Attributes | |
| static const int | NUM_COLS = 8 |
Model storing all available games for display in a QTreeView or QTableView.
Provides access to game information, supports sorting by different columns, and updates when new game data is received from the server.
| GamesModel::GamesModel | ( | const QMap< int, QString > & | _rooms, |
| const QMap< int, GameTypeMap > & | _gameTypes, | ||
| QObject * | parent = nullptr ) |
Constructs a GamesModel.
| _rooms | Mapping of room IDs to room names. |
| _gameTypes | Mapping of room IDs to their available game types. |
| parent | Parent QObject. |
|
inlinenodiscardoverride |
|
nodiscardoverride |
| const ServerInfo_Game & GamesModel::getGame | ( | int | row | ) |
Returns a reference to a specific game by row index.
| row | Row index in the table. |
|
static |
Formats the game creation time into a human-readable string.
| secs | Number of seconds since the game started. |
|
inline |
Returns the map of game types per room.
|
nodiscardoverride |
|
inline |
Returns the index of the room column.
|
inlinenodiscardoverride |
|
inline |
Returns the index of the start time column.
| void GamesModel::updateGameList | ( | const ServerInfo_Game & | game | ) |
Updates the game list with a new or updated game.
| game | The ServerInfo_Game object to add or update. |
|
private |
List of games currently displayed.
|
private |
Map of room IDs to available game types.
|
staticprivate |
Number of columns in the table.
|
private |
Map of room IDs to room names.
|
static |
Role used for sorting.