Commit ec2382dd authored by Ian Wadham's avatar Ian Wadham

Add a double-click event handler and prevent scene items from receiving mouse...

Add a double-click event handler and prevent scene items from receiving mouse clicks. This is to allow very rapid sequences of digging operations.

svn path=/branches/work/kgoldrunner-qgv/; revision=1314413
parent a3afa468
...@@ -154,6 +154,7 @@ KGameRenderedItem * KGrRenderer::getTileItem ...@@ -154,6 +154,7 @@ KGameRenderedItem * KGrRenderer::getTileItem
KGameRenderedItem * tile = KGameRenderedItem * tile =
new KGameRenderedItem ((keyTable[index].picSource == Set) ? new KGameRenderedItem ((keyTable[index].picSource == Set) ?
m_setRenderer : m_actorsRenderer, key); m_setRenderer : m_actorsRenderer, key);
tile->setAcceptedMouseButtons (0);
m_scene->addItem (tile); m_scene->addItem (tile);
return tile; return tile;
} }
...@@ -169,6 +170,7 @@ KGrSprite * KGrRenderer::getSpriteItem (const char picType, const int tickTime) ...@@ -169,6 +170,7 @@ KGrSprite * KGrRenderer::getSpriteItem (const char picType, const int tickTime)
KGrSprite * sprite = new KGrSprite ((keyTable[index].picSource == Set) ? KGrSprite * sprite = new KGrSprite ((keyTable[index].picSource == Set) ?
m_setRenderer : m_actorsRenderer, m_setRenderer : m_actorsRenderer,
key, picType, tickTime); key, picType, tickTime);
sprite->setAcceptedMouseButtons (0);
// We cannot add the sprite to the scene yet: it needs a frame and size. // We cannot add the sprite to the scene yet: it needs a frame and size.
return sprite; return sprite;
} }
...@@ -183,6 +185,7 @@ KGameRenderedItem * KGrRenderer::getBackground ...@@ -183,6 +185,7 @@ KGameRenderedItem * KGrRenderer::getBackground
QString key = getBackgroundKey (level); QString key = getBackgroundKey (level);
KGameRenderedItem * background = new KGameRenderedItem (m_setRenderer, key); KGameRenderedItem * background = new KGameRenderedItem (m_setRenderer, key);
background->setAcceptedMouseButtons (0);
m_scene->addItem (background); m_scene->addItem (background);
return background; return background;
...@@ -201,6 +204,7 @@ KGameRenderedItem * KGrRenderer::getBorderItem ...@@ -201,6 +204,7 @@ KGameRenderedItem * KGrRenderer::getBorderItem
} }
KGameRenderedItem * item = new KGameRenderedItem (m_setRenderer, spriteKey); KGameRenderedItem * item = new KGameRenderedItem (m_setRenderer, spriteKey);
item->setAcceptedMouseButtons (0);
m_scene->addItem (item); m_scene->addItem (item);
return item; return item;
} }
......
...@@ -83,6 +83,11 @@ void KGrView::mousePressEvent (QMouseEvent * mouseEvent) ...@@ -83,6 +83,11 @@ void KGrView::mousePressEvent (QMouseEvent * mouseEvent)
emit mouseClick (mouseEvent->button()); emit mouseClick (mouseEvent->button());
} }
void KGrView::mouseDoubleClickEvent (QMouseEvent * mouseEvent)
{
emit mouseClick (mouseEvent->button());
}
void KGrView::mouseReleaseEvent (QMouseEvent * mouseEvent) void KGrView::mouseReleaseEvent (QMouseEvent * mouseEvent)
{ {
emit mouseLetGo (mouseEvent->button()); emit mouseLetGo (mouseEvent->button());
......
...@@ -51,9 +51,10 @@ signals: ...@@ -51,9 +51,10 @@ signals:
void mouseLetGo (int); void mouseLetGo (int);
protected: protected:
virtual void resizeEvent (QResizeEvent *); virtual void resizeEvent (QResizeEvent *);
virtual void mousePressEvent (QMouseEvent * mouseEvent); virtual void mousePressEvent (QMouseEvent * mouseEvent);
virtual void mouseReleaseEvent (QMouseEvent * mouseEvent); virtual void mouseDoubleClickEvent (QMouseEvent * mouseEvent);
virtual void mouseReleaseEvent (QMouseEvent * mouseEvent);
private: private:
QCursor * m_mouse; QCursor * m_mouse;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment