diff --git a/declarativeimports/qtextracomponents/CMakeLists.txt b/declarativeimports/qtextracomponents/CMakeLists.txt index 008c96b62..3422ba011 100644 --- a/declarativeimports/qtextracomponents/CMakeLists.txt +++ b/declarativeimports/qtextracomponents/CMakeLists.txt @@ -8,8 +8,8 @@ set(qtextracomponents_SRCS qtextracomponentsplugin.cpp # qpixmapitem.cpp # qimageitem.cpp - qiconitem.cpp -# mouseeventlistener.cpp + qiconitem.cpp + mouseeventlistener.cpp columnproxymodel.cpp ) diff --git a/declarativeimports/qtextracomponents/mouseeventlistener.cpp b/declarativeimports/qtextracomponents/mouseeventlistener.cpp index d18a660cf..30ac7172f 100644 --- a/declarativeimports/qtextracomponents/mouseeventlistener.cpp +++ b/declarativeimports/qtextracomponents/mouseeventlistener.cpp @@ -43,7 +43,7 @@ MouseEventListener::MouseEventListener(QQuickItem *parent) qmlRegisterType(); qmlRegisterType(); - setFiltersChildEvents(true); + setFiltersChildMouseEvents(true); setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton|Qt::MidButton|Qt::XButton1|Qt::XButton2); } @@ -66,85 +66,85 @@ bool MouseEventListener::hoverEnabled() const return acceptHoverEvents(); } -void MouseEventListener::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - - m_containsMouse = true; - emit containsMouseChanged(true); -} - -void MouseEventListener::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - - m_containsMouse = false; - emit containsMouseChanged(false); -} +// void MouseEventListener::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +// { +// Q_UNUSED(event); +// +// m_containsMouse = true; +// emit containsMouseChanged(true); +// } +// +// void MouseEventListener::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +// { +// Q_UNUSED(event); +// +// m_containsMouse = false; +// emit containsMouseChanged(false); +// } bool MouseEventListener::containsMouse() const { return m_containsMouse; } -void MouseEventListener::mousePressEvent(QGraphicsSceneMouseEvent *me) -{ - if (m_lastEvent == me) { - return; - } - - //FIXME: when a popup window is visible: a click anywhere hides it: but the old qgraphicswidget will continue to think it's under the mouse - //doesn't seem to be any good way to properly reset this. - //this msolution will still caused a missed click after the popup is gone, but gets the situation unblocked. - if (!isUnderMouse()) { - me->ignore(); - return; - } - - KDeclarativeMouseEvent dme(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - m_pressAndHoldEvent = new KDeclarativeMouseEvent(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - emit pressed(&dme); - m_pressed = true; - - m_pressAndHoldTimer->start(PressAndHoldDelay); -} - -void MouseEventListener::mouseMoveEvent(QGraphicsSceneMouseEvent *me) -{ - if (m_lastEvent == me) { - return; - } - - KDeclarativeMouseEvent dme(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - emit positionChanged(&dme); -} - -void MouseEventListener::mouseReleaseEvent(QGraphicsSceneMouseEvent *me) -{ - if (m_lastEvent == me) { - return; - } - - KDeclarativeMouseEvent dme(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - m_pressed = false; - emit released(&dme); - - if (QPointF(me->pos() - me->buttonDownPos(me->button())).manhattanLength() <= QApplication::startDragDistance() && m_pressAndHoldTimer->isActive()) { - emit clicked(&dme); - m_pressAndHoldTimer->stop(); - } -} - -void MouseEventListener::wheelEvent(QGraphicsSceneWheelEvent *we) -{ - if (m_lastEvent == we) { - return; - } - - KDeclarativeWheelEvent dwe(we->pos(), we->screenPos(), we->delta(), we->buttons(), we->modifiers(), we->orientation()); - emit wheelMoved(&dwe); -} - +// void MouseEventListener::mousePressEvent(QGraphicsSceneMouseEvent *me) +// { +// if (m_lastEvent == me) { +// return; +// } +// +// //FIXME: when a popup window is visible: a click anywhere hides it: but the old qgraphicswidget will continue to think it's under the mouse +// //doesn't seem to be any good way to properly reset this. +// //this msolution will still caused a missed click after the popup is gone, but gets the situation unblocked. +// if (!isUnderMouse()) { +// me->ignore(); +// return; +// } +// +// KDeclarativeMouseEvent dme(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// m_pressAndHoldEvent = new KDeclarativeMouseEvent(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// emit pressed(&dme); +// m_pressed = true; +// +// m_pressAndHoldTimer->start(PressAndHoldDelay); +// } +// +// void MouseEventListener::mouseMoveEvent(QGraphicsSceneMouseEvent *me) +// { +// if (m_lastEvent == me) { +// return; +// } +// +// KDeclarativeMouseEvent dme(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// emit positionChanged(&dme); +// } +// +// void MouseEventListener::mouseReleaseEvent(QGraphicsSceneMouseEvent *me) +// { +// if (m_lastEvent == me) { +// return; +// } +// +// KDeclarativeMouseEvent dme(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// m_pressed = false; +// emit released(&dme); +// +// if (QPointF(me->pos() - me->buttonDownPos(me->button())).manhattanLength() <= QApplication::startDragDistance() && m_pressAndHoldTimer->isActive()) { +// emit clicked(&dme); +// m_pressAndHoldTimer->stop(); +// } +// } +// +// void MouseEventListener::wheelEvent(QGraphicsSceneWheelEvent *we) +// { +// if (m_lastEvent == we) { +// return; +// } +// +// KDeclarativeWheelEvent dwe(we->pos(), we->screenPos(), we->delta(), we->buttons(), we->modifiers(), we->orientation()); +// emit wheelMoved(&dwe); +// } +// void MouseEventListener::handlePressAndHold() { if (m_pressed) { @@ -154,63 +154,63 @@ void MouseEventListener::handlePressAndHold() } -bool MouseEventListener::sceneEventFilter(QGraphicsItem *item, QEvent *event) -{ - if (!isEnabled()) { - return false; - } - - m_lastEvent = event; - - switch (event->type()) { - case QEvent::GraphicsSceneMousePress: { - QGraphicsSceneMouseEvent *me = static_cast(event); - //the parent will receive events in its own coordinates - const QPointF myPos = item->mapToItem(this, me->pos()); - KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - m_pressAndHoldEvent = new KDeclarativeMouseEvent(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - //kDebug() << "pressed in sceneEventFilter"; - emit pressed(&dme); - m_pressed = true; - - m_pressAndHoldTimer->start(PressAndHoldDelay); - break; - } - case QEvent::GraphicsSceneMouseMove: { - QGraphicsSceneMouseEvent *me = static_cast(event); - const QPointF myPos = item->mapToItem(this, me->pos()); - KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - //kDebug() << "positionChanged..." << dme.x() << dme.y(); - m_pressAndHoldEvent = new KDeclarativeMouseEvent(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - emit positionChanged(&dme); - break; - } - case QEvent::GraphicsSceneMouseRelease: { - QGraphicsSceneMouseEvent *me = static_cast(event); - const QPointF myPos = item->mapToItem(this, me->pos()); - KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); - m_pressed = false; - - emit released(&dme); - - if (QPointF(me->pos() - me->buttonDownPos(me->button())).manhattanLength() <= QApplication::startDragDistance() && m_pressAndHoldTimer->isActive()) { - emit clicked(&dme); - m_pressAndHoldTimer->stop(); - } - break; - } - case QEvent::GraphicsSceneWheel: { - QGraphicsSceneWheelEvent *we = static_cast(event); - KDeclarativeWheelEvent dwe(we->pos(), we->screenPos(), we->delta(), we->buttons(), we->modifiers(), we->orientation()); - emit wheelMoved(&dwe); - break; - } - default: - break; - } - - return QQuickItem::sceneEventFilter(item, event); -} +// bool MouseEventListener::sceneEventFilter(QGraphicsItem *item, QEvent *event) +// { +// if (!isEnabled()) { +// return false; +// } +// +// m_lastEvent = event; +// +// switch (event->type()) { +// case QEvent::GraphicsSceneMousePress: { +// QGraphicsSceneMouseEvent *me = static_cast(event); +// //the parent will receive events in its own coordinates +// const QPointF myPos = item->mapToItem(this, me->pos()); +// KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// m_pressAndHoldEvent = new KDeclarativeMouseEvent(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// //kDebug() << "pressed in sceneEventFilter"; +// emit pressed(&dme); +// m_pressed = true; +// +// m_pressAndHoldTimer->start(PressAndHoldDelay); +// break; +// } +// case QEvent::GraphicsSceneMouseMove: { +// QGraphicsSceneMouseEvent *me = static_cast(event); +// const QPointF myPos = item->mapToItem(this, me->pos()); +// KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// //kDebug() << "positionChanged..." << dme.x() << dme.y(); +// m_pressAndHoldEvent = new KDeclarativeMouseEvent(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// emit positionChanged(&dme); +// break; +// } +// case QEvent::GraphicsSceneMouseRelease: { +// QGraphicsSceneMouseEvent *me = static_cast(event); +// const QPointF myPos = item->mapToItem(this, me->pos()); +// KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers()); +// m_pressed = false; +// +// emit released(&dme); +// +// if (QPointF(me->pos() - me->buttonDownPos(me->button())).manhattanLength() <= QApplication::startDragDistance() && m_pressAndHoldTimer->isActive()) { +// emit clicked(&dme); +// m_pressAndHoldTimer->stop(); +// } +// break; +// } +// case QEvent::GraphicsSceneWheel: { +// QGraphicsSceneWheelEvent *we = static_cast(event); +// KDeclarativeWheelEvent dwe(we->pos(), we->screenPos(), we->delta(), we->buttons(), we->modifiers(), we->orientation()); +// emit wheelMoved(&dwe); +// break; +// } +// default: +// break; +// } +// +// return QQuickItem::sceneEventFilter(item, event); +// } #include "mouseeventlistener.moc" diff --git a/declarativeimports/qtextracomponents/mouseeventlistener.h b/declarativeimports/qtextracomponents/mouseeventlistener.h index 9fc22aea1..1f32e4cf7 100644 --- a/declarativeimports/qtextracomponents/mouseeventlistener.h +++ b/declarativeimports/qtextracomponents/mouseeventlistener.h @@ -143,13 +143,13 @@ public: bool hoverEnabled() const; protected: - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void wheelEvent(QGraphicsSceneWheelEvent *event); - bool sceneEventFilter(QGraphicsItem *i, QEvent *e); +// void hoverEnterEvent(QGraphicsSceneHoverEvent *event); +// void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); +// void mousePressEvent(QGraphicsSceneMouseEvent *event); +// void mouseMoveEvent(QGraphicsSceneMouseEvent *event); +// void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); +// void wheelEvent(QGraphicsSceneWheelEvent *event); +// bool sceneEventFilter(QGraphicsItem *i, QEvent *e); Q_SIGNALS: void pressed(KDeclarativeMouseEvent *mouse); diff --git a/declarativeimports/qtextracomponents/qtextracomponentsplugin.cpp b/declarativeimports/qtextracomponents/qtextracomponentsplugin.cpp index cb9ce9f7a..e01545290 100644 --- a/declarativeimports/qtextracomponents/qtextracomponentsplugin.cpp +++ b/declarativeimports/qtextracomponents/qtextracomponentsplugin.cpp @@ -27,7 +27,7 @@ // #include "qpixmapitem.h" // #include "qimageitem.h" #include "qiconitem.h" -//#include "mouseeventlistener.h" +#include "mouseeventlistener.h" #include "columnproxymodel.h" // void QtExtraComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) @@ -42,7 +42,7 @@ void QtExtraComponentsPlugin::registerTypes(const char *uri) // qmlRegisterType(uri, 0, 1, "QPixmapItem"); // qmlRegisterType(uri, 0, 1, "QImageItem"); qmlRegisterType(uri, 0, 1, "QIconItem"); -// qmlRegisterType(uri, 0, 1, "MouseEventListener"); + qmlRegisterType(uri, 0, 1, "MouseEventListener"); qmlRegisterType(uri, 0, 1, "ColumnProxyModel"); qmlRegisterType();