mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 16:32:16 -07:00
refactor
This commit is contained in:
parent
79e284ba9b
commit
40a482686d
2 changed files with 10 additions and 2 deletions
|
|
@ -108,12 +108,12 @@ void ZoneViewZone::zoneDumpReceived(const Response &r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previousOrigSize = origZone->getCards().size();
|
previousOrigSize = origZone->getCards().size();
|
||||||
|
updateCardIds(false);
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
emit cardCountChanged();
|
emit cardCountChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because of boundingRect(), this function must not be called before the zone was added to a scene.
|
void ZoneViewZone::updateCardIds(bool /*isRemoval*/)
|
||||||
void ZoneViewZone::reorganizeCards()
|
|
||||||
{
|
{
|
||||||
int cardCount = cards.size();
|
int cardCount = cards.size();
|
||||||
if (!origZone->contentsKnown()) {
|
if (!origZone->contentsKnown()) {
|
||||||
|
|
@ -138,7 +138,11 @@ void ZoneViewZone::reorganizeCards()
|
||||||
cards[i]->setId(i + startId);
|
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);
|
CardList cardsToDisplay(cards);
|
||||||
|
|
||||||
// sort cards
|
// sort cards
|
||||||
|
|
@ -287,6 +291,7 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
}
|
}
|
||||||
card->setParentItem(this);
|
card->setParentItem(this);
|
||||||
card->update();
|
card->update();
|
||||||
|
updateCardIds(false);
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -325,6 +330,7 @@ void ZoneViewZone::removeCard(int position)
|
||||||
|
|
||||||
CardItem *card = cards.takeAt(position);
|
CardItem *card = cards.takeAt(position);
|
||||||
card->deleteLater();
|
card->deleteLater();
|
||||||
|
updateCardIds(false);
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ private:
|
||||||
int firstCardId;
|
int firstCardId;
|
||||||
int previousOrigSize;
|
int previousOrigSize;
|
||||||
|
|
||||||
|
void updateCardIds(bool isRemoval);
|
||||||
|
|
||||||
struct GridSize
|
struct GridSize
|
||||||
{
|
{
|
||||||
int rows;
|
int rows;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue