|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
#include <game_list_model.h>
Public Types | |
| using | IsRunningFn = std::function<bool(const std::string& gameId)> |
Public Member Functions | |
| GameListModel (QObject *parent=nullptr) | |
| ~GameListModel () override | |
| void | clear () |
| Clear all rows. | |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| Qt::ItemFlags | flags (const QModelIndex &index) const override |
| const Game * | gameAt (int row) const |
| Get the Game* at a given row. Returns nullptr if out of range. | |
| const std::vector< const Game * > & | games () const |
| Get the raw game list (O(1)). | |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| int | rowForGameId (const std::string &gameId) const |
| O(1) gameId -> row lookup. Returns -1 if not found. | |
| void | setGames (std::vector< const Game * > games) |
| Replace the model's game list in one shot. | |
| void | setIcon (const std::string &gameId, const QIcon &icon) |
| Stash a pre-scaled QIcon for a given gameId. | |
| void | setIsRunningAccessor (IsRunningFn accessor) |
| Install a callback the model queries to answer GameIsRunningRole. | |
| void | updateGameById (const std::string &gameId) |
| Find the row for gameId and emit dataChanged for it. No-op if missing. | |
| void | updateRow (int row) |
| Emit dataChanged for a single row so the delegate repaints. | |
Definition at line 36 of file game_list_model.h.
| using GameListModel::IsRunningFn = std::function<bool(const std::string& gameId)> |
Definition at line 95 of file game_list_model.h.
|
explicit |
Definition at line 17 of file game_list_model.cpp.
|
overridedefault |
References games().
| void GameListModel::clear | ( | ) |
Clear all rows.
Definition at line 33 of file game_list_model.cpp.
|
override |
Definition at line 119 of file game_list_model.cpp.
|
override |
Definition at line 112 of file game_list_model.cpp.
| const Game * GameListModel::gameAt | ( | int | row | ) | const |
Get the Game* at a given row. Returns nullptr if out of range.
Definition at line 59 of file game_list_model.cpp.
|
inline |
Get the raw game list (O(1)).
Definition at line 56 of file game_list_model.h.
Referenced by ~GameListModel(), and setGames().
|
override |
Definition at line 105 of file game_list_model.cpp.
| int GameListModel::rowForGameId | ( | const std::string & | gameId | ) | const |
O(1) gameId -> row lookup. Returns -1 if not found.
Definition at line 53 of file game_list_model.cpp.
Referenced by setIcon(), and updateGameById().
| void GameListModel::setGames | ( | std::vector< const Game * > | games | ) |
Replace the model's game list in one shot.
Triggers full reset. Game* pointers must remain valid until the next setGames() or clear().
Definition at line 25 of file game_list_model.cpp.
References games().
| void GameListModel::setIcon | ( | const std::string & | gameId, |
| const QIcon & | icon ) |
Stash a pre-scaled QIcon for a given gameId.
Returned via Qt::DecorationRole on the corresponding row. Takes no ownership — QIcon is implicitly shared.
Definition at line 89 of file game_list_model.cpp.
References rowForGameId().
|
inline |
Install a callback the model queries to answer GameIsRunningRole.
Routing through a callback avoids a hard dependency on GameLaunchController in the model. The callback is invoked on the GUI thread during paint — keep it O(1) (map lookup).
Definition at line 101 of file game_list_model.h.
| void GameListModel::updateGameById | ( | const std::string & | gameId | ) |
Find the row for gameId and emit dataChanged for it. No-op if missing.
Definition at line 78 of file game_list_model.cpp.
References rowForGameId(), and updateRow().
| void GameListModel::updateRow | ( | int | row | ) |
Emit dataChanged for a single row so the delegate repaints.
Use this when backing Game* data has changed but the row list hasn't.
Definition at line 70 of file game_list_model.cpp.
Referenced by updateGameById().