diff options
-rw-r--r-- | doc/src/declarative/elements.qdoc | 1 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 27 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepackage.cpp | 27 |
3 files changed, 55 insertions, 0 deletions
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 470a78c..da96b8e 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -89,6 +89,7 @@ The following table lists the QML elements provided by the Qt Declarative module \o \l ListModel, \l ListElement \o \l VisualItemModel \o \l VisualDataModel +\o \l Package \o \l XmlListModel and XmlRole \o \l DateTimeFormatter \o \l NumberFormatter diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 8114f9b..2402648 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -929,6 +929,33 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q return stat; } +/*! + \qmlproperty object VisualDataModel::parts + + The \a parts property selects a VisualDataModel which creates + delegates from the part named. This is used in conjunction with + the Package element. + + For example, the code below selects a model which creates + delegates named \e list from a Package: + + \code + VisualDataModel { + id: visualModel + delegate: Package { + Item { Package.name: "list" } + } + model: myModel + } + + ListView { + width: 200; height:200 + model: visualModel.parts.list + } + \endcode + + \sa Package +*/ QObject *QDeclarativeVisualDataModel::parts() { Q_D(QDeclarativeVisualDataModel); diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp index 356d7a1..34ae466 100644 --- a/src/declarative/util/qdeclarativepackage.cpp +++ b/src/declarative/util/qdeclarativepackage.cpp @@ -46,6 +46,33 @@ QT_BEGIN_NAMESPACE +/*! + \qmlclass Package QDeclarativePackage + \brief Package provides a collection of named items + + The Package class is currently used in conjunction with + VisualDataModel to enable delegates with a shared context + to be provided to multiple views. + + Any item within a Package may be assigned a name via the + \e {Package.name} attached property. + + The example below creates a Package containing two named items; + \e list and \e grid. The third element in the package is parented to whichever + delegate it should appear in. This allows an item to move + between views. + + \snippet examples/declarative/package/Delegate.qml 0 + + These named items are used as the delegates by the two views who + reference the special VisualDataModel.parts property to select + a model which provides the chosen delegate. + + \snippet examples/declarative/package/view.qml 0 + +*/ + + class QDeclarativePackagePrivate : public QObjectPrivate { public: |