Commit 1f2e9aae authored by Clinton Stimpson's avatar Clinton Stimpson
Browse files

BUG: Fix record/playback of item views to support hitting

      decoration items such as checkboxes.
parent 93bdb8cd
......@@ -118,18 +118,21 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co
else if(Command.startsWith("mouse"))
{
QStringList args = Arguments.split(',');
if(args.size() == 4)
if(args.size() == 6)
{
Qt::MouseButton button = static_cast<Qt::MouseButton>(args[0].toInt());
Qt::MouseButtons buttons = static_cast<Qt::MouseButton>(args[1].toInt());
Qt::KeyboardModifiers keym = static_cast<Qt::KeyboardModifier>(args[2].toInt());
QModelIndex idx = GetIndex(object, args[3]);
int x = args[3].toInt();
int y = args[4].toInt();
QModelIndex idx = GetIndex(object, args[5]);
QRect r = object->visualRect(idx);
QPoint pt = r.topLeft() + QPoint(x,y);
QEvent::Type type = QEvent::MouseButtonPress;
type = Command == "mouseMove" ? QEvent::MouseMove : type;
type = Command == "mouseRelease" ? QEvent::MouseButtonRelease : type;
type = Command == "mouseDblClick" ? QEvent::MouseButtonDblClick : type;
QMouseEvent e(type, r.center(), button, buttons, keym);
QMouseEvent e(type, pt, button, buttons, keym);
QCoreApplication::sendEvent(object->viewport(), &e);
pqEventDispatcher::processEventsAndWait(1);
return true;
......
......@@ -83,60 +83,45 @@ bool pqAbstractItemViewEventTranslator::translateEvent(QObject* Object, QEvent*
return true;
}
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
{
if(Object == object)
{
return false;
}
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
this->LastPos = mouseEvent->pos();
QModelIndex idx = object->indexAt(mouseEvent->pos());
QString idxStr = toIndexStr(idx);
QString info = QString("%1,%2,%3,%4")
.arg(mouseEvent->button())
.arg(mouseEvent->buttons())
.arg(mouseEvent->modifiers())
.arg(idxStr);
emit recordEvent(object, "mousePress", info);
return true;
}
case QEvent::MouseButtonDblClick:
{
if(Object == object)
if(Event->type() != QEvent::MouseButtonRelease)
{
return false;
this->LastPos = mouseEvent->pos();
}
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
this->LastPos = mouseEvent->pos();
QModelIndex idx = object->indexAt(mouseEvent->pos());
QString idxStr = toIndexStr(idx);
QString info = QString("%1,%2,%3,%4")
QRect r = object->visualRect(idx);
QPoint relPt = mouseEvent->pos() - r.topLeft();
QString info = QString("%1,%2,%3,%4,%5,%6")
.arg(mouseEvent->button())
.arg(mouseEvent->buttons())
.arg(mouseEvent->modifiers())
.arg(relPt.x())
.arg(relPt.y())
.arg(idxStr);
emit recordEvent(object, "mouseDblClick", info);
return true;
}
case QEvent::MouseButtonRelease:
{
if(Object == object)
if(Event->type() == QEvent::MouseButtonPress)
{
return false;
emit recordEvent(object, "mousePress", info);
}
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
QModelIndex idx = object->indexAt(mouseEvent->pos());
QString idxStr = toIndexStr(idx);
QString info = QString("%1,%2,%3,%4")
.arg(mouseEvent->button())
.arg(mouseEvent->buttons())
.arg(mouseEvent->modifiers())
.arg(idxStr);
if(this->LastPos != mouseEvent->pos())
else if(Event->type() == QEvent::MouseButtonDblClick)
{
emit recordEvent(object, "mouseDblClick", info);
}
else if(Event->type() == QEvent::MouseButtonRelease)
{
emit recordEvent(object, "mouseMove", info);
if(this->LastPos != mouseEvent->pos())
{
emit recordEvent(object, "mouseMove", info);
}
emit recordEvent(object, "mouseRelease", info);
}
emit recordEvent(object, "mouseRelease", info);
return true;
}
default:
......
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