diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-08-05 23:23:43 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-08-05 23:23:43 (GMT) |
commit | d018b73c2a79e79f50a988c848f040d263d0e75b (patch) | |
tree | f87dc897b293ccc653e3fae8202dd7605dd73640 /src/declarative/fx | |
parent | 304238b586b75ee73d46d2de4ffdb0ed40218b70 (diff) | |
parent | c0525981ffb291fc281a2daaafa290d4ff5917f4 (diff) | |
download | Qt-d018b73c2a79e79f50a988c848f040d263d0e75b.zip Qt-d018b73c2a79e79f50a988c848f040d263d0e75b.tar.gz Qt-d018b73c2a79e79f50a988c848f040d263d0e75b.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx')
-rw-r--r-- | src/declarative/fx/qfxanchors.cpp | 3 | ||||
-rw-r--r-- | src/declarative/fx/qfxanchors.h | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxanchors_p.h | 25 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 34 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.h | 31 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem_p.h | 1 | ||||
-rw-r--r-- | src/declarative/fx/qfxvisualitemmodel.cpp | 51 | ||||
-rw-r--r-- | src/declarative/fx/qfxvisualitemmodel.h | 3 |
8 files changed, 118 insertions, 32 deletions
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 1595f57..b60990c 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -969,3 +969,6 @@ bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const } QT_END_NAMESPACE + +#include "moc_qfxanchors.cpp" + diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 70217d6..3dd64c7 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QFxAnchorsPrivate; +class QFxAnchorLine; class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject { Q_OBJECT @@ -172,7 +173,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QFxAnchors::UsedAnchors) QT_END_NAMESPACE -Q_DECLARE_METATYPE(QFxAnchorLine) QML_DECLARE_TYPE(QFxAnchors) QT_END_HEADER diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index ca42966..9b1bc18 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -58,6 +58,31 @@ QT_BEGIN_NAMESPACE +class QFxAnchorLine +{ +public: + QFxAnchorLine() : item(0), anchorLine(Invalid) + { + } + + enum AnchorLine { + Invalid = 0x0, + Left = 0x01, + Right = 0x02, + Top = 0x04, + Bottom = 0x08, + HCenter = 0x10, + VCenter = 0x20, + Baseline = 0x40, + Horizontal_Mask = Left | Right | HCenter, + Vertical_Mask = Top | Bottom | VCenter | Baseline + }; + + QFxItem *item; + AnchorLine anchorLine; +}; +Q_DECLARE_METATYPE(QFxAnchorLine) + class QFxAnchorsPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QFxAnchors) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 02466d0..b36e994 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -53,7 +53,6 @@ #include <QtDeclarative/qmlengine.h> #include "qmlstate.h" #include "qlistmodelinterface.h" -#include "qfxanchors_p.h" #include "qfxview.h" #include "qmlstategroup.h" @@ -362,6 +361,14 @@ void QFxContents::setItem(QFxItem *item) \sa QFxItem::setFocus() */ +static inline void qfxitem_registerAnchorLine() { + static bool registered = false; + if (!registered) { + qRegisterMetaType<QFxAnchorLine>("QFxAnchorLine"); + registered = true; + } +} + /*! \fn QFxItem::QFxItem(QFxItem *parent) @@ -371,6 +378,7 @@ QFxItem::QFxItem(QFxItem* parent) : QGraphicsObject(*(new QFxItemPrivate), parent, 0) { Q_D(QFxItem); + qfxitem_registerAnchorLine(); d->init(parent); } @@ -380,6 +388,7 @@ QFxItem::QFxItem(QFxItemPrivate &dd, QFxItem *parent) : QGraphicsObject(dd, parent, 0) { Q_D(QFxItem); + qfxitem_registerAnchorLine(); d->init(parent); } @@ -1280,8 +1289,10 @@ void QFxItem::setBaselineOffset(qreal offset) */ /*! - Returns a value indicating whether the mouse should - remain with this item. + Returns a value indicating whether mouse input should + remain with this item exclusively. + + \sa setKeepMouseGrab */ bool QFxItem::keepMouseGrab() const { @@ -1292,6 +1303,20 @@ bool QFxItem::keepMouseGrab() const /*! The flag indicating whether the mouse should remain with this item is set to \a keep. + + This is useful for items that wish to grab and keep mouse + interaction following a predefined gesture. For example, + an item that is interested in horizontal mouse movement + may set keepMouseGrab to true once a threshold has been + exceeded. Once keepMouseGrab has been set to true, filtering + items will not react to mouse events. + + If the item does not indicate that it wishes to retain mouse grab, + a filtering item may steal the grab. For example, Flickable may attempt + to steal a mouse grab if it detects that the user has begun to + move the viewport. + + \sa keepMouseGrab */ void QFxItem::setKeepMouseGrab(bool keep) { @@ -1891,3 +1916,6 @@ QDebug operator<<(QDebug debug, QFxItem *item) } QT_END_NAMESPACE + +#include "moc_qfxitem.cpp" + diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index c3607ef..3ba00cb 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -89,31 +89,8 @@ private: qreal m_width; }; -class QFxAnchorLine -{ -public: - QFxAnchorLine() : item(0), anchorLine(Invalid) - { - } - - enum AnchorLine { - Invalid = 0x0, - Left = 0x01, - Right = 0x02, - Top = 0x04, - Bottom = 0x08, - HCenter = 0x10, - VCenter = 0x20, - Baseline = 0x40, - Horizontal_Mask = Left | Right | HCenter, - Vertical_Mask = Top | Bottom | VCenter | Baseline - }; - - QFxItem *item; - AnchorLine anchorLine; -}; - class QmlState; +class QFxAnchorLine; class QmlTransition; class QFxKeyEvent; class QFxAnchors; @@ -186,9 +163,6 @@ public: QmlList<QGraphicsTransform *> *transform(); - bool keepMouseGrab() const; - void setKeepMouseGrab(bool); - qreal width() const; void setWidth(qreal); @@ -208,6 +182,9 @@ public: void setFocus(bool); bool hasActiveFocus() const; + bool keepMouseGrab() const; + void setKeepMouseGrab(bool); + Q_SIGNALS: void xChanged(); void yChanged(); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index b11b812..08d173d 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -57,6 +57,7 @@ #include <QtDeclarative/qmlstate.h> #include <QtDeclarative/qfxanchors.h> #include <private/qmlnullablevalue_p.h> +#include <private/qfxanchors_p.h> #include <QtDeclarative/qml.h> #include <QtDeclarative/qmlcontext.h> #include <QtCore/qlist.h> diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index 6516545..9694b3a 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -58,6 +58,47 @@ QML_DECLARE_TYPE(QListModelInterface) QT_BEGIN_NAMESPACE +class QFxVisualItemModelAttached : public QObject +{ + Q_OBJECT + +public: + QFxVisualItemModelAttached(QObject *parent) + : QObject(parent), m_index(0) {} + ~QFxVisualItemModelAttached() { + attachedProperties.remove(parent()); + } + + Q_PROPERTY(int index READ index NOTIFY indexChanged) + int index() const { return m_index; } + void setIndex(int idx) { + if (m_index != idx) { + m_index = idx; + emit indexChanged(); + } + } + + static QFxVisualItemModelAttached *properties(QObject *obj) { + QFxVisualItemModelAttached *rv = attachedProperties.value(obj); + if (!rv) { + rv = new QFxVisualItemModelAttached(obj); + attachedProperties.insert(obj, rv); + } + return rv; + } + +signals: + void indexChanged(); + +public: + int m_index; + + static QHash<QObject*, QFxVisualItemModelAttached*> attachedProperties; +}; + +QHash<QObject*, QFxVisualItemModelAttached*> QFxVisualItemModelAttached::attachedProperties; + + class QFxVisualItemModelPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QFxVisualItemModel); @@ -75,6 +116,8 @@ public: void itemAppended() { Q_Q(QFxVisualItemModel); + QFxVisualItemModelAttached *attached = QFxVisualItemModelAttached::properties(children.last()); + attached->setIndex(children.count()-1); emit q->itemsInserted(children.count()-1, 1); emit q->countChanged(); } @@ -88,7 +131,8 @@ public: \brief The VisualItemModel allows items to be provided to a view. The children of the VisualItemModel are provided in a model which - can be used in a view. + can be used in a view. An item can determine its index within the + model via the VisualItemModel.index attached property. The example below places three colored rectangles in a ListView. \code @@ -177,6 +221,11 @@ void QFxVisualItemModelPrivate::ItemList::append(QFxItem *item) model->itemAppended(); } +QFxVisualItemModelAttached *QFxVisualItemModel::qmlAttachedProperties(QObject *obj) +{ + return QFxVisualItemModelAttached::properties(obj); +} + class QFxVisualDataModelParts; class QFxVisualDataModelData; diff --git a/src/declarative/fx/qfxvisualitemmodel.h b/src/declarative/fx/qfxvisualitemmodel.h index 6160068..6165746 100644 --- a/src/declarative/fx/qfxvisualitemmodel.h +++ b/src/declarative/fx/qfxvisualitemmodel.h @@ -101,6 +101,7 @@ private: Q_DISABLE_COPY(QFxVisualModel) }; +class QFxVisualItemModelAttached; class QFxVisualItemModelPrivate; class Q_DECLARATIVE_EXPORT QFxVisualItemModel : public QFxVisualModel { @@ -125,6 +126,8 @@ public: QmlList<QFxItem *> *children(); + static QFxVisualItemModelAttached *qmlAttachedProperties(QObject *obj); + private: Q_DISABLE_COPY(QFxVisualItemModel) }; |