summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-12-13 12:53:06 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-12-13 12:53:06 (GMT)
commit896cd4bd08181ad16ad9cee6d2aaa1844a4f06d3 (patch)
treefebdfc095d955fa2f57c7ebc337a2d7ce87ddf47
parentaae8f8432856125c94d93a9849914a7c6a7ecc76 (diff)
parent95ddfa13737164c93c58ce3694ce59ec68a016d9 (diff)
downloadQt-896cd4bd08181ad16ad9cee6d2aaa1844a4f06d3.zip
Qt-896cd4bd08181ad16ad9cee6d2aaa1844a4f06d3.tar.gz
Qt-896cd4bd08181ad16ad9cee6d2aaa1844a4f06d3.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: Ensure ListView contentHeight is set to a valid size. Revert "Add mirroring-positioners.qml example" that was accidentally pushed Fix dragging Flickable back over start point. Add mirroring-positioners.qml example A QAIM model resulted in items moving to incorrect locations
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml37
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp20
5 files changed, 66 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 377f3b5..f1d92c5 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -700,8 +700,8 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
bool rejectY = false;
bool rejectX = false;
- bool stealY = false;
- bool stealX = false;
+ bool stealY = stealMouse;
+ bool stealX = stealMouse;
if (q->yflick()) {
int dy = int(event->pos().y() - pressPos.y());
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index d008f91..2a7f508 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -265,6 +265,8 @@ public:
}
}
pos = (*(--visibleItems.constEnd()))->endPosition() + invisibleCount * (averageSize + spacing);
+ } else if (model && model->count()) {
+ pos = model->count() * averageSize + (model->count()-1) * spacing;
}
return pos;
}
@@ -1050,6 +1052,8 @@ void QDeclarativeListViewPrivate::updateCurrent(int modelIndex)
// This is slightly sub-optimal, but section heading caching minimizes the impact.
if (currentItem->section)
currentItem->section->setVisible(false);
+ if (visibleItems.isEmpty())
+ averageSize = currentItem->size();
}
updateHighlight();
emit q->currentIndexChanged();
@@ -1576,6 +1580,7 @@ void QDeclarativeListView::setModel(const QVariant &model)
d->updateTrackedItem();
}
}
+ d->updateViewport();
}
connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
@@ -1647,6 +1652,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate)
d->highlight->setPosition(d->currentItem->position());
d->updateTrackedItem();
}
+ d->updateViewport();
}
}
emit delegateChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 4fe6c4c..4f5213a 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -1367,7 +1367,7 @@ void QDeclarativeVisualDataModel::_q_rowsMoved(const QModelIndex &sourceParent,
Q_D(QDeclarativeVisualDataModel);
const int count = sourceEnd - sourceStart + 1;
if (destinationParent == d->m_root && sourceParent == d->m_root) {
- _q_itemsMoved(sourceStart, destinationRow, count);
+ _q_itemsMoved(sourceStart, sourceStart > destinationRow ? destinationRow : destinationRow-1, count);
} else if (sourceParent == d->m_root) {
_q_itemsRemoved(sourceStart, count);
} else if (destinationParent == d->m_root) {
diff --git a/tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml b/tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml
new file mode 100644
index 0000000..0756618
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml
@@ -0,0 +1,37 @@
+import QtQuick 1.0
+
+Item {
+ width: 640
+ height: 480
+
+ function setModel() {
+ listView.model = listModel1
+ }
+
+ ListModel {
+ id: listModel1
+ ListElement { text: "Apple" }
+ ListElement { text: "Banana" }
+ ListElement { text: "Orange" }
+ ListElement { text: "Coconut" }
+ }
+
+ Rectangle {
+ width: 200
+ height: listView.contentHeight
+ color: "yellow"
+ anchors.centerIn: parent
+
+ ListView {
+ id: listView
+ objectName: "listview"
+ anchors.fill: parent
+
+ delegate: Item {
+ width: 200
+ height: 20
+ Text { text: model.text; anchors.centerIn: parent }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index ff90d32..b834d46 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -104,6 +104,7 @@ private slots:
void sizeLessThan1();
void QTBUG_14821();
void resizeDelegate();
+ void QTBUG_16037();
private:
template <class T> void items();
@@ -1944,6 +1945,25 @@ void tst_QDeclarativeListView::resizeDelegate()
delete canvas;
}
+void tst_QDeclarativeListView::QTBUG_16037()
+{
+ QDeclarativeView *canvas = createView();
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug16037.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "listview");
+ QTRY_VERIFY(listview != 0);
+
+ QVERIFY(listview->contentHeight() <= 0.0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "setModel");
+
+ QTRY_COMPARE(listview->contentHeight(), 80.0);
+
+ delete canvas;
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();