Drag from grave/rfg implemented
This commit is contained in:
parent
05e7b42193
commit
16631712c7
4 changed files with 76 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ public:
|
|||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||
void reorganizeCards();
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "rfgzone.h"
|
||||
#include "player.h"
|
||||
#include "client.h"
|
||||
#include "carddragitem.h"
|
||||
#include "zoneviewzone.h"
|
||||
|
||||
RfgZone::RfgZone(Player *_p, QGraphicsItem *parent)
|
||||
|
@ -56,3 +57,36 @@ void RfgZone::reorganizeCards()
|
|||
{
|
||||
update(boundingRect());
|
||||
}
|
||||
|
||||
void RfgZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
CardZone::mousePressEvent(event);
|
||||
if (event->isAccepted())
|
||||
return;
|
||||
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
setCursor(Qt::ClosedHandCursor);
|
||||
event->accept();
|
||||
} else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void RfgZone::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 RfgZone::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ public:
|
|||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||
void reorganizeCards();
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue