1#include "cavokeclientmodel.h"
4CavokeClientModel::CavokeClientModel(QObject *parent) : QObject{parent} {
7void CavokeClientModel::loadQmlGame(
const QString &gameId) {
13 qDebug() <<
"Starting game from: " << gameId;
15 emit startQmlApplication(gameModel);
17void CavokeClientModel::updateGamesList(
const QJsonArray &newGamesList) {
18 std::vector<GameInfo> got_from;
19 std::transform(newGamesList.begin(), newGamesList.end(),
20 std::back_inserter(got_from), [](
const QJsonValue &obj) {
22 game_info.read(obj.toObject());
25 gamesList = std::move(got_from);
27 if (!newGamesList.empty()) {
28 qDebug() <<
"First In Model: " << gamesList[0].id;
30 emit gamesListUpdated(gamesList);
32void CavokeClientModel::receivedGameIndexChange(
int newIndex) {
33 emit updateSelectedGame(gamesList[newIndex]);
36void CavokeClientModel::receivedGameIndexChangeInList(
int newIndex) {
37 emit updateSelectedGameInList(gamesList[newIndex]);
40void CavokeClientModel::gotIndexToDownload(
int index) {
41 gotGameIdToDownload(gamesList[index].
id);
44GameInfo CavokeClientModel::getGameByIndex(
int index) {
45 return gamesList[index];
48void CavokeClientModel::gotGameIdToDownload(
const QString &gameId) {
50 emit downloadGame(gameId);