Merging received bidding into the model.

This commit is contained in:
2026-02-19 13:10:55 +01:00
parent 440333b589
commit d381e1ab8c
3 changed files with 41 additions and 11 deletions

View File

@ -240,17 +240,46 @@ void TableModel::setOnlineCredentials(const QString& mail,
}
void TableModel::updateBiddings(const QList<bidding> biddings) {
int round = biddings.first().biddingRound;
qInfo() << "Updating bidding for round:" << round << "...";
QListIterator<bidding> i(biddings);
while (i.hasNext()) {
const bidding localBidding = i.next();
qWarning() << "Processing bidding:";
qInfo() << "localBidding.userId:" << localBidding.userId;
qDebug() << "localBidding.biddingRound:" << localBidding.biddingRound;
qDebug() << "localBidding.amount:" << localBidding.amount;
qDebug() << "localBidding.depotWishOne:" << localBidding.depotWishOne;
qDebug() << "localBidding.depotWishTwo:" << localBidding.depotWishTwo;
qInfo() << "Processing bidding:";
const int biddingRound = localBidding.biddingRound;
if (biddingRound == 0 || biddingRound > 3) {
qWarning() << "Bidding round exceeds valid bounds. Ignoring...";
continue;
}
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}};
setItemData(itemIndex, values);
}
}
}
@ -618,7 +647,8 @@ QModelIndex TableModel::getIndexByRoleValue(const QString& valueString, const in
}
}
if (itemRow < 0 || itemRow >= m_items.length()) {
qWarning() << "Couldn't find item with mail address:" << valueString << "- Returning...";
qWarning() << "Couldn't find item with:" << valueString << " matching role" << role
<< "- Returning...";
return QModelIndex();
}
const QModelIndex itemIndex = index(itemRow, 0);