This commit is contained in:
RickyRister 2025-01-03 18:59:49 -08:00
parent 79e284ba9b
commit 40a482686d
2 changed files with 10 additions and 2 deletions

View file

@ -108,12 +108,12 @@ void ZoneViewZone::zoneDumpReceived(const Response &r)
}
}
previousOrigSize = origZone->getCards().size();
updateCardIds(false);
reorganizeCards();
emit cardCountChanged();
}
// Because of boundingRect(), this function must not be called before the zone was added to a scene.
void ZoneViewZone::reorganizeCards()
void ZoneViewZone::updateCardIds(bool /*isRemoval*/)
{
int cardCount = cards.size();
if (!origZone->contentsKnown()) {
@ -138,7 +138,11 @@ void ZoneViewZone::reorganizeCards()
cards[i]->setId(i + startId);
}
}
}
// Because of boundingRect(), this function must not be called before the zone was added to a scene.
void ZoneViewZone::reorganizeCards()
{
CardList cardsToDisplay(cards);
// sort cards
@ -287,6 +291,7 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
}
card->setParentItem(this);
card->update();
updateCardIds(false);
reorganizeCards();
}
@ -325,6 +330,7 @@ void ZoneViewZone::removeCard(int position)
CardItem *card = cards.takeAt(position);
card->deleteLater();
updateCardIds(false);
reorganizeCards();
}

View file

@ -38,6 +38,8 @@ private:
int firstCardId;
int previousOrigSize;
void updateCardIds(bool isRemoval);
struct GridSize
{
int rows;