Cleaning up TableModel::updateBiddings function
This commit is contained in:
@ -251,33 +251,11 @@ void TableModel::updateBiddings(const QList<bidding> 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<int, QVariant> values = {
|
||||
{biddingRole, amount}, {DepotWish1Role, depotWishOne}, {DepotWish2Role, depotWishTwo}};
|
||||
const QMap<int, QVariant> 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<int, QVariant> 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}};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user