[games/chessament] src: Remove fancy way of updating standings
Manuel Alcaraz Zambrano <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit ae67ad091e99f513230859a6b1f71e959136596c by Manuel Alcaraz Zambrano.
Committed on 04/08/2026 at 09:14.
Pushed by manuelal into branch 'master'.
Remove fancy way of updating standings
As it doesn't work with a sort proxy model in front of it.
M +2 -31 src/standingsmodel.cpp
https://invent.kde.org/games/chessament/-/commit/ae67ad091e99f513230859a6b1f71e959136596c
diff --git a/src/standingsmodel.cpp b/src/standingsmodel.cpp
index 9f711ed..88ee82d 100644
--- a/src/standingsmodel.cpp
+++ b/src/standingsmodel.cpp
@@ -107,38 +107,9 @@ QVariant StandingsModel::headerData(int section, Qt::Orientation orientation, in
void StandingsModel::setStandings(QList<Standing> standings)
{
- auto rowDiff = standings.size() - m_standings.size();
-
- int newColumns = 4 + static_cast<int>(standings.isEmpty() ? 0 : standings[0].values().size());
- int prevColumns = 4 + static_cast<int>(m_standings.isEmpty() ? 0 : m_standings[0].values().size());
- int columnDiff = newColumns - prevColumns;
-
- if (rowDiff > 0) {
- beginInsertRows({}, static_cast<int>(m_standings.size()), static_cast<int>(standings.size()) - 1);
- } else if (rowDiff < 0) {
- beginRemoveRows({}, static_cast<int>(standings.size()), static_cast<int>(m_standings.size()) - 1);
- }
- if (columnDiff > 0) {
- beginInsertColumns({}, prevColumns, newColumns - 1);
- } else if (columnDiff < 0) {
- beginRemoveColumns({}, newColumns, prevColumns - 1);
- }
-
+ beginResetModel();
m_standings = std::move(standings);
-
- if (rowDiff > 0) {
- endInsertRows();
- } else if (rowDiff < 0) {
- endRemoveRows();
- }
- if (columnDiff > 0) {
- endInsertColumns();
- } else if (columnDiff < 0) {
- endRemoveColumns();
- }
-
- Q_EMIT headerDataChanged(Qt::Horizontal, 0, columnCount() - 1);
- Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
+ endResetModel();
}
void StandingsModel::setTournament(Tournament *tournament)