diff options
Diffstat (limited to 'src/declarative')
14 files changed, 127 insertions, 124 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index e3aab65..a2afc1b 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,6 +1,8 @@ ============================================================================= The changes below are pre Qt 4.7.0 alpha +Renamed MouseRegion -> MouseArea + QmlView ------- The API of QmlView has been narrowed and its role as a convenience class diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri index db9c29e..e5343c6 100644 --- a/src/declarative/graphicsitems/graphicsitems.pri +++ b/src/declarative/graphicsitems/graphicsitems.pri @@ -28,8 +28,8 @@ HEADERS += \ $$PWD/qmlgraphicspositioners_p_p.h \ $$PWD/qmlgraphicsloader_p.h \ $$PWD/qmlgraphicsloader_p_p.h \ - $$PWD/qmlgraphicsmouseregion_p.h \ - $$PWD/qmlgraphicsmouseregion_p_p.h \ + $$PWD/qmlgraphicsmousearea_p.h \ + $$PWD/qmlgraphicsmousearea_p_p.h \ $$PWD/qmlgraphicspath_p.h \ $$PWD/qmlgraphicspath_p_p.h \ $$PWD/qmlgraphicspathview_p.h \ @@ -70,7 +70,7 @@ SOURCES += \ $$PWD/qmlgraphicsfocusscope.cpp \ $$PWD/qmlgraphicspositioners.cpp \ $$PWD/qmlgraphicsloader.cpp \ - $$PWD/qmlgraphicsmouseregion.cpp \ + $$PWD/qmlgraphicsmousearea.cpp \ $$PWD/qmlgraphicspath.cpp \ $$PWD/qmlgraphicspathview.cpp \ $$PWD/qmlgraphicsrectangle.cpp \ diff --git a/src/declarative/graphicsitems/qmlgraphicsevents.cpp b/src/declarative/graphicsitems/qmlgraphicsevents.cpp index 1f63218..efd7b4a 100644 --- a/src/declarative/graphicsitems/qmlgraphicsevents.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsevents.cpp @@ -183,7 +183,7 @@ Item { For example, to react to a Shift key + Left mouse button click: \qml -MouseRegion { +MouseArea { onClicked: { if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething(); } } \endqml diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp index be512fc..f5abc18 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp @@ -97,7 +97,7 @@ public: NumberAnimation { properties: "angle"; duration: 2000 } } - MouseRegion { + MouseArea { // change between default and 'back' states onClicked: flipable.state = (flipable.state == 'back' ? '' : 'back') anchors.fill: parent diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp index 66d62f0..9263f49 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp @@ -51,7 +51,7 @@ #include "qmlgraphicsanimatedimage_p.h" #include "qmlgraphicsborderimage_p.h" #include "qmlgraphicspositioners_p.h" -#include "qmlgraphicsmouseregion_p.h" +#include "qmlgraphicsmousearea_p.h" #include "qmlgraphicsflickable_p.h" #include "qmlgraphicsflickable_p_p.h" #include "qmlgraphicsflipable_p.h" @@ -64,7 +64,7 @@ #include "qmlgraphicslayoutitem_p.h" #include "qmlgraphicslistview_p.h" #include "qmlgraphicsloader_p.h" -#include "qmlgraphicsmouseregion_p.h" +#include "qmlgraphicsmousearea_p.h" #include "qmlgraphicsparticles_p.h" #include "qmlgraphicspath_p.h" #include "qmlgraphicspathview_p.h" @@ -112,7 +112,8 @@ void QmlGraphicsItemModule::defineModule() QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem); QML_REGISTER_TYPE(Qt,4,6,ListView,QmlGraphicsListView); QML_REGISTER_TYPE(Qt,4,6,Loader,QmlGraphicsLoader); - QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseRegion); + QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseArea); + QML_REGISTER_TYPE(Qt,4,6,MouseArea,QmlGraphicsMouseArea); QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect); QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion); QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity); diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp index 159ddc3..e4c7411 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp @@ -124,7 +124,7 @@ void QmlGraphicsLoaderPrivate::initResize() \code Loader { id: pageLoader } Rectangle { - MouseRegion { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" } + MouseArea { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" } } \endcode diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmousearea.cpp index 3470d37..cc07989 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsmousearea.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qmlgraphicsmouseregion_p.h" -#include "qmlgraphicsmouseregion_p_p.h" +#include "qmlgraphicsmousearea_p.h" +#include "qmlgraphicsmousearea_p_p.h" #include "qmlgraphicsevents_p_p.h" @@ -136,24 +136,24 @@ void QmlGraphicsDrag::setYmax(qreal m) emit maximumYChanged(); } -QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() +QmlGraphicsMouseAreaPrivate::~QmlGraphicsMouseAreaPrivate() { delete drag; } /*! - \qmlclass MouseRegion QmlGraphicsMouseRegion - \brief The MouseRegion item enables simple mouse handling. + \qmlclass MouseArea QmlGraphicsMouseArea + \brief The MouseArea item enables simple mouse handling. \inherits Item - A MouseRegion is typically used in conjunction with a visible item, - where the MouseRegion effectively 'proxies' mouse handling for that - item. For example, we can put a MouseRegion in a Rectangle that changes + A MouseArea is typically used in conjunction with a visible item, + where the MouseArea effectively 'proxies' mouse handling for that + item. For example, we can put a MouseArea in a Rectangle that changes the Rectangle color to red when clicked: \snippet doc/src/snippets/declarative/mouseregion.qml 0 - Many MouseRegion signals pass a \l {MouseEvent}{mouse} parameter that contains + Many MouseArea signals pass a \l {MouseEvent}{mouse} parameter that contains additional information about the mouse event, such as the position, button, and any key modifiers. @@ -163,13 +163,13 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() For basic key handling, see the \l {Keys}{Keys attached property}. - MouseRegion is an invisible item: it is never painted. + MouseArea is an invisible item: it is never painted. \sa MouseEvent */ /*! - \qmlsignal MouseRegion::onEntered() + \qmlsignal MouseArea::onEntered() This handler is called when the mouse enters the mouse region. @@ -181,7 +181,7 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() */ /*! - \qmlsignal MouseRegion::onExited() + \qmlsignal MouseArea::onExited() This handler is called when the mouse exists the mouse region. @@ -193,7 +193,7 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() */ /*! - \qmlsignal MouseRegion::onPositionChanged(MouseEvent mouse) + \qmlsignal MouseArea::onPositionChanged(MouseEvent mouse) This handler is called when the mouse position changes. @@ -208,10 +208,10 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() */ /*! - \qmlsignal MouseRegion::onClicked(mouse) + \qmlsignal MouseArea::onClicked(mouse) This handler is called when there is a click. A click is defined as a press followed by a release, - both inside the MouseRegion (pressing, moving outside the MouseRegion, and then moving back inside and + both inside the MouseArea (pressing, moving outside the MouseArea, and then moving back inside and releasing is also considered a click). The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y @@ -221,21 +221,21 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() */ /*! - \qmlsignal MouseRegion::onPressed(mouse) + \qmlsignal MouseArea::onPressed(mouse) This handler is called when there is a press. The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y position and which button was pressed. - The \e accepted property of the MouseEvent parameter determines whether this MouseRegion + The \e accepted property of the MouseEvent parameter determines whether this MouseArea will handle the press and all future mouse events until release. The default is to accept - the event and not allow other MouseRegions beneath this one to handle the event. If \e accepted - is set to false, no further events will be sent to this MouseRegion until the button is next + the event and not allow other MouseArea beneath this one to handle the event. If \e accepted + is set to false, no further events will be sent to this MouseArea until the button is next pressed. */ /*! - \qmlsignal MouseRegion::onReleased(mouse) + \qmlsignal MouseArea::onReleased(mouse) This handler is called when there is a release. The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y @@ -245,7 +245,7 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() */ /*! - \qmlsignal MouseRegion::onPressAndHold(mouse) + \qmlsignal MouseArea::onPressAndHold(mouse) This handler is called when there is a long press (currently 800ms). The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y @@ -255,7 +255,7 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() */ /*! - \qmlsignal MouseRegion::onDoubleClicked(mouse) + \qmlsignal MouseArea::onDoubleClicked(mouse) This handler is called when there is a double-click (a press followed by a release followed by a press). The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y @@ -266,30 +266,30 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() /*! \internal - \class QmlGraphicsMouseRegion - \brief The QmlGraphicsMouseRegion class provides a simple mouse handling abstraction for use within Qml. + \class QmlGraphicsMouseArea + \brief The QmlGraphicsMouseArea class provides a simple mouse handling abstraction for use within Qml. \ingroup group_coreitems - All QmlGraphicsItem derived classes can do mouse handling but the QmlGraphicsMouseRegion class exposes mouse + All QmlGraphicsItem derived classes can do mouse handling but the QmlGraphicsMouseArea class exposes mouse handling data as properties and tracks flicking and dragging of the mouse. - A QmlGraphicsMouseRegion object can be instantiated in Qml using the tag \l MouseRegion. + A QmlGraphicsMouseArea object can be instantiated in Qml using the tag \l MouseArea. */ -QmlGraphicsMouseRegion::QmlGraphicsMouseRegion(QmlGraphicsItem *parent) - : QmlGraphicsItem(*(new QmlGraphicsMouseRegionPrivate), parent) +QmlGraphicsMouseArea::QmlGraphicsMouseArea(QmlGraphicsItem *parent) + : QmlGraphicsItem(*(new QmlGraphicsMouseAreaPrivate), parent) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); d->init(); } -QmlGraphicsMouseRegion::~QmlGraphicsMouseRegion() +QmlGraphicsMouseArea::~QmlGraphicsMouseArea() { } /*! - \qmlproperty real MouseRegion::mouseX - \qmlproperty real MouseRegion::mouseY + \qmlproperty real MouseArea::mouseX + \qmlproperty real MouseArea::mouseY These properties hold the coordinates of the mouse. If the hoverEnabled property is false then these properties will only be valid @@ -298,44 +298,44 @@ QmlGraphicsMouseRegion::~QmlGraphicsMouseRegion() If hoverEnabled is true then these properties will be valid: \list - \i when no button is pressed, but the mouse is within the MouseRegion (containsMouse is true). + \i when no button is pressed, but the mouse is within the MouseArea (containsMouse is true). \i if a button is pressed and held, even if it has since moved out of the region. \endlist - The coordinates are relative to the MouseRegion. + The coordinates are relative to the MouseArea. */ -qreal QmlGraphicsMouseRegion::mouseX() const +qreal QmlGraphicsMouseArea::mouseX() const { - Q_D(const QmlGraphicsMouseRegion); + Q_D(const QmlGraphicsMouseArea); return d->lastPos.x(); } -qreal QmlGraphicsMouseRegion::mouseY() const +qreal QmlGraphicsMouseArea::mouseY() const { - Q_D(const QmlGraphicsMouseRegion); + Q_D(const QmlGraphicsMouseArea); return d->lastPos.y(); } /*! - \qmlproperty bool MouseRegion::enabled + \qmlproperty bool MouseArea::enabled This property holds whether the item accepts mouse events. */ -bool QmlGraphicsMouseRegion::isEnabled() const +bool QmlGraphicsMouseArea::isEnabled() const { - Q_D(const QmlGraphicsMouseRegion); + Q_D(const QmlGraphicsMouseArea); return d->absorb; } -void QmlGraphicsMouseRegion::setEnabled(bool a) +void QmlGraphicsMouseArea::setEnabled(bool a) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (a != d->absorb) { d->absorb = a; emit enabledChanged(); } } /*! - \qmlproperty MouseButtons MouseRegion::pressedButtons + \qmlproperty MouseButtons MouseArea::pressedButtons This property holds the mouse buttons currently pressed. It contains a bitwise combination of: @@ -351,7 +351,7 @@ void QmlGraphicsMouseRegion::setEnabled(bool a) text: mr.pressedButtons & Qt.RightButton ? "right" : "" horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - MouseRegion { + MouseArea { id: mr acceptedButtons: Qt.LeftButton | Qt.RightButton anchors.fill: parent @@ -361,15 +361,15 @@ void QmlGraphicsMouseRegion::setEnabled(bool a) \sa acceptedButtons */ -Qt::MouseButtons QmlGraphicsMouseRegion::pressedButtons() const +Qt::MouseButtons QmlGraphicsMouseArea::pressedButtons() const { - Q_D(const QmlGraphicsMouseRegion); + Q_D(const QmlGraphicsMouseArea); return d->lastButtons; } -void QmlGraphicsMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event) +void QmlGraphicsMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); d->moved = false; if (!d->absorb) QmlGraphicsItem::mousePressEvent(event); @@ -392,9 +392,9 @@ void QmlGraphicsMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event) } } -void QmlGraphicsMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QmlGraphicsMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (!d->absorb) { QmlGraphicsItem::mouseMoveEvent(event); return; @@ -462,9 +462,9 @@ void QmlGraphicsMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } -void QmlGraphicsMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QmlGraphicsMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (!d->absorb) { QmlGraphicsItem::mouseReleaseEvent(event); } else { @@ -477,9 +477,9 @@ void QmlGraphicsMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } } -void QmlGraphicsMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) +void QmlGraphicsMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (!d->absorb) { QmlGraphicsItem::mouseDoubleClickEvent(event); } else { @@ -493,18 +493,18 @@ void QmlGraphicsMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *eve } } -void QmlGraphicsMouseRegion::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +void QmlGraphicsMouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (!d->absorb) QmlGraphicsItem::hoverEnterEvent(event); else setHovered(true); } -void QmlGraphicsMouseRegion::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +void QmlGraphicsMouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (!d->absorb) { QmlGraphicsItem::hoverEnterEvent(event); } else { @@ -514,20 +514,20 @@ void QmlGraphicsMouseRegion::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } } -void QmlGraphicsMouseRegion::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +void QmlGraphicsMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (!d->absorb) QmlGraphicsItem::hoverLeaveEvent(event); else setHovered(false); } -bool QmlGraphicsMouseRegion::sceneEvent(QEvent *event) +bool QmlGraphicsMouseArea::sceneEvent(QEvent *event) { bool rv = QmlGraphicsItem::sceneEvent(event); if (event->type() == QEvent::UngrabMouse) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (d->pressed) { // if our mouse grab has been removed (probably by Flickable), fix our // state @@ -540,9 +540,9 @@ bool QmlGraphicsMouseRegion::sceneEvent(QEvent *event) return rv; } -void QmlGraphicsMouseRegion::timerEvent(QTimerEvent *event) +void QmlGraphicsMouseArea::timerEvent(QTimerEvent *event) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (event->timerId() == d->pressAndHoldTimer.timerId()) { d->pressAndHoldTimer.stop(); if (d->pressed && d->dragged == false && d->hovered == true) { @@ -554,7 +554,7 @@ void QmlGraphicsMouseRegion::timerEvent(QTimerEvent *event) } /*! - \qmlproperty bool MouseRegion::hoverEnabled + \qmlproperty bool MouseArea::hoverEnabled This property holds whether hover events are handled. By default, mouse events are only handled in response to a button event, or when a button is @@ -565,31 +565,31 @@ void QmlGraphicsMouseRegion::timerEvent(QTimerEvent *event) */ /*! - \qmlproperty bool MouseRegion::containsMouse + \qmlproperty bool MouseArea::containsMouse This property holds whether the mouse is currently inside the mouse region. \warning This property is not updated if the region moves under the mouse: \e containsMouse will not change. In addition, if hoverEnabled is false, containsMouse will only be valid when the mouse is pressed. */ -bool QmlGraphicsMouseRegion::hovered() const +bool QmlGraphicsMouseArea::hovered() const { - Q_D(const QmlGraphicsMouseRegion); + Q_D(const QmlGraphicsMouseArea); return d->hovered; } /*! - \qmlproperty bool MouseRegion::pressed + \qmlproperty bool MouseArea::pressed This property holds whether the mouse region is currently pressed. */ -bool QmlGraphicsMouseRegion::pressed() const +bool QmlGraphicsMouseArea::pressed() const { - Q_D(const QmlGraphicsMouseRegion); + Q_D(const QmlGraphicsMouseArea); return d->pressed; } -void QmlGraphicsMouseRegion::setHovered(bool h) +void QmlGraphicsMouseArea::setHovered(bool h) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (d->hovered != h) { d->hovered = h; emit hoveredChanged(); @@ -598,7 +598,7 @@ void QmlGraphicsMouseRegion::setHovered(bool h) } /*! - \qmlproperty Qt::MouseButtons MouseRegion::acceptedButtons + \qmlproperty Qt::MouseButtons MouseArea::acceptedButtons This property holds the mouse buttons that the mouse region reacts to. The available buttons are: @@ -612,17 +612,17 @@ void QmlGraphicsMouseRegion::setHovered(bool h) "|" (or) operator: \code - MouseRegion { acceptedButtons: Qt.LeftButton | Qt.RightButton } + MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton } \endcode The default is to accept the Left button. */ -Qt::MouseButtons QmlGraphicsMouseRegion::acceptedButtons() const +Qt::MouseButtons QmlGraphicsMouseArea::acceptedButtons() const { return acceptedMouseButtons(); } -void QmlGraphicsMouseRegion::setAcceptedButtons(Qt::MouseButtons buttons) +void QmlGraphicsMouseArea::setAcceptedButtons(Qt::MouseButtons buttons) { if (buttons != acceptedMouseButtons()) { setAcceptedMouseButtons(buttons); @@ -630,9 +630,9 @@ void QmlGraphicsMouseRegion::setAcceptedButtons(Qt::MouseButtons buttons) } } -bool QmlGraphicsMouseRegion::setPressed(bool p) +bool QmlGraphicsMouseArea::setPressed(bool p) { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); bool isclick = d->pressed == true && p == false && d->dragged == false && d->hovered == true; if (d->pressed != p) { @@ -653,21 +653,21 @@ bool QmlGraphicsMouseRegion::setPressed(bool p) return false; } -QmlGraphicsDrag *QmlGraphicsMouseRegion::drag() +QmlGraphicsDrag *QmlGraphicsMouseArea::drag() { - Q_D(QmlGraphicsMouseRegion); + Q_D(QmlGraphicsMouseArea); if (!d->drag) d->drag = new QmlGraphicsDrag; return d->drag; } /*! - \qmlproperty Item MouseRegion::drag.target - \qmlproperty Axis MouseRegion::drag.axis - \qmlproperty real MouseRegion::drag.minimumX - \qmlproperty real MouseRegion::drag.maximumX - \qmlproperty real MouseRegion::drag.minimumY - \qmlproperty real MouseRegion::drag.maximumY + \qmlproperty Item MouseArea::drag.target + \qmlproperty Axis MouseArea::drag.axis + \qmlproperty real MouseArea::drag.minimumX + \qmlproperty real MouseArea::drag.maximumX + \qmlproperty real MouseArea::drag.minimumY + \qmlproperty real MouseArea::drag.maximumY drag provides a convenient way to make an item draggable. diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h b/src/declarative/graphicsitems/qmlgraphicsmousearea_p.h index cccf90c..2e2f8c9 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsmousearea_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLGRAPHICSMOUSEREGION_H -#define QMLGRAPHICSMOUSEREGION_H +#ifndef QMLGRAPHICSMOUSEAREA_H +#define QMLGRAPHICSMOUSEAREA_H #include "qmlgraphicsitem.h" @@ -102,8 +102,8 @@ private: }; class QmlGraphicsMouseEvent; -class QmlGraphicsMouseRegionPrivate; -class Q_DECLARATIVE_EXPORT QmlGraphicsMouseRegion : public QmlGraphicsItem +class QmlGraphicsMouseAreaPrivate; +class Q_DECLARATIVE_EXPORT QmlGraphicsMouseArea : public QmlGraphicsItem { Q_OBJECT @@ -118,8 +118,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsMouseRegion : public QmlGraphicsItem Q_PROPERTY(QmlGraphicsDrag *drag READ drag CONSTANT) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ??? public: - QmlGraphicsMouseRegion(QmlGraphicsItem *parent=0); - ~QmlGraphicsMouseRegion(); + QmlGraphicsMouseArea(QmlGraphicsItem *parent=0); + ~QmlGraphicsMouseArea(); qreal mouseX() const; qreal mouseY() const; @@ -171,15 +171,15 @@ private: void handleRelease(); private: - Q_DISABLE_COPY(QmlGraphicsMouseRegion) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsMouseRegion) + Q_DISABLE_COPY(QmlGraphicsMouseArea) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsMouseArea) }; QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsDrag) -QML_DECLARE_TYPE(QmlGraphicsMouseRegion) +QML_DECLARE_TYPE(QmlGraphicsMouseArea) QT_END_HEADER -#endif // QMLGRAPHICSMOUSEREGION_H +#endif // QMLGRAPHICSMOUSEAREA_H diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h b/src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h index be27176..fadb430 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h @@ -61,21 +61,21 @@ QT_BEGIN_NAMESPACE -class QmlGraphicsMouseRegionPrivate : public QmlGraphicsItemPrivate +class QmlGraphicsMouseAreaPrivate : public QmlGraphicsItemPrivate { - Q_DECLARE_PUBLIC(QmlGraphicsMouseRegion) + Q_DECLARE_PUBLIC(QmlGraphicsMouseArea) public: - QmlGraphicsMouseRegionPrivate() + QmlGraphicsMouseAreaPrivate() : absorb(true), hovered(false), pressed(false), longPress(false), drag(0) { } - ~QmlGraphicsMouseRegionPrivate(); + ~QmlGraphicsMouseAreaPrivate(); void init() { - Q_Q(QmlGraphicsMouseRegion); + Q_Q(QmlGraphicsMouseArea); q->setAcceptedMouseButtons(Qt::LeftButton); } @@ -87,7 +87,7 @@ public: } bool isConnected(const char *signal) { - Q_Q(QmlGraphicsMouseRegion); + Q_Q(QmlGraphicsMouseArea); int idx = QObjectPrivate::get(q)->signalIndex(signal); return QObjectPrivate::get(q)->isSignalConnected(idx); } diff --git a/src/declarative/qml/qmlscript.cpp b/src/declarative/qml/qmlscript.cpp index c0320cd..ef142a5 100644 --- a/src/declarative/qml/qmlscript.cpp +++ b/src/declarative/qml/qmlscript.cpp @@ -58,7 +58,7 @@ console.log(otherinterestingitem.property); } } - MouseRegion { onClicked: debugMyComponent() } + MouseArea { onClicked: debugMyComponent() } \endqml \note While it is possible to use any JavaScript code within a Script element, diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 82bd33e..d7ddfce 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -176,7 +176,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj The \c running property can be set to declaratively control whether or not an animation is running. The following example will animate a rectangle - whenever the \l MouseRegion is pressed. + whenever the \l MouseArea is pressed. \code Rectangle { @@ -185,7 +185,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj running: myMouse.pressed from: 0; to: 100 } - MouseRegion { id: myMouse } + MouseArea { id: myMouse } } \endcode @@ -1794,7 +1794,7 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) Fade out \c theObject when clicked: \qml - MouseRegion { + MouseArea { anchors.fill: theObject onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 } } @@ -2214,7 +2214,7 @@ void QmlPropertyAnimation::setProperties(const QString &prop) color: Qt.rgba(0,0,1) //need to explicitly specify target and property NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 } - MouseRegion { + MouseArea { anchors.fill: parent onClicked: theAnim.start() } diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp index 9bec3bb..3d04aaf 100644 --- a/src/declarative/util/qmlconnection.cpp +++ b/src/declarative/util/qmlconnection.cpp @@ -72,7 +72,7 @@ public: "on<Signal>" handler that reacts when a signal is received, like this: \qml - MouseRegion { + MouseArea { onClicked: { foo(x+123,y+456) } } \endqml @@ -94,7 +94,7 @@ public: like this: \qml - MouseRegion { + MouseArea { Connection { signal: "clicked(x,y)" script: { foo(x+123,y+456) } @@ -106,7 +106,7 @@ public: the sender of the signal, and the script is the default attribute: \qml - MouseRegion { + MouseArea { id: mr } ... diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index af41dfd..8fda3ae 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -188,7 +188,7 @@ static void dump(ModelNode *node, int ind); Text { text: '$'+cost; anchors.right: parent.right } // Double the price when clicked. - MouseRegion { + MouseArea { anchors.fill: parent onClicked: fruitModel.set(index, "cost", cost*2) } diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index 84f1e9a..068cb4d 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE } } - MouseRegion { anchors.fill: parent; onClicked: myText.state = 'myState' } + MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' } } \endqml @@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE \qml PropertyChanges { - target: myMouseRegion + target: myMouseArea onClicked: doSomethingDifferent() } \endqml |