Source

Target

Commits (4)
Showing with 112 additions and 86 deletions
...@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE ...@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\qmlmodule QtQml.Models 2 \qmlmodule QtQml.Models 2
\title Qt QML Model QML Types \title Qt QML Models QML Types
\ingroup qmlmodules \ingroup qmlmodules
\brief Provides QML types for data models \brief Provides QML types for data models
\since 5.1 \since 5.1
...@@ -60,7 +60,8 @@ QT_BEGIN_NAMESPACE ...@@ -60,7 +60,8 @@ QT_BEGIN_NAMESPACE
import QtQml.Models 2.1 import QtQml.Models 2.1
\endcode \endcode
Note that QtQml.Models module started at version 2.1 to match the version of the parent module. Note that QtQml.Models module started at version 2.1 to match the version
of the parent module, \l{Qt QML}.
*/ */
......
...@@ -32,9 +32,11 @@ tagfile = ../../../doc/qtqml/qtqml.tags ...@@ -32,9 +32,11 @@ tagfile = ../../../doc/qtqml/qtqml.tags
depends += qtcore qtxmlpatterns qtgui qtquick qtdoc depends += qtcore qtxmlpatterns qtgui qtquick qtdoc
headerdirs += .. headerdirs += .. \
../../imports/models
sourcedirs += .. sourcedirs += .. \
../../imports/models
exampledirs += ../../../examples/qml \ exampledirs += ../../../examples/qml \
../ \ ../ \
......
...@@ -58,8 +58,13 @@ follows: ...@@ -58,8 +58,13 @@ follows:
import QtQuick 2.0 import QtQuick 2.0
\endqml \endqml
See the \l{Qt Quick} module documentation for more information about the See the \l{Qt Quick} module documentation for more information about the \c
\c QtQuick namespace and what it provides to QML application developers. QtQuick namespace and what it provides to QML application developers.
The QML types for creating lists and models, such as \l ListModel and \l
ListElement, are moved to a submodule, \c QtQml.Models. The \l{Qt QML Models QML
Types}{Qt QML Models} page has more information.
The documentation for the types below applies equally to the types of the same The documentation for the types below applies equally to the types of the same
name provided by the \l{Qt Quick} module, as they are in fact identical. name provided by the \l{Qt Quick} module, as they are in fact identical.
......
...@@ -84,6 +84,19 @@ various QML object types: ...@@ -84,6 +84,19 @@ various QML object types:
\li \l Timer \li \l Timer
\endlist \endlist
\section2 Lists and Models
New in Qt 5.1, the model types are moved to a submodule, \c QtQml.Models. The
\l{Qt QML Models QML Types}{Qt QML Models} page has more information.
\list
\li \l DelegateModel
\li \l DelegateModelGroup
\li \l ListElement
\li \l ListModel
\li \l ObjectModel
\endlist
\section1 JavaScript Environment for QML Applications \section1 JavaScript Environment for QML Applications
JavaScript expressions allow QML code to contain application logic. Qt QML JavaScript expressions allow QML code to contain application logic. Qt QML
......
...@@ -39,13 +39,14 @@ a summary of the new changes: ...@@ -39,13 +39,14 @@ a summary of the new changes:
\li New properties for \l Qt.application: arguments, name, and version. \li New properties for \l Qt.application: arguments, name, and version.
\endlist \endlist
\section2 New Submodules \section2 New Submodule
The Qt QML Models is a new submodule in Qt 5.1 and provides several QML types The \l{Qt QML Models QML Types}{Qt QML Models} is a new submodule in Qt 5.1 and
for handling data with models and lists. provides several QML types for handling data with models and lists. These types
replace types such as \l VisualItem, \l VisualDataModel, and \l VisualDataGroup.
\list \list
\li \l{QtQml.Models}{Models} \li \l{Qt QML Models QML Types}{Models}
\endlist \endlist
The \l{What's New in Qt 5.1} has more information about the Qt 5.1 release. The \l{What's New in Qt 5.1} has more information about the Qt 5.1 release.
......
...@@ -121,15 +121,16 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent) ...@@ -121,15 +121,16 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent)
/*! /*!
\qmltype VisualDataModel \qmltype VisualDataModel
\instantiates QQmlDelegateModel \instantiates QQmlDelegateModel
\inqmlmodule QtQml 2 \inqmlmodule QtQuick 2
\ingroup qtquick-models \ingroup qtquick-models
\brief Encapsulates a model and delegate \brief Encapsulates a model and delegate
The VisualDataModel type encapsulates a model and the delegate that will The VisualDataModel type encapsulates a model and the delegate that will
be instantiated for items in a model. be instantiated for items in a model.
This type is provided by \c {QtQuick 2} for compatibility reasons. The same implementation This type is provided by the \l{Qt QML} module due to compatibility reasons.
is now primarily available as DelegateModel in the QtQml.Models module. The same implementation is now primarily available as DelegateModel in the
\l{Qt QML Models QML Types}{Qt QML Models} module.
\sa {QtQml.Models2::DelegateModel} \sa {QtQml.Models2::DelegateModel}
*/ */
...@@ -142,12 +143,6 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent) ...@@ -142,12 +143,6 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent)
The DelegateModel type encapsulates a model and the delegate that will The DelegateModel type encapsulates a model and the delegate that will
be instantiated for items in the model. be instantiated for items in the model.
This element is also available as DelegateModel in the \c QtQuick module. For full details,
see the \l DelegateModel documentation.
The DelegateModel type encapsulates a model and the delegate that will
be instantiated for items in the model.
It is usually not necessary to create a DelegateModel. It is usually not necessary to create a DelegateModel.
However, it can be useful for manipulating and accessing the \l modelIndex However, it can be useful for manipulating and accessing the \l modelIndex
when a QAbstractItemModel subclass is used as the when a QAbstractItemModel subclass is used as the
...@@ -158,6 +153,9 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent) ...@@ -158,6 +153,9 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent)
The example below illustrates using a DelegateModel with a ListView. The example below illustrates using a DelegateModel with a ListView.
\snippet delegatemodel/visualdatamodel.qml 0 \snippet delegatemodel/visualdatamodel.qml 0
\note This type is also available as \l VisualDataModel in the \l{Qt QML}
module due to compatibility reasons.
*/ */
QQmlDelegateModelPrivate::QQmlDelegateModelPrivate(QQmlContext *ctxt) QQmlDelegateModelPrivate::QQmlDelegateModelPrivate(QQmlContext *ctxt)
...@@ -2168,15 +2166,32 @@ void QQmlDelegateModelGroupPrivate::destroyingPackage(QQuickPackage *package) ...@@ -2168,15 +2166,32 @@ void QQmlDelegateModelGroupPrivate::destroyingPackage(QQuickPackage *package)
it->destroyingPackage(package); it->destroyingPackage(package);
} }
/*!
\qmltype VisualDataGroup
\instantiates QQmlDelegateModelGroup
\inqmlmodule QtQuick 2
\ingroup qtquick-models
\brief Encapsulates a filtered set of visual data items
The VisualDataGroup type provides a means to address the model data of a
model's delegate items, as well as sort and filter these delegate items.
This type is provided by the \l{Qt QML} module due to compatibility reasons.
The same implementation is now primarily available as \l DelegateModelGroup
in the \l{Qt QML Models QML Types}{Qt QML Models} module.
\sa {QtQml.Models2::DelegateModelGroup}
*/
/*! /*!
\qmltype DelegateModelGroup \qmltype DelegateModelGroup
\instantiates QQmlDelegateModelGroup \instantiates QQmlDelegateModelGroup
\inqmlmodule QtQml 2 \inqmlmodule QtQml.Models 2
\ingroup qtquick-models \ingroup qtquick-models
\brief Encapsulates a filtered set of visual data items \brief Encapsulates a filtered set of visual data items
The DelegateModelGroup type provides a means to address the model data of a DelegateModel's The DelegateModelGroup type provides a means to address the model data of a
delegate items, as well as sort and filter these delegate items. DelegateModel's delegate items, as well as sort and filter these delegate
items.
The initial set of instantiable delegate items in a DelegateModel is represented The initial set of instantiable delegate items in a DelegateModel is represented
by its \l {QtQml.Models2::DelegateModel::items}{items} group, which normally directly reflects by its \l {QtQml.Models2::DelegateModel::items}{items} group, which normally directly reflects
...@@ -2200,24 +2215,11 @@ void QQmlDelegateModelGroupPrivate::destroyingPackage(QQuickPackage *package) ...@@ -2200,24 +2215,11 @@ void QQmlDelegateModelGroupPrivate::destroyingPackage(QQuickPackage *package)
type or to cherry-pick specific items that should be instantiated irregardless of whether type or to cherry-pick specific items that should be instantiated irregardless of whether
they're currently within a view's visible area. they're currently within a view's visible area.
\sa {QML Dynamic View Ordering Tutorial} \note This type is also available as \l VisualDataGroup in the \l{Qt QML}
*/ module due to compatibility reasons.
/*!
\qmltype DelegateModelGroup
\instantiates QQmlDelegateModelGroup
\inqmlmodule QtQml.Models 2
\brief Encapsulates a filtered set of visual data items
The DelegateModelGroup type provides a means to address the model data of a DelegateModel's
delegate items, as well as sort and filter these delegate items.
This element is also available as DelegateModelGroup in the \c QtQuick module. For full details,
see the \l DelegateModelGroup documentation.
\sa {QtQuick::DelegateModelGroup} \sa {QML Dynamic View Ordering Tutorial}
*/ */
QQmlDelegateModelGroup::QQmlDelegateModelGroup(QObject *parent) QQmlDelegateModelGroup::QQmlDelegateModelGroup(QObject *parent)
: QObject(*new QQmlDelegateModelGroupPrivate, parent) : QObject(*new QQmlDelegateModelGroupPrivate, parent)
{ {
......
...@@ -1426,24 +1426,12 @@ QQmlListModelParser::ListInstruction *QQmlListModelParser::ListModelData::instru ...@@ -1426,24 +1426,12 @@ QQmlListModelParser::ListInstruction *QQmlListModelParser::ListModelData::instru
\qmltype ListModel \qmltype ListModel
\instantiates QQmlListModel \instantiates QQmlListModel
\inqmlmodule QtQml.Models 2 \inqmlmodule QtQml.Models 2
\brief Defines a free-form list data source
The ListModel is a simple container of ListElement definitions, each containing data roles.
The contents can be defined dynamically, or explicitly in QML.
This type is also available in the \c {QtQuick 2} import.
\sa {QtQml2::ListModel}{Full documentation for ListModel}
*/
/*!
\qmltype ListModel
\instantiates QQmlListModel
\inqmlmodule QtQml 2
\brief Defines a free-form list data source
\ingroup qtquick-models \ingroup qtquick-models
\brief Defines a free-form list data source
The ListModel is a simple container of ListElement definitions, each containing data roles. The ListModel is a simple container of ListElement definitions, each
The contents can be defined dynamically, or explicitly in QML. containing data roles. The contents can be defined dynamically, or
explicitly in QML.
The number of elements in the model can be obtained from its \l count property. The number of elements in the model can be obtained from its \l count property.
A number of familiar methods are also provided to manipulate the contents of the A number of familiar methods are also provided to manipulate the contents of the
...@@ -1803,7 +1791,7 @@ QHash<int, QByteArray> QQmlListModel::roleNames() const ...@@ -1803,7 +1791,7 @@ QHash<int, QByteArray> QQmlListModel::roleNames() const
} }
/*! /*!
\qmlproperty bool QtQml2::ListModel::dynamicRoles \qmlproperty bool ListModel::dynamicRoles
By default, the type of a role is fixed the first time By default, the type of a role is fixed the first time
the role is used. For example, if you create a role called the role is used. For example, if you create a role called
...@@ -1849,7 +1837,7 @@ void QQmlListModel::setDynamicRoles(bool enableDynamicRoles) ...@@ -1849,7 +1837,7 @@ void QQmlListModel::setDynamicRoles(bool enableDynamicRoles)
} }
/*! /*!
\qmlproperty int QtQml2::ListModel::count \qmlproperty int ListModel::count
The number of data entries in the model. The number of data entries in the model.
*/ */
int QQmlListModel::count() const int QQmlListModel::count() const
...@@ -2539,18 +2527,6 @@ bool QQmlListModelParser::definesEmptyList(const QString &s) ...@@ -2539,18 +2527,6 @@ bool QQmlListModelParser::definesEmptyList(const QString &s)
\instantiates QQmlListElement \instantiates QQmlListElement
\inqmlmodule QtQml.Models 2 \inqmlmodule QtQml.Models 2
\brief Defines a data item in a ListModel \brief Defines a data item in a ListModel
List elements are defined inside ListModel definitions, and represent items in a list.
This type is also available in the \c {QtQuick 2} import.
\sa {QtQml2::ListElement}{Full documentation for ListElement}
*/
/*!
\qmltype ListElement
\instantiates QQmlListElement
\inqmlmodule QtQml 2
\brief Defines a data item in a ListModel
\ingroup qtquick-models \ingroup qtquick-models
List elements are defined inside ListModel definitions, and represent items in a List elements are defined inside ListModel definitions, and represent items in a
......
...@@ -229,6 +229,9 @@ private: ...@@ -229,6 +229,9 @@ private:
QStringHash<Role *> roleHash; QStringHash<Role *> roleHash;
}; };
/*!
\internal
*/
class ListElement class ListElement
{ {
public: public:
...@@ -292,6 +295,9 @@ private: ...@@ -292,6 +295,9 @@ private:
friend class ListModel; friend class ListModel;
}; };
/*!
\internal
*/
class ListModel class ListModel
{ {
public: public:
...@@ -375,4 +381,3 @@ QT_END_NAMESPACE ...@@ -375,4 +381,3 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(ListModel *); Q_DECLARE_METATYPE(ListModel *);
#endif // QQUICKLISTMODEL_P_P_H #endif // QQUICKLISTMODEL_P_P_H
...@@ -169,7 +169,7 @@ public: ...@@ -169,7 +169,7 @@ public:
/*! /*!
\qmltype VisualItemModel \qmltype VisualItemModel
\instantiates QQmlObjectModel \instantiates QQmlObjectModel
\inqmlmodule QtQml 2 \inqmlmodule QtQuick 2
\brief Defines a set of objects to be used as a model \brief Defines a set of objects to be used as a model
The VisualItemModel type encapsulates contains the objects to be used The VisualItemModel type encapsulates contains the objects to be used
......
...@@ -60,4 +60,5 @@ headerdirs += ../../plugins ...@@ -60,4 +60,5 @@ headerdirs += ../../plugins
sourcedirs += ../../plugins sourcedirs += ../../plugins
#exclude certain directories #exclude certain directories
excludedirs = ../../imports/dialogs excludedirs += ../../imports/dialogs \
../../imports/models
...@@ -234,13 +234,26 @@ Animation paths ...@@ -234,13 +234,26 @@ Animation paths
\section2 Model/View Types And Data Storage And Access \section2 Model/View Types And Data Storage And Access
Models And Model Data QML Lists and Models
The \l{Qt QML Models QML Types}{Qt QML Models} submodule provides the types for
structuring data with models and lists.
\list
\li \l ListModel - Defines a list of data
\li \l ListElement - Defines a data item in a \l ListModel
\endlist
These QML types are part of Qt Quick for backwards compatibility, but for
newer applications, \l{Qt QML Models QML Types}{Qt QML Models} provides
the same functionality.
\list \list
\li \l {QtQml2::ListModel}{ListModel} - Defines a list of data
\li \l {QtQml2::ListElement}{ListElement} - Defines a data item in a \l {QtQml2::ListModel}{ListModel}
\li \l {VisualItemModel} - Contains items that already defines its own visual delegate \li \l {VisualItemModel} - Contains items that already defines its own visual delegate
\li \l {VisualDataModel} - Encapsulates a model and a delegate \li \l {VisualDataModel} - Encapsulates a model and a delegate
\li \l {VisualDataGroup} - Encapsulates a filtered set of visual data items \li \l {VisualDataGroup} - Encapsulates a filtered set of visual data items
\endlist
XML Lists
\list
\li \l {XmlListModel} - Specifies a model using XPath expressions \li \l {XmlListModel} - Specifies a model using XPath expressions
\li \l {XmlRole} - Specifies a role for an \l {XmlListModel} \li \l {XmlRole} - Specifies a role for an \l {XmlListModel}
\endlist \endlist
......
...@@ -43,7 +43,7 @@ QML types for creating user interfaces with the QML language, and a ...@@ -43,7 +43,7 @@ QML types for creating user interfaces with the QML language, and a
\l{Qt Quick C++ Classes}{C++ API} for extending QML applications with C++ code. \l{Qt Quick C++ Classes}{C++ API} for extending QML applications with C++ code.
\note From Qt 5.1, a set of Qt Quick based UI controls is available to \note From Qt 5.1, a set of Qt Quick based UI controls is available to
create classic desktop-style user interfaces. Please see \l{Qt Quick Controls} create user interfaces. Please see \l{Qt Quick Controls}
for more information. for more information.
For those new to QML and Qt Quick, please see For those new to QML and Qt Quick, please see
......
...@@ -44,6 +44,15 @@ features introduced by the new import and new classes in Qt 5.1: ...@@ -44,6 +44,15 @@ features introduced by the new import and new classes in Qt 5.1:
\li New \l TextEdit properties: selectByKeyboard and textDocument \li New \l TextEdit properties: selectByKeyboard and textDocument
\li A \l Window declared inside another Window or \l Item will automatically be \li A \l Window declared inside another Window or \l Item will automatically be
transient for (centered upon) the outer window. transient for (centered upon) the outer window.
\li These types are now part of \l{Qt QML}:
\list
\li \l {VisualItemModel}
\li \l {VisualDataModel} - Encapsulates a model and a delegate
\li \l {VisualDataGroup}
\endlist
These types are kept due to compatibility reasons and are replaced by the
\l{Qt QML Models QML Types}{Qt QML Models} types.
\endlist
\endlist \endlist
\section2 New Submodules \section2 New Submodules
......
...@@ -190,9 +190,6 @@ void tst_qquickanimatedimage::mirror_running() ...@@ -190,9 +190,6 @@ void tst_qquickanimatedimage::mirror_running()
QImage frame0_expected = frame0.transformed(transform); QImage frame0_expected = frame0.transformed(transform);
QImage frame1_expected = frame1.transformed(transform); QImage frame1_expected = frame1.transformed(transform);
#ifdef Q_OS_MAC
QSKIP("QTBUG-31370 - sometimes fails on Mac");
#endif
QCOMPARE(frame0_flipped, frame0_expected); QCOMPARE(frame0_flipped, frame0_expected);
QCOMPARE(frame1_flipped, frame1_expected); QCOMPARE(frame1_flipped, frame1_expected);
...@@ -204,29 +201,28 @@ void tst_qquickanimatedimage::mirror_notRunning() ...@@ -204,29 +201,28 @@ void tst_qquickanimatedimage::mirror_notRunning()
QFETCH(QUrl, fileUrl); QFETCH(QUrl, fileUrl);
QQuickView window; QQuickView window;
window.setSource(fileUrl);
window.show(); window.show();
QTRY_VERIFY(window.isExposed());
window.setSource(fileUrl);
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(window.rootObject()); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(window.rootObject());
QVERIFY(anim); QVERIFY(anim);
int width = anim->property("width").toInt(); int width = anim->property("width").toInt();
QPixmap screenshot = QPixmap::fromImage(window.grabWindow()); QImage screenshot = window.grabWindow();
QTransform transform; QTransform transform;
transform.translate(width, 0).scale(-1, 1.0); transform.translate(width, 0).scale(-1, 1.0);
QPixmap expected = screenshot.transformed(transform); QImage expected = screenshot.transformed(transform);
int frame = anim->currentFrame(); int frame = anim->currentFrame();
bool playing = anim->isPlaying(); bool playing = anim->isPlaying();
bool paused = anim->isPlaying(); bool paused = anim->isPlaying();
anim->setProperty("mirror", true); anim->setProperty("mirror", true);
screenshot = QPixmap::fromImage(window.grabWindow()); screenshot = window.grabWindow();
#ifdef Q_OS_MAC screenshot.save("screen.png");
QSKIP("QTBUG-31370 - sometimes fails on Mac");
#endif
QCOMPARE(screenshot, expected); QCOMPARE(screenshot, expected);
// mirroring should not change the current frame or playing status // mirroring should not change the current frame or playing status
......
...@@ -483,7 +483,9 @@ int main(int argc, char ** argv) ...@@ -483,7 +483,9 @@ int main(int argc, char ** argv)
QObject *topLevel = component->create(); QObject *topLevel = component->create();
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
QQuickView* qxView = 0; QQuickView* qxView = 0;
if (!window) { if (window) {
engine.setIncubationController(window->incubationController());
} else {
QQuickItem *contentItem = qobject_cast<QQuickItem *>(topLevel); QQuickItem *contentItem = qobject_cast<QQuickItem *>(topLevel);
if (contentItem) { if (contentItem) {
qxView = new QQuickView(&engine, NULL); qxView = new QQuickView(&engine, NULL);
......