Skip to content

Commit

Permalink
Fix player category column refreshing
Browse files Browse the repository at this point in the history
Fixes #40.
  • Loading branch information
svendcs committed Aug 20, 2020
1 parent 449e550 commit f981bb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/core/actions/add_players_to_category_action.cpp
Expand Up @@ -36,19 +36,17 @@ void AddPlayersToCategoryAction::redoImpl(TournamentStore & tournament) {
category.addPlayer(playerId);
}

tournament.addPlayersToCategory(mCategoryId, mAddedPlayerIds);

if (!mAddedPlayerIds.empty()) {
mDrawAction = std::make_unique<DrawCategoriesAction>(std::vector<CategoryId>{mCategoryId}, mSeed);
mDrawAction->redo(tournament);
}

tournament.addPlayersToCategory(mCategoryId, mAddedPlayerIds);
}

void AddPlayersToCategoryAction::undoImpl(TournamentStore & tournament) {
if (!tournament.containsCategory(mCategoryId)) return;

tournament.erasePlayersFromCategory(mCategoryId, mAddedPlayerIds);

CategoryStore & category = tournament.getCategory(mCategoryId);
for (auto playerId : mAddedPlayerIds) {
PlayerStore & player = tournament.getPlayer(playerId);
Expand All @@ -61,6 +59,8 @@ void AddPlayersToCategoryAction::undoImpl(TournamentStore & tournament) {
mDrawAction.reset();
}

tournament.erasePlayersFromCategory(mCategoryId, mAddedPlayerIds);

mAddedPlayerIds.clear();
}

Expand Down
3 changes: 2 additions & 1 deletion src/ui/models/players_model.cpp
Expand Up @@ -206,9 +206,10 @@ QString PlayersModel::listPlayerCategories(const PlayerStore &player) const {
}

void PlayersModel::playerCategoriesChanged(const std::vector<PlayerId> &playerIds) {
static constexpr unsigned int CATEGORY_COLUMN = 8;
for (auto playerId : playerIds) {
int row = getRow(playerId);
emit dataChanged(createIndex(row, 7), createIndex(row, 7));
emit dataChanged(createIndex(row, CATEGORY_COLUMN), createIndex(row, CATEGORY_COLUMN));
}
}

Expand Down

0 comments on commit f981bb0

Please sign in to comment.