mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-23 15:13:55 -07:00
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:
parent
f2cbdae829
commit
38f76d449a
2 changed files with 8 additions and 1 deletions
|
|
@ -140,16 +140,22 @@ void CardAmountWidget::updateCardCount()
|
||||||
*/
|
*/
|
||||||
void CardAmountWidget::addPrinting(const QString &zone)
|
void CardAmountWidget::addPrinting(const QString &zone)
|
||||||
{
|
{
|
||||||
|
// Add the card and expand the list UI
|
||||||
auto newCardIndex = deckModel->addCard(rootCard, zone);
|
auto newCardIndex = deckModel->addCard(rootCard, zone);
|
||||||
recursiveExpand(newCardIndex);
|
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);
|
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);
|
auto amount = deckModel->data(find_card, Qt::DisplayRole);
|
||||||
for (int i = 0; i < amount.toInt() - 1; i++) {
|
for (int i = 0; i < amount.toInt() - 1; i++) {
|
||||||
deckModel->addCard(rootCard, zone);
|
deckModel->addCard(rootCard, zone);
|
||||||
}
|
}
|
||||||
deckModel->removeRow(find_card.row(), find_card.parent());
|
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(),
|
newCardIndex = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
|
||||||
rootCard.getPrinting().getProperty("num"));
|
rootCard.getPrinting().getProperty("num"));
|
||||||
deckView->setCurrentIndex(newCardIndex);
|
deckView->setCurrentIndex(newCardIndex);
|
||||||
|
|
|
||||||
|
|
@ -397,6 +397,7 @@ void DeckLoader::clearSetNamesAndNumbers()
|
||||||
// Set the providerId on the card
|
// Set the providerId on the card
|
||||||
card->setCardSetShortName(nullptr);
|
card->setCardSetShortName(nullptr);
|
||||||
card->setCardCollectorNumber(nullptr);
|
card->setCardCollectorNumber(nullptr);
|
||||||
|
card->setCardProviderId(nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
forEachCard(clearSetNameAndNumber);
|
forEachCard(clearSetNameAndNumber);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue