Cleaning up TableModel::updateBiddings function
This commit is contained in:
@ -252,32 +252,10 @@ void TableModel::updateBiddings(const QList<bidding> biddings) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const QString uuid = localBidding.userId;
|
const QString uuid = localBidding.userId;
|
||||||
|
|
||||||
const QModelIndex itemIndex = getIndexByRoleValue(localBidding.userId, OnlineIdRole);
|
const QModelIndex itemIndex = getIndexByRoleValue(localBidding.userId, OnlineIdRole);
|
||||||
if (itemIndex.isValid()) {
|
if (itemIndex.isValid()) {
|
||||||
qInfo() << "Found Uuid for user:" << itemIndex.data(MailRole);
|
qInfo() << "Found Uuid for user:" << itemIndex.data(MailRole);
|
||||||
|
const QMap<int, QVariant> values = getItemValues(localBidding);
|
||||||
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}};
|
|
||||||
setItemData(itemIndex, values);
|
setItemData(itemIndex, values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -654,3 +632,31 @@ QModelIndex TableModel::getIndexByRoleValue(const QString& valueString, const in
|
|||||||
const QModelIndex itemIndex = index(itemRow, 0);
|
const QModelIndex itemIndex = index(itemRow, 0);
|
||||||
return itemIndex;
|
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