small changes

This commit is contained in:
Max-Wilhelm Bruker 2009-07-01 01:05:52 +02:00
parent 47eadb6f86
commit c3fb56581d
12 changed files with 23 additions and 22 deletions

View file

@ -70,7 +70,7 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
void CardItem::setName(const QString &_name) void CardItem::setName(const QString &_name)
{ {
name = _name; name = _name;
update(boundingRect()); update();
} }
void CardItem::setTapped(bool _tapped) void CardItem::setTapped(bool _tapped)
@ -80,31 +80,31 @@ void CardItem::setTapped(bool _tapped)
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(90).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2)); setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(90).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
else else
setTransform(QTransform()); setTransform(QTransform());
update(boundingRect()); update();
} }
void CardItem::setAttacking(bool _attacking) void CardItem::setAttacking(bool _attacking)
{ {
attacking = _attacking; attacking = _attacking;
update(boundingRect()); update();
} }
void CardItem::setFaceDown(bool _facedown) void CardItem::setFaceDown(bool _facedown)
{ {
facedown = _facedown; facedown = _facedown;
update(boundingRect()); update();
} }
void CardItem::setCounters(int _counters) void CardItem::setCounters(int _counters)
{ {
counters = _counters; counters = _counters;
update(boundingRect()); update();
} }
void CardItem::setAnnotation(const QString &_annotation) void CardItem::setAnnotation(const QString &_annotation)
{ {
annotation = _annotation; annotation = _annotation;
update(boundingRect()); update();
} }
void CardItem::setDoesntUntap(bool _doesntUntap) void CardItem::setDoesntUntap(bool _doesntUntap)
@ -120,7 +120,7 @@ void CardItem::resetState()
annotation = QString(); annotation = QString();
setTapped(false); setTapped(false);
setDoesntUntap(false); setDoesntUntap(false);
update(boundingRect()); update();
} }
CardDragItem *CardItem::createDragItem(int _id, const QPointF &_pos, const QPointF &_scenePos, bool faceDown) CardDragItem *CardItem::createDragItem(int _id, const QPointF &_pos, const QPointF &_scenePos, bool faceDown)
@ -215,7 +215,7 @@ QVariant CardItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QV
return value; return value;
} else if (change == ItemSelectedHasChanged) { } else if (change == ItemSelectedHasChanged) {
qDebug("selection changed"); qDebug("selection changed");
update(boundingRect()); update();
return value; return value;
} else } else
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);

View file

@ -1,4 +1,5 @@
#include "cardlist.h" #include "cardlist.h"
#include "carditem.h"
CardList::CardList(bool _contentsKnown) CardList::CardList(bool _contentsKnown)
: QList<CardItem *>(), contentsKnown(_contentsKnown) : QList<CardItem *>(), contentsKnown(_contentsKnown)

View file

@ -1,9 +1,10 @@
#ifndef CARDLIST_H #ifndef CARDLIST_H
#define CARDLIST_H #define CARDLIST_H
#include "carditem.h"
#include <QList> #include <QList>
class CardItem;
class CardList : public QList<CardItem *> { class CardList : public QList<CardItem *> {
protected: protected:
bool contentsKnown; bool contentsKnown;

View file

@ -6,7 +6,7 @@
#include "zoneviewzone.h" #include "zoneviewzone.h"
CardZone::CardZone(Player *_p, const QString &_name, bool _hasCardAttr, bool _isShufflable, QGraphicsItem *parent, bool isView) CardZone::CardZone(Player *_p, const QString &_name, bool _hasCardAttr, bool _isShufflable, QGraphicsItem *parent, bool isView)
: AbstractGraphicsItem(parent), player(_p), name(_name), cards(NULL), view(NULL), menu(NULL), hasCardAttr(_hasCardAttr), isShufflable(_isShufflable) : AbstractGraphicsItem(parent), player(_p), name(_name), cards(NULL), view(NULL), menu(NULL), doubleClickAction(0), hasCardAttr(_hasCardAttr), isShufflable(_isShufflable)
{ {
if (!isView) if (!isView)
player->addZone(this); player->addZone(this);
@ -27,7 +27,7 @@ void CardZone::clearContents()
cards->clear(); cards->clear();
} }
void CardZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void CardZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent */*event*/)
{ {
if (doubleClickAction) if (doubleClickAction)
doubleClickAction->trigger(); doubleClickAction->trigger();
@ -71,8 +71,7 @@ CardItem *CardZone::getCard(int cardId, const QString &cardName)
CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName) CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName)
{ {
if (position >= cards->size()) Q_ASSERT(position < cards->size());
return NULL;
CardItem *c = cards->takeAt(position); CardItem *c = cards->takeAt(position);

View file

@ -3,6 +3,7 @@
#include <QString> #include <QString>
#include "cardlist.h" #include "cardlist.h"
#include "carditem.h"
#include "abstractgraphicsitem.h" #include "abstractgraphicsitem.h"
class Player; class Player;

View file

@ -26,7 +26,7 @@ void Counter::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*
void Counter::setValue(int _value) void Counter::setValue(int _value)
{ {
value = _value; value = _value;
update(boundingRect()); update();
} }
void Counter::mousePressEvent(QGraphicsSceneMouseEvent *event) void Counter::mousePressEvent(QGraphicsSceneMouseEvent *event)

View file

@ -59,7 +59,7 @@ void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
card->setParentItem(this); card->setParentItem(this);
card->resetState(); card->resetState();
card->setVisible(true); card->setVisible(true);
card->update(card->boundingRect()); card->update();
} }
void HandZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/) void HandZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)

View file

@ -50,7 +50,7 @@ void LibraryZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint
void LibraryZone::reorganizeCards() void LibraryZone::reorganizeCards()
{ {
update(boundingRect()); update();
} }
void LibraryZone::mousePressEvent(QGraphicsSceneMouseEvent *event) void LibraryZone::mousePressEvent(QGraphicsSceneMouseEvent *event)

View file

@ -20,6 +20,7 @@ QRectF PileZone::boundingRect() const
void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
qDebug("PileZone::paint");
if (!cards->isEmpty()) { if (!cards->isEmpty()) {
painter->save(); painter->save();
cards->at(0)->paint(painter, option, widget); cards->at(0)->paint(painter, option, widget);
@ -47,7 +48,7 @@ void PileZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/*
void PileZone::reorganizeCards() void PileZone::reorganizeCards()
{ {
qDebug(QString("PileZone: reorganize, x=%1, y=%2, w=%3, h=%4").arg(boundingRect().x()).arg(boundingRect().y()).arg(boundingRect().width()).arg(boundingRect().height()).toLatin1()); qDebug(QString("PileZone: reorganize, x=%1, y=%2, w=%3, h=%4").arg(boundingRect().x()).arg(boundingRect().y()).arg(boundingRect().width()).arg(boundingRect().height()).toLatin1());
update(boundingRect()); update();
} }
void PileZone::mousePressEvent(QGraphicsSceneMouseEvent *event) void PileZone::mousePressEvent(QGraphicsSceneMouseEvent *event)

View file

@ -31,7 +31,7 @@ void TableZone::addCardImpl(CardItem *card, int x, int y)
qDebug(QString("table: appended %1 at pos %2: zValue = %3, x = %4, y = %5").arg(card->getName()).arg(cards->size() - 1).arg(card->zValue()).arg(x).arg(y).toLatin1()); qDebug(QString("table: appended %1 at pos %2: zValue = %3, x = %4, y = %5").arg(card->getName()).arg(cards->size() - 1).arg(card->zValue()).arg(x).arg(y).toLatin1());
card->setParentItem(this); card->setParentItem(this);
card->setVisible(true); card->setVisible(true);
card->update(card->boundingRect()); card->update();
} }
void TableZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown) void TableZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown)

View file

@ -52,7 +52,6 @@ void ZoneViewLayout::removeItem(ZoneViewWidget *item)
{ {
qDebug("ZoneViewLayout::removeItem"); qDebug("ZoneViewLayout::removeItem");
views.removeAt(views.indexOf(item)); views.removeAt(views.indexOf(item));
scene()->removeItem(item);
reorganize(); reorganize();
} }

View file

@ -75,7 +75,7 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
{ {
cards->insert(x, card); cards->insert(x, card);
card->setParentItem(this); card->setParentItem(this);
card->update(card->boundingRect()); card->update();
} }
void ZoneViewZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/) void ZoneViewZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
@ -89,8 +89,7 @@ void ZoneViewZone::removeCard(int position)
if (position >= cards->size()) if (position >= cards->size())
return; return;
CardItem *card = cards->at(position); CardItem *card = cards->takeAt(position);
cards->removeAt(position);
delete card; delete card;
reorganizeCards(); reorganizeCards();
} }