summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-08-18 00:43:02 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-08-18 00:43:02 (GMT)
commit8f5e72298fc4b8a5838bee1291a2cc422750b6b8 (patch)
treef7a780127d327c879cb642b8a23c44f081c71556 /src
parent41335c52ef2844589030cddb4773c68cf38331af (diff)
downloadQt-8f5e72298fc4b8a5838bee1291a2cc422750b6b8.zip
Qt-8f5e72298fc4b8a5838bee1291a2cc422750b6b8.tar.gz
Qt-8f5e72298fc4b8a5838bee1291a2cc422750b6b8.tar.bz2
MouseRegion API changes following review.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp46
-rw-r--r--src/declarative/fx/qfxmouseregion.h26
-rw-r--r--src/declarative/fx/qfxmouseregion_p.h2
3 files changed, 59 insertions, 15 deletions
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index 42e024d..22d64cb 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -296,7 +296,10 @@ bool QFxMouseRegion::isEnabled() const
void QFxMouseRegion::setEnabled(bool a)
{
Q_D(QFxMouseRegion);
- d->absorb = a;
+ if (a != d->absorb) {
+ d->absorb = a;
+ emit enabledChanged();
+ }
}
void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
@@ -473,9 +476,9 @@ void QFxMouseRegion::timerEvent(QTimerEvent *event)
\warning This property is only partially implemented -- it is only valid when the mouse is pressed, and not for hover events.
*/
-bool QFxMouseRegion::hovered()
+bool QFxMouseRegion::hovered() const
{
- Q_D(QFxMouseRegion);
+ Q_D(const QFxMouseRegion);
return d->hovered;
}
@@ -483,9 +486,9 @@ bool QFxMouseRegion::hovered()
\qmlproperty bool MouseRegion::pressed
This property holds whether the mouse region is currently pressed.
*/
-bool QFxMouseRegion::pressed()
+bool QFxMouseRegion::pressed() const
{
- Q_D(QFxMouseRegion);
+ Q_D(const QFxMouseRegion);
return d->pressed;
}
@@ -499,6 +502,39 @@ void QFxMouseRegion::setHovered(bool h)
}
}
+/*!
+ \qmlproperty Qt::MouseButtons MouseRegion::acceptedButtons
+ This property holds the mouse buttons that the mouse region reacts to.
+
+ The available buttons are:
+ \list
+ \o Qt.LeftButton
+ \o Qt.RightButton
+ \o Qt.MiddleButton
+ \endlist
+
+ To accept more than one button the flags can be combined with the
+ "|" (or) operator:
+
+ \code
+ MouseRegion { acceptedButtons: Qt.LeftButton | Qt.RightButton }
+ \endcode
+
+ The default is to accept the Left button.
+*/
+Qt::MouseButtons QFxMouseRegion::acceptedButtons() const
+{
+ return acceptedMouseButtons();
+}
+
+void QFxMouseRegion::setAcceptedButtons(Qt::MouseButtons buttons)
+{
+ if (buttons != acceptedMouseButtons()) {
+ setAcceptedMouseButtons(buttons);
+ emit acceptedButtonsChanged();
+ }
+}
+
void QFxMouseRegion::setPressed(bool p)
{
Q_D(QFxMouseRegion);
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index 418434a..f2d22d3 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -55,11 +55,12 @@ class Q_DECLARATIVE_EXPORT QFxDrag : public QObject
Q_OBJECT
Q_PROPERTY(QFxItem *target READ target WRITE setTarget)
- Q_PROPERTY(QString axis READ axis WRITE setAxis)
- Q_PROPERTY(qreal xmin READ xmin WRITE setXmin)
- Q_PROPERTY(qreal xmax READ xmax WRITE setXmax)
- Q_PROPERTY(qreal ymin READ ymin WRITE setYmin)
- Q_PROPERTY(qreal ymax READ ymax WRITE setYmax)
+ Q_PROPERTY(QString axis READ axis WRITE setAxis) //### enum
+ Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin)
+ Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax)
+ Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin)
+ Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax)
+ //### consider drag and drop
public:
QFxDrag(QObject *parent=0);
~QFxDrag();
@@ -97,8 +98,10 @@ class Q_DECLARATIVE_EXPORT QFxMouseRegion : public QFxItem
Q_PROPERTY(qreal mouseY READ mouseY NOTIFY positionChanged)
Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
- Q_PROPERTY(QFxDrag *drag READ drag)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
+ Q_PROPERTY(QFxDrag *drag READ drag) //### add flicking to QFxDrag or add a QFxFlick ???
+ //### trackingEnabled?
public:
QFxMouseRegion(QFxItem *parent=0);
~QFxMouseRegion();
@@ -109,17 +112,22 @@ public:
bool isEnabled() const;
void setEnabled(bool);
- bool hovered();
- bool pressed();
+ bool hovered() const;
+ bool pressed() const;
void setHovered(bool);
void setPressed(bool);
+ Qt::MouseButtons acceptedButtons() const;
+ void setAcceptedButtons(Qt::MouseButtons buttons);
+
QFxDrag *drag();
Q_SIGNALS:
void hoveredChanged();
void pressedChanged();
+ void enabledChanged();
+ void acceptedButtonsChanged();
void positionChanged(QFxMouseEvent *mouse);
void pressed(QFxMouseEvent *mouse);
diff --git a/src/declarative/fx/qfxmouseregion_p.h b/src/declarative/fx/qfxmouseregion_p.h
index f03c334..1501a81 100644
--- a/src/declarative/fx/qfxmouseregion_p.h
+++ b/src/declarative/fx/qfxmouseregion_p.h
@@ -73,7 +73,7 @@ public:
void init()
{
Q_Q(QFxMouseRegion);
- q->setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
+ q->setAcceptedMouseButtons(Qt::LeftButton);
q->setAcceptHoverEvents(true);
}