From 38f76d449a3c31dda9d4d251ed2f3d0a7ec28518 Mon Sep 17 00:00:00 2001 From: BruebachL <44814898+BruebachL@users.noreply.github.com> Date: Fri, 15 Aug 2025 07:11:02 +0200 Subject: [PATCH] Fix providerId cards getting removed from deckList by convenience replacement function (#6074) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 2 hours 25 minutes Co-authored-by: Lukas BrĂ¼bach --- .../ui/widgets/printing_selector/card_amount_widget.cpp | 8 +++++++- cockatrice/src/deck/deck_loader.cpp | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/client/ui/widgets/printing_selector/card_amount_widget.cpp b/cockatrice/src/client/ui/widgets/printing_selector/card_amount_widget.cpp index 62b6031fd..168a21ee7 100644 --- a/cockatrice/src/client/ui/widgets/printing_selector/card_amount_widget.cpp +++ b/cockatrice/src/client/ui/widgets/printing_selector/card_amount_widget.cpp @@ -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); diff --git a/cockatrice/src/deck/deck_loader.cpp b/cockatrice/src/deck/deck_loader.cpp index 965e71c56..eef8461bc 100644 --- a/cockatrice/src/deck/deck_loader.cpp +++ b/cockatrice/src/deck/deck_loader.cpp @@ -397,6 +397,7 @@ void DeckLoader::clearSetNamesAndNumbers() // Set the providerId on the card card->setCardSetShortName(nullptr); card->setCardCollectorNumber(nullptr); + card->setCardProviderId(nullptr); }; forEachCard(clearSetNameAndNumber);