Drag from grave/rfg implemented

This commit is contained in:
Max-Wilhelm Bruker
2009-04-03 14:50:06 +02:00
parent 05e7b42193
commit 16631712c7
4 changed files with 76 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
#include "gravezone.h"
#include "player.h"
#include "client.h"
#include "carddragitem.h"
#include "zoneviewzone.h"
GraveZone::GraveZone(Player *_p, QGraphicsItem *parent)
@@ -56,3 +57,36 @@ void GraveZone::reorganizeCards()
{
update(boundingRect());
}
void GraveZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
CardZone::mousePressEvent(event);
if (event->isAccepted())
return;
if (event->button() == Qt::LeftButton) {
setCursor(Qt::ClosedHandCursor);
event->accept();
} else
event->ignore();
}
void GraveZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() < QApplication::startDragDistance())
return;
if (cards->empty())
return;
CardItem *card = cards->at(0);
CardDragItem *drag = card->createDragItem(this, card->getId(), event->pos(), event->scenePos());
drag->grabMouse();
setCursor(Qt::OpenHandCursor);
}
void GraveZone::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event);
setCursor(Qt::OpenHandCursor);
}