Commit 9314e49d authored by Clinton Stimpson's avatar Clinton Stimpson
Browse files

ENH: Special case QHeaderView to support it properly.

parent ae1a4510
...@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqAbstractItemViewEventPlayer.h" #include "pqAbstractItemViewEventPlayer.h"
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QHeaderView>
#include <QApplication> #include <QApplication>
#include <QMouseEvent> #include <QMouseEvent>
#include <QKeyEvent> #include <QKeyEvent>
...@@ -125,9 +126,26 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co ...@@ -125,9 +126,26 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co
Qt::KeyboardModifiers keym = static_cast<Qt::KeyboardModifier>(args[2].toInt()); Qt::KeyboardModifiers keym = static_cast<Qt::KeyboardModifier>(args[2].toInt());
int x = args[3].toInt(); int x = args[3].toInt();
int y = args[4].toInt(); int y = args[4].toInt();
QModelIndex idx = GetIndex(object, args[5]); QPoint pt;
QRect r = object->visualRect(idx); QHeaderView* header = qobject_cast<QHeaderView*>(object);
QPoint pt = r.topLeft() + QPoint(x,y); if(header)
{
int idx = args[5].toInt();
if(header->orientation() == Qt::Horizontal)
{
pt = QPoint(header->sectionPosition(idx), 4);
}
else
{
pt = QPoint(4, header->sectionPosition(idx));
}
}
else
{
QModelIndex idx = GetIndex(object, args[5]);
QRect r = object->visualRect(idx);
pt = r.topLeft() + QPoint(x,y);
}
QEvent::Type type = QEvent::MouseButtonPress; QEvent::Type type = QEvent::MouseButtonPress;
type = Command == "mouseMove" ? QEvent::MouseMove : type; type = Command == "mouseMove" ? QEvent::MouseMove : type;
type = Command == "mouseRelease" ? QEvent::MouseButtonRelease : type; type = Command == "mouseRelease" ? QEvent::MouseButtonRelease : type;
......
...@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqAbstractItemViewEventTranslator.h" #include "pqAbstractItemViewEventTranslator.h"
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QHeaderView>
#include <QEvent> #include <QEvent>
#include <QKeyEvent> #include <QKeyEvent>
...@@ -95,10 +96,22 @@ bool pqAbstractItemViewEventTranslator::translateEvent(QObject* Object, QEvent* ...@@ -95,10 +96,22 @@ bool pqAbstractItemViewEventTranslator::translateEvent(QObject* Object, QEvent*
{ {
this->LastPos = mouseEvent->pos(); this->LastPos = mouseEvent->pos();
} }
QModelIndex idx = object->indexAt(mouseEvent->pos()); QString idxStr;
QString idxStr = toIndexStr(idx); QPoint relPt = QPoint(0,0);
QRect r = object->visualRect(idx); QHeaderView* header = qobject_cast<QHeaderView*>(object);
QPoint relPt = mouseEvent->pos() - r.topLeft(); if(header)
{
int idx = header->logicalIndexAt(mouseEvent->pos());
idxStr = QString("%1").arg(idx);
}
else
{
QModelIndex idx = object->indexAt(mouseEvent->pos());
idxStr = toIndexStr(idx);
QRect r = object->visualRect(idx);
relPt = mouseEvent->pos() - r.topLeft();
}
QString info = QString("%1,%2,%3,%4,%5,%6") QString info = QString("%1,%2,%3,%4,%5,%6")
.arg(mouseEvent->button()) .arg(mouseEvent->button())
.arg(mouseEvent->buttons()) .arg(mouseEvent->buttons())
......
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