Allow offline Replays tab (#5519)

This commit is contained in:
RickyRister 2025-01-24 21:44:48 -08:00 committed by GitHub
parent ec6a23de56
commit 19b758591b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 65 additions and 17 deletions

View file

@ -43,7 +43,7 @@ RemoteReplayList_TreeModel::RemoteReplayList_TreeModel(AbstractClient *_client,
RemoteReplayList_TreeModel::~RemoteReplayList_TreeModel()
{
clearTree();
clearAll();
}
int RemoteReplayList_TreeModel::rowCount(const QModelIndex &parent) const
@ -242,7 +242,10 @@ ServerInfo_ReplayMatch const *RemoteReplayList_TreeModel::getEnclosingReplayMatc
return &node->getMatchInfo();
}
void RemoteReplayList_TreeModel::clearTree()
/**
* Deletes all items in the model
*/
void RemoteReplayList_TreeModel::clearAll()
{
for (int i = 0; i < replayMatches.size(); ++i)
delete replayMatches[i];
@ -258,6 +261,13 @@ void RemoteReplayList_TreeModel::refreshTree()
client->sendCommand(pend);
}
void RemoteReplayList_TreeModel::clearTree()
{
beginResetModel();
clearAll();
endResetModel();
}
void RemoteReplayList_TreeModel::addMatchInfo(const ServerInfo_ReplayMatch &matchInfo)
{
beginInsertRows(QModelIndex(), replayMatches.size(), replayMatches.size());
@ -294,7 +304,7 @@ void RemoteReplayList_TreeModel::replayListFinished(const Response &r)
const Response_ReplayList &resp = r.GetExtension(Response_ReplayList::ext);
beginResetModel();
clearTree();
clearAll();
for (int i = 0; i < resp.match_list_size(); ++i)
replayMatches.append(new MatchNode(resp.match_list(i)));

View file

@ -73,7 +73,7 @@ private:
QList<MatchNode *> replayMatches;
QIcon dirIcon, fileIcon, lockIcon;
void clearTree();
void clearAll();
static const int numberOfColumns;
signals:
@ -94,6 +94,7 @@ public:
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
void clearTree();
void refreshTree();
ServerInfo_Replay const *getReplay(const QModelIndex &index) const;
ServerInfo_ReplayMatch const *getReplayMatch(const QModelIndex &index) const;
@ -115,6 +116,10 @@ public:
ServerInfo_ReplayMatch const *getReplayMatch(const QModelIndex &ind) const;
QList<ServerInfo_Replay const *> getSelectedReplays() const;
QSet<ServerInfo_ReplayMatch const *> getSelectedReplayMatches() const;
void clearTree()
{
treeModel->clearTree();
}
void refreshTree()
{
treeModel->refreshTree();