From 019b254b7e4dd4c925ee79406fa69d311c62488a Mon Sep 17 00:00:00 2001 From: RickyRister Date: Tue, 24 Dec 2024 22:45:04 -0800 Subject: [PATCH] rename old get replay match method to get enclosing --- .../remote/remote_replay_list_tree_widget.cpp | 15 ++++++++++++++- .../remote/remote_replay_list_tree_widget.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/server/remote/remote_replay_list_tree_widget.cpp b/cockatrice/src/server/remote/remote_replay_list_tree_widget.cpp index 838524519..d35a0316a 100644 --- a/cockatrice/src/server/remote/remote_replay_list_tree_widget.cpp +++ b/cockatrice/src/server/remote/remote_replay_list_tree_widget.cpp @@ -216,6 +216,18 @@ ServerInfo_Replay const *RemoteReplayList_TreeModel::getReplay(const QModelIndex } ServerInfo_ReplayMatch const *RemoteReplayList_TreeModel::getReplayMatch(const QModelIndex &index) const +{ + if (!index.isValid()) + return nullptr; + + auto *node = dynamic_cast(static_cast(index.internalPointer())); + if (!node) + return nullptr; + + return &node->getMatchInfo(); +} + +ServerInfo_ReplayMatch const *RemoteReplayList_TreeModel::getEnclosingReplayMatch(const QModelIndex &index) const { if (!index.isValid()) return nullptr; @@ -338,6 +350,7 @@ QList RemoteReplayList_TreeWidget::getSelectedReplays /** * Gets all currently selected replayMatches. + * If a non-folder node is selected, it will return the parent folder of that node. * * @return A Set of pointers to the selected replayMatches. */ @@ -346,7 +359,7 @@ QSet RemoteReplayList_TreeWidget::getSelectedRep const auto selection = selectionModel()->selectedRows(); auto replayMatches = QSet(); for (const auto &row : selection) { - if (const auto replayMatch = treeModel->getReplayMatch(proxyModel->mapToSource(row))) { + if (const auto replayMatch = treeModel->getEnclosingReplayMatch(proxyModel->mapToSource(row))) { replayMatches << replayMatch; } } diff --git a/cockatrice/src/server/remote/remote_replay_list_tree_widget.h b/cockatrice/src/server/remote/remote_replay_list_tree_widget.h index a93e693fa..4d03af3d7 100644 --- a/cockatrice/src/server/remote/remote_replay_list_tree_widget.h +++ b/cockatrice/src/server/remote/remote_replay_list_tree_widget.h @@ -97,6 +97,7 @@ public: void refreshTree(); ServerInfo_Replay const *getReplay(const QModelIndex &index) const; ServerInfo_ReplayMatch const *getReplayMatch(const QModelIndex &index) const; + ServerInfo_ReplayMatch const *getEnclosingReplayMatch(const QModelIndex &index) const; void addMatchInfo(const ServerInfo_ReplayMatch &matchInfo); void updateMatchInfo(int gameId, const ServerInfo_ReplayMatch &matchInfo); void removeMatchInfo(int gameId);