Fix providerId cards getting removed from deckList by convenience replacement function (#6074)

Took 2 hours 25 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-08-15 07:11:02 +02:00 committed by GitHub
parent f2cbdae829
commit 38f76d449a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -140,16 +140,22 @@ void CardAmountWidget::updateCardCount()
*/
void CardAmountWidget::addPrinting(const QString &zone)
{
// Add the card and expand the list UI
auto newCardIndex = deckModel->addCard(rootCard, zone);
recursiveExpand(newCardIndex);
// Check if a card without a providerId already exists in the deckModel and replace it, if so.
QModelIndex find_card = deckModel->findCard(rootCard.getName(), zone);
if (find_card.isValid() && find_card != newCardIndex) {
QString foundProviderId = deckModel->data(find_card.sibling(find_card.row(), 4), Qt::DisplayRole).toString();
if (find_card.isValid() && find_card != newCardIndex && foundProviderId == "") {
auto amount = deckModel->data(find_card, Qt::DisplayRole);
for (int i = 0; i < amount.toInt() - 1; i++) {
deckModel->addCard(rootCard, zone);
}
deckModel->removeRow(find_card.row(), find_card.parent());
}
// Set Index and Focus as if the user had just clicked the new card and modify the deckEditor saveState
newCardIndex = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
rootCard.getPrinting().getProperty("num"));
deckView->setCurrentIndex(newCardIndex);

View file

@ -397,6 +397,7 @@ void DeckLoader::clearSetNamesAndNumbers()
// Set the providerId on the card
card->setCardSetShortName(nullptr);
card->setCardCollectorNumber(nullptr);
card->setCardProviderId(nullptr);
};
forEachCard(clearSetNameAndNumber);