From fb61b442ca724a644e6bac622c54f45affe0158d Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Wed, 2 Dec 2009 22:48:19 +0100 Subject: [PATCH] some (but not all) compatibility changes for qt 4.6 --- cockatrice/src/handzone.cpp | 44 ++++++++++++++++----------------- cockatrice/src/tablezone.cpp | 1 + cockatrice/src/zoneviewzone.cpp | 1 + 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/cockatrice/src/handzone.cpp b/cockatrice/src/handzone.cpp index eb98e387..321502b7 100644 --- a/cockatrice/src/handzone.cpp +++ b/cockatrice/src/handzone.cpp @@ -31,29 +31,29 @@ void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option void HandZone::reorganizeCards() { - if (cards.isEmpty()) - return; - - const int cardCount = cards.size(); - qreal totalWidth = boundingRect().width(); - qreal totalHeight = boundingRect().height(); - qreal cardWidth = cards.at(0)->boundingRect().width(); - qreal cardHeight = cards.at(0)->boundingRect().height(); - qreal xspace = 5; - qreal x1 = xspace; - qreal x2 = totalWidth - xspace - cardWidth; - - for (int i = 0; i < cardCount; i++) { - CardItem *c = cards.at(i); - qreal x = i % 2 ? x2 : x1; - // If the total height of the cards is smaller than the available height, - // the cards do not need to overlap and are displayed in the center of the area. - if (cardHeight * cardCount > totalHeight) - c->setPos(x, ((qreal) i) * (totalHeight - cardHeight) / (cardCount - 1)); - else - c->setPos(x, ((qreal) i) * cardHeight + (totalHeight - cardCount * cardHeight) / 2); - c->setZValue(i); + if (!cards.isEmpty()) { + const int cardCount = cards.size(); + qreal totalWidth = boundingRect().width(); + qreal totalHeight = boundingRect().height(); + qreal cardWidth = cards.at(0)->boundingRect().width(); + qreal cardHeight = cards.at(0)->boundingRect().height(); + qreal xspace = 5; + qreal x1 = xspace; + qreal x2 = totalWidth - xspace - cardWidth; + + for (int i = 0; i < cardCount; i++) { + CardItem *c = cards.at(i); + qreal x = i % 2 ? x2 : x1; + // If the total height of the cards is smaller than the available height, + // the cards do not need to overlap and are displayed in the center of the area. + if (cardHeight * cardCount > totalHeight) + c->setPos(x, ((qreal) i) * (totalHeight - cardHeight) / (cardCount - 1)); + else + c->setPos(x, ((qreal) i) * cardHeight + (totalHeight - cardCount * cardHeight) / 2); + c->setZValue(i); + } } + update(); } void HandZone::addCardImpl(CardItem *card, int x, int /*y*/) diff --git a/cockatrice/src/tablezone.cpp b/cockatrice/src/tablezone.cpp index 7a76016a..ca353242 100644 --- a/cockatrice/src/tablezone.cpp +++ b/cockatrice/src/tablezone.cpp @@ -73,6 +73,7 @@ void TableZone::handleDropEventByGrid(int cardId, CardZone *startZone, const QPo void TableZone::reorganizeCards() { + update(); } void TableZone::toggleTapped() diff --git a/cockatrice/src/zoneviewzone.cpp b/cockatrice/src/zoneviewzone.cpp index 63735d16..0c868d54 100644 --- a/cockatrice/src/zoneviewzone.cpp +++ b/cockatrice/src/zoneviewzone.cpp @@ -127,6 +127,7 @@ void ZoneViewZone::removeCard(int position) void ZoneViewZone::setGeometry(const QRectF &rect) { + prepareGeometryChange(); setPos(rect.topLeft()); height = rect.height(); reorganizeCards();