mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 16:32:16 -07:00
add method for clearing remote replays model
This commit is contained in:
parent
25c3acf866
commit
c97e6aa43e
2 changed files with 19 additions and 4 deletions
|
|
@ -43,7 +43,7 @@ RemoteReplayList_TreeModel::RemoteReplayList_TreeModel(AbstractClient *_client,
|
||||||
|
|
||||||
RemoteReplayList_TreeModel::~RemoteReplayList_TreeModel()
|
RemoteReplayList_TreeModel::~RemoteReplayList_TreeModel()
|
||||||
{
|
{
|
||||||
clearTree();
|
clearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
int RemoteReplayList_TreeModel::rowCount(const QModelIndex &parent) const
|
int RemoteReplayList_TreeModel::rowCount(const QModelIndex &parent) const
|
||||||
|
|
@ -242,7 +242,10 @@ ServerInfo_ReplayMatch const *RemoteReplayList_TreeModel::getEnclosingReplayMatc
|
||||||
return &node->getMatchInfo();
|
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)
|
for (int i = 0; i < replayMatches.size(); ++i)
|
||||||
delete replayMatches[i];
|
delete replayMatches[i];
|
||||||
|
|
@ -258,6 +261,13 @@ void RemoteReplayList_TreeModel::refreshTree()
|
||||||
client->sendCommand(pend);
|
client->sendCommand(pend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoteReplayList_TreeModel::clearTree()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
clearAll();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
void RemoteReplayList_TreeModel::addMatchInfo(const ServerInfo_ReplayMatch &matchInfo)
|
void RemoteReplayList_TreeModel::addMatchInfo(const ServerInfo_ReplayMatch &matchInfo)
|
||||||
{
|
{
|
||||||
beginInsertRows(QModelIndex(), replayMatches.size(), replayMatches.size());
|
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);
|
const Response_ReplayList &resp = r.GetExtension(Response_ReplayList::ext);
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
clearTree();
|
clearAll();
|
||||||
|
|
||||||
for (int i = 0; i < resp.match_list_size(); ++i)
|
for (int i = 0; i < resp.match_list_size(); ++i)
|
||||||
replayMatches.append(new MatchNode(resp.match_list(i)));
|
replayMatches.append(new MatchNode(resp.match_list(i)));
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ private:
|
||||||
QList<MatchNode *> replayMatches;
|
QList<MatchNode *> replayMatches;
|
||||||
|
|
||||||
QIcon dirIcon, fileIcon, lockIcon;
|
QIcon dirIcon, fileIcon, lockIcon;
|
||||||
void clearTree();
|
void clearAll();
|
||||||
|
|
||||||
static const int numberOfColumns;
|
static const int numberOfColumns;
|
||||||
signals:
|
signals:
|
||||||
|
|
@ -94,6 +94,7 @@ public:
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||||
QModelIndex parent(const QModelIndex &index) const;
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
void clearTree();
|
||||||
void refreshTree();
|
void refreshTree();
|
||||||
ServerInfo_Replay const *getReplay(const QModelIndex &index) const;
|
ServerInfo_Replay const *getReplay(const QModelIndex &index) const;
|
||||||
ServerInfo_ReplayMatch const *getReplayMatch(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;
|
ServerInfo_ReplayMatch const *getReplayMatch(const QModelIndex &ind) const;
|
||||||
QList<ServerInfo_Replay const *> getSelectedReplays() const;
|
QList<ServerInfo_Replay const *> getSelectedReplays() const;
|
||||||
QSet<ServerInfo_ReplayMatch const *> getSelectedReplayMatches() const;
|
QSet<ServerInfo_ReplayMatch const *> getSelectedReplayMatches() const;
|
||||||
|
void clearTree()
|
||||||
|
{
|
||||||
|
treeModel->clearTree();
|
||||||
|
}
|
||||||
void refreshTree()
|
void refreshTree()
|
||||||
{
|
{
|
||||||
treeModel->refreshTree();
|
treeModel->refreshTree();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue