1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 15:15:31 +00:00

Minimise false detection of grab & drag operation.

This commit is contained in:
cc9cii 2014-10-28 06:42:33 +11:00
parent a01a921644
commit 5afaa0083f
2 changed files with 23 additions and 8 deletions

View file

@ -4,6 +4,7 @@
#include <sstream> #include <sstream>
#include <QMouseEvent> #include <QMouseEvent>
#include <QElapsedTimer>
#include <OgreCamera.h> #include <OgreCamera.h>
#include <OgreSceneManager.h> #include <OgreSceneManager.h>
@ -300,10 +301,16 @@ void CSVRender::PagedWorldspaceWidget::mouseMoveEvent (QMouseEvent *event)
{ {
case Mouse_Grab: case Mouse_Grab:
{ {
// FIXME: check if min elapsed time, mTimer.elapsed(); // check if min elapsed time to stop false detection of drag
// then stop/disable the timer if(!mMouseEventTimer->isValid() || !mMouseEventTimer->hasExpired(200)) // ms
mMouseState = Mouse_Drag; break;
//std::cout << "grab->drag" << std::endl; else
{
mMouseEventTimer->invalidate();
mMouseState = Mouse_Drag;
std::cout << "grab->drag" << std::endl;
}
/* FALL_THROUGH */ /* FALL_THROUGH */
} }
@ -322,7 +329,7 @@ void CSVRender::PagedWorldspaceWidget::mouseMoveEvent (QMouseEvent *event)
case Mouse_Edit: case Mouse_Edit:
case Mouse_Default: case Mouse_Default:
{ {
break; break; // error event, ignore
} }
/* NO_DEFAULT_CASE */ /* NO_DEFAULT_CASE */
} }
@ -355,9 +362,10 @@ void CSVRender::PagedWorldspaceWidget::mousePressEvent (QMouseEvent *event)
// FIXME: setup a x-z plane at the y position of the object // FIXME: setup a x-z plane at the y position of the object
// FIXME: ray test agaist the plane to get a starting position // FIXME: ray test agaist the plane to get a starting position
// of the mouse in relation to the object position // of the mouse in relation to the object position
mMouseEventTimer->start();
mMouseState = Mouse_Grab; mMouseState = Mouse_Grab;
//std::cout << "default/edit->grab" << std::endl; //std::cout << "default/edit->grab" << std::endl;
// FIXME: start QElapsedTimer mTimer.start();
} }
break; break;
} }
@ -597,7 +605,7 @@ std::string CSVRender::PagedWorldspaceWidget::getStartupInstruction()
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document) CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document)
: WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default"), : WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default"),
mControlElements(NULL), mDisplayCellCoord(true), mOverlayMask(NULL), mControlElements(NULL), mDisplayCellCoord(true), mOverlayMask(NULL),
mCurrentObj(""), mMouseState(Mouse_Default), mOldPos(0,0) mCurrentObj(""), mMouseState(Mouse_Default), mOldPos(0,0), mMouseEventTimer(0)
{ {
QAbstractItemModel *cells = QAbstractItemModel *cells =
document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells); document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells);
@ -609,7 +617,9 @@ CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc
connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)), connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
this, SLOT (cellAdded (const QModelIndex&, int, int))); this, SLOT (cellAdded (const QModelIndex&, int, int)));
initDebug(); initDebug();
mMouseEventTimer = new QElapsedTimer();
mMouseEventTimer->invalidate();
} }
CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget() CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget()
@ -631,6 +641,8 @@ CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget()
removeRenderTargetListener(mOverlayMask); removeRenderTargetListener(mOverlayMask);
delete mOverlayMask; delete mOverlayMask;
delete mMouseEventTimer;
// For debugging only // For debugging only
std::map<std::string, std::vector<std::string> >::iterator iter = mSelectedEntities.begin(); std::map<std::string, std::vector<std::string> >::iterator iter = mSelectedEntities.begin();
for(;iter != mSelectedEntities.end(); ++iter) for(;iter != mSelectedEntities.end(); ++iter)

View file

@ -8,6 +8,8 @@
#include "worldspacewidget.hpp" #include "worldspacewidget.hpp"
#include "cell.hpp" #include "cell.hpp"
class QElapsedTimer;
namespace CSVRender namespace CSVRender
{ {
@ -37,6 +39,7 @@ namespace CSVRender
MouseState mMouseState; MouseState mMouseState;
QPoint mOldPos; QPoint mOldPos;
std::string mCurrentObj; std::string mCurrentObj;
QElapsedTimer *mMouseEventTimer;
private: private: