Rework the appearance of poll delegate

![image](/uploads/510e995e15d76ce0566b126a6917a963/image.png){width=541 height=269}
This commit is contained in:
James Graham
2025-03-28 09:05:39 +00:00
parent 8180f111d0
commit fadb5725e0
5 changed files with 129 additions and 21 deletions

View File

@@ -12,7 +12,7 @@ PollAnswerModel::PollAnswerModel(PollHandler *parent)
Q_ASSERT(parent != nullptr);
connect(parent, &PollHandler::selectionsChanged, this, [this]() {
dataChanged(index(0), index(rowCount() - 1), {CountRole, LocalChoiceRole});
dataChanged(index(0), index(rowCount() - 1), {CountRole, LocalChoiceRole, IsWinnerRole});
});
connect(parent, &PollHandler::answersChanged, this, [this]() {
dataChanged(index(0), index(rowCount() - 1), {TextRole});
@@ -50,6 +50,9 @@ QVariant PollAnswerModel::data(const QModelIndex &index, int role) const
}
return pollHandler->checkMemberSelectedId(room->localMember().id(), pollHandler->answerAtRow(row).id);
}
if (role == IsWinnerRole) {
return pollHandler->winningAnswerIds().contains(pollHandler->answerAtRow(row).id) && pollHandler->hasEnded();
}
return {};
}
@@ -72,5 +75,6 @@ QHash<int, QByteArray> PollAnswerModel::roleNames() const
{TextRole, "answerText"},
{CountRole, "count"},
{LocalChoiceRole, "localChoice"},
{IsWinnerRole, "isWinner"},
};
}