summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-08-03 07:28:21 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-08-03 07:28:21 (GMT)
commita41128af5373a0225c3548abd3eb82cd7e8f7a0e (patch)
tree378fe5976aa66b2ce73c8657ceaa59ac8579e9dd
parent6b2a5c6f18cb766801a50db583e14a8e559e9bfb (diff)
parentb5c6f77bf0a84e7411d64d6f486ffcbd79ad9494 (diff)
downloadQt-a41128af5373a0225c3548abd3eb82cd7e8f7a0e.zip
Qt-a41128af5373a0225c3548abd3eb82cd7e8f7a0e.tar.gz
Qt-a41128af5373a0225c3548abd3eb82cd7e8f7a0e.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Fix photo positioning bug in flickr demo. Fix Flickable.StopAtBounds behavior when content size < flickable size Ensure dataChanged doesn't force request for unwanted data in QML views.
-rw-r--r--demos/declarative/flickr/flickr.qml22
-rw-r--r--demos/declarative/flickr/mobile/GridDelegate.qml130
-rw-r--r--demos/declarative/flickr/mobile/ImageDetails.qml22
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp26
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp15
-rw-r--r--src/declarative/util/qdeclarativeopenmetaobject.cpp12
-rw-r--r--src/declarative/util/qdeclarativeopenmetaobject_p.h1
7 files changed, 126 insertions, 102 deletions
diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml
index 48db476..152f9f9 100644
--- a/demos/declarative/flickr/flickr.qml
+++ b/demos/declarative/flickr/flickr.qml
@@ -57,21 +57,20 @@ Item {
Item {
id: views
- x: 2; width: parent.width - 4
+ width: parent.width
anchors.top: titleBar.bottom; anchors.bottom: toolBar.top
- Mobile.GridDelegate { id: gridDelegate }
GridView {
- x: (width/4-79)/2; y: x
- id: photoGridView; model: rssModel; delegate: gridDelegate; cacheBuffer: 100
- cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height - 1; z: 6
+ id: photoGridView; model: rssModel; delegate: Mobile.GridDelegate {}
+ cacheBuffer: 100
+ cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height
}
- Mobile.ListDelegate { id: listDelegate }
ListView {
- id: photoListView; model: rssModel; delegate: listDelegate; z: 6
+ id: photoListView; model: rssModel; delegate: Mobile.ListDelegate { }
width: parent.width; height: parent.height; x: -(parent.width * 1.5); cacheBuffer: 100;
}
+
states: State {
name: "ListView"; when: screen.inListView == true
PropertyChanges { target: photoListView; x: 0 }
@@ -81,13 +80,16 @@ Item {
transitions: Transition {
NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
}
+
+ Mobile.ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height }
+
+ Item { id: foreground; anchors.fill: parent }
}
- Mobile.ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height; z:1 }
- Mobile.TitleBar { id: titleBar; z: 5; width: parent.width; height: 40; opacity: 0.9 }
+ Mobile.TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 }
Mobile.ToolBar {
- id: toolBar; z: 5
+ id: toolBar
height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
button1Label: "Update"; button2Label: "View mode"
onButton1Clicked: rssModel.reload()
diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml
index cbb00a2..c368e95 100644
--- a/demos/declarative/flickr/mobile/GridDelegate.qml
+++ b/demos/declarative/flickr/mobile/GridDelegate.qml
@@ -39,75 +39,73 @@
**
****************************************************************************/
- import Qt 4.7
+import Qt 4.7
- Component {
- id: photoDelegate
- Item {
- id: wrapper; width: 79; height: 79
+Item {
+ id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight
- function photoClicked() {
- imageDetails.photoTitle = title;
- imageDetails.photoTags = tags;
- imageDetails.photoWidth = photoWidth;
- imageDetails.photoHeight = photoHeight;
- imageDetails.photoType = photoType;
- imageDetails.photoAuthor = photoAuthor;
- imageDetails.photoDate = photoDate;
- imageDetails.photoUrl = url;
- imageDetails.rating = 0;
- scaleMe.state = "Details";
- }
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
+ }
- Item {
- anchors.centerIn: parent
- scale: 0.0
- Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
- id: scaleMe
+ Item {
+ anchors.centerIn: parent
+ scale: 0.0
+ Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
+ id: scaleMe
- Rectangle { height: 79; width: 79; id: blackRect; anchors.centerIn: parent; color: "black"; smooth: true }
- Rectangle {
- id: whiteRect; width: 77; height: 77; anchors.centerIn: parent; color: "#dddddd"; smooth: true
- Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true}
- Image { source: "images/gloss.png" }
- }
+ Item {
+ width: 77; height: 77; anchors.centerIn: parent
+ Rectangle {
+ id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
+ Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
+ Image { source: "images/gloss.png" }
+ }
+ }
- Connections {
- target: toolBar
- onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
- }
+ Connections {
+ target: toolBar
+ onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
+ }
+
+ states: [
+ State {
+ name: "Show"; when: thumb.status == Image.Ready
+ PropertyChanges { target: scaleMe; scale: 1 }
+ },
+ State {
+ name: "Details"
+ PropertyChanges { target: scaleMe; scale: 1 }
+ ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
+ PropertyChanges { target: background; state: "DetailedView" }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "Show"; to: "Details"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ },
+ Transition {
+ from: "Details"; to: "Show"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ }
+ ]
+ }
+ MouseArea { anchors.fill: wrapper; onClicked: photoClicked() }
+}
- states: [
- State {
- name: "Show"; when: thumb.status == Image.Ready
- PropertyChanges { target: scaleMe; scale: 1 }
- },
- State {
- name: "Details"
- PropertyChanges { target: scaleMe; scale: 1 }
- ParentChange { target: wrapper; parent: imageDetails.frontContainer }
- PropertyChanges { target: wrapper; x: 20; y: 60; z: 1000 }
- PropertyChanges { target: background; state: "DetailedView" }
- }
- ]
- transitions: [
- Transition {
- from: "Show"; to: "Details"
- ParentAnimation {
- NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
- }
- },
- Transition {
- from: "Details"; to: "Show"
- SequentialAnimation {
- ParentAnimation {
- NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
- }
- PropertyAction { targets: wrapper; properties: "z" }
- }
- }
- ]
- }
- MouseArea { anchors.fill: wrapper; onClicked: { photoClicked() } }
- }
- }
diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml
index b1a7359..ff902ce 100644
--- a/demos/declarative/flickr/mobile/ImageDetails.qml
+++ b/demos/declarative/flickr/mobile/ImageDetails.qml
@@ -45,7 +45,7 @@ import "../common" as Common
Flipable {
id: container
- property variant frontContainer: containerFront
+ property alias frontContainer: containerFront
property string photoTitle: ""
property string photoTags: ""
property int photoWidth
@@ -76,17 +76,17 @@ Flipable {
Column {
spacing: 10
anchors {
- left: parent.left; leftMargin: 20
- right: parent.right; rightMargin: 20
- top: parent.top; topMargin: 180
+ left: parent.left; leftMargin: 10
+ right: parent.right; rightMargin: 10
+ top: parent.top; topMargin: 120
}
- Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle }
- Text { color: "white"; elide: Text.ElideRight; text: "<b>Size:</b> " + container.photoWidth + 'x' + container.photoHeight }
- Text { color: "white"; elide: Text.ElideRight; text: "<b>Type:</b> " + container.photoType }
- Text { color: "white"; elide: Text.ElideRight; text: "<b>Author:</b> " + container.photoAuthor }
- Text { color: "white"; elide: Text.ElideRight; text: "<b>Published:</b> " + container.photoDate }
- Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "<b>Tags:</b> " }
- Text { color: "white"; elide: Text.ElideRight; text: container.photoTags }
+ Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width }
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 998b33a..19cabdd 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -681,12 +681,15 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (newY < maxY && maxY - minY <= 0)
newY = maxY + (newY - maxY) / 2;
if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newY > minY || newY < maxY)) {
- if (newY > minY)
- newY = minY;
- else if (newY < maxY)
+ rejectY = true;
+ if (newY < maxY) {
newY = maxY;
- else
- rejectY = true;
+ rejectY = false;
+ }
+ if (newY > minY) {
+ newY = minY;
+ rejectY = false;
+ }
}
if (!rejectY && stealMouse) {
vData.move.setValue(qRound(newY));
@@ -708,12 +711,15 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (newX < maxX && maxX - minX <= 0)
newX = maxX + (newX - maxX) / 2;
if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newX > minX || newX < maxX)) {
- if (newX > minX)
- newX = minX;
- else if (newX < maxX)
+ rejectX = true;
+ if (newX < maxX) {
newX = maxX;
- else
- rejectX = true;
+ rejectX = false;
+ }
+ if (newX > minX) {
+ newX = minX;
+ rejectX = false;
+ }
}
if (!rejectX && stealMouse) {
hData.move.setValue(qRound(newX));
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 79c1c43..ceb1961 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -444,6 +444,9 @@ public:
int propForRole(int) const;
void setValue(int, const QVariant &);
+ bool hasValue(int id) const {
+ return m_meta->hasValue(id);
+ }
void ensureProperties();
@@ -1216,11 +1219,13 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count,
int role = roles.at(roleIdx);
int propId = data->propForRole(role);
if (propId != -1) {
- if (d->m_listModelInterface) {
- data->setValue(propId, d->m_listModelInterface->data(idx, QList<int>() << role).value(role));
- } else if (d->m_abstractItemModel) {
- QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root);
- data->setValue(propId, d->m_abstractItemModel->data(index, role));
+ if (data->hasValue(propId)) {
+ if (d->m_listModelInterface) {
+ data->setValue(propId, d->m_listModelInterface->data(idx, QList<int>() << role).value(role));
+ } else if (d->m_abstractItemModel) {
+ QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root);
+ data->setValue(propId, d->m_abstractItemModel->data(index, role));
+ }
}
} else {
QString roleName;
diff --git a/src/declarative/util/qdeclarativeopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp
index ba5d534..40485bd 100644
--- a/src/declarative/util/qdeclarativeopenmetaobject.cpp
+++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp
@@ -161,6 +161,12 @@ public:
prop.second = true;
}
+ inline bool hasData(int idx) const {
+ if (idx >= data.count())
+ return false;
+ return data[idx].second;
+ }
+
bool autoCreate;
QDeclarativeOpenMetaObject *q;
QAbstractDynamicMetaObject *parent;
@@ -295,6 +301,12 @@ void QDeclarativeOpenMetaObject::setValue(const QByteArray &name, const QVariant
activate(d->object, id + d->type->d->signalOffset, 0);
}
+// returns true if this value has been initialized by a call to either value() or setValue()
+bool QDeclarativeOpenMetaObject::hasValue(int id) const
+{
+ return d->hasData(id);
+}
+
void QDeclarativeOpenMetaObject::setCached(bool c)
{
if (c == d->cacheProperties || !d->type->d->engine)
diff --git a/src/declarative/util/qdeclarativeopenmetaobject_p.h b/src/declarative/util/qdeclarativeopenmetaobject_p.h
index 9bb4c34..c18fa3d 100644
--- a/src/declarative/util/qdeclarativeopenmetaobject_p.h
+++ b/src/declarative/util/qdeclarativeopenmetaobject_p.h
@@ -91,6 +91,7 @@ public:
void setValue(int, const QVariant &);
QVariant &operator[](const QByteArray &);
QVariant &operator[](int);
+ bool hasValue(int) const;
int count() const;
QByteArray name(int) const;