From 06589e5a091c8362f6b22d8f42e7926cc245b8c8 Mon Sep 17 00:00:00 2001 From: Bent Witthold Date: Thu, 19 Feb 2026 13:20:07 +0100 Subject: [PATCH] Cleaning up TableModel::updateBiddings function --- libs/BeetRoundCore/model/tablemodel.cpp | 54 ++++++++++++++----------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/libs/BeetRoundCore/model/tablemodel.cpp b/libs/BeetRoundCore/model/tablemodel.cpp index 248b2e3..5447b52 100644 --- a/libs/BeetRoundCore/model/tablemodel.cpp +++ b/libs/BeetRoundCore/model/tablemodel.cpp @@ -251,33 +251,11 @@ void TableModel::updateBiddings(const QList biddings) { qWarning() << "Bidding round exceeds valid bounds. Ignoring..."; continue; } - const QString uuid = localBidding.userId; - + const QString uuid = localBidding.userId; const QModelIndex itemIndex = getIndexByRoleValue(localBidding.userId, OnlineIdRole); if (itemIndex.isValid()) { qInfo() << "Found Uuid for user:" << itemIndex.data(MailRole); - - const int amount = localBidding.amount; - const QString depotWishOne = localBidding.depotWishOne; - const QString depotWishTwo = localBidding.depotWishTwo; - - UserRoles biddingRole; - switch (biddingRound) { - case 1: - biddingRole = Bidding1Role; - break; - case 2: - biddingRole = Bidding2Role; - break; - case 3: - biddingRole = Bidding3Role; - break; - default: - break; - } - - QMap values = { - {biddingRole, amount}, {DepotWish1Role, depotWishOne}, {DepotWish2Role, depotWishTwo}}; + const QMap values = getItemValues(localBidding); setItemData(itemIndex, values); } } @@ -654,3 +632,31 @@ QModelIndex TableModel::getIndexByRoleValue(const QString& valueString, const in const QModelIndex itemIndex = index(itemRow, 0); return itemIndex; } + +QMap TableModel::getItemValues(const bidding bid) { + const int biddingRound = bid.biddingRound; + const int amount = bid.amount; + const QString depotWishOne = bid.depotWishOne; + const QString depotWishTwo = bid.depotWishTwo; + + UserRoles biddingRole; + switch (biddingRound) { + case 1: + biddingRole = Bidding1Role; + break; + case 2: + biddingRole = Bidding2Role; + break; + case 3: + biddingRole = Bidding3Role; + break; + default: + break; + } + + if (biddingRound == 1) { + return {{biddingRole, amount}, {DepotWish1Role, depotWishOne}, {DepotWish2Role, depotWishTwo}}; + } else { + return {{biddingRole, amount}}; + } +}