dynamic pixmap cache update

This commit is contained in:
Max-Wilhelm Bruker 2009-08-29 20:17:02 +02:00
parent 0f737e6155
commit 4beb990f38
6 changed files with 37 additions and 8 deletions

View file

@ -15,6 +15,8 @@ CardItem::CardItem(CardDatabase *_db, const QString &_name, int _cardid, QGraphi
setFlag(ItemIsSelectable);
setAcceptsHoverEvents(true);
setCacheMode(DeviceCoordinateCache);
connect(info, SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
}
CardItem::~CardItem()
@ -28,6 +30,11 @@ QRectF CardItem::boundingRect() const
return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT);
}
void CardItem::pixmapUpdated()
{
update();
}
void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget */*widget*/)
{
painter->save();
@ -105,8 +112,10 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
void CardItem::setName(const QString &_name)
{
disconnect(info, 0, this, 0);
name = _name;
info = db->getCard(name);
connect(info, SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
update();
}