summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/listview/dynamic.qml22
-rw-r--r--src/declarative/fx/qfxlistview.cpp16
2 files changed, 34 insertions, 4 deletions
diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml
index 78346f3..2607527 100644
--- a/examples/declarative/listview/dynamic.qml
+++ b/examples/declarative/listview/dynamic.qml
@@ -1,5 +1,6 @@
import Qt 4.6
import "content"
+import "../scrollbar"
Rectangle {
width: 640; height: 480
@@ -99,10 +100,31 @@ Rectangle {
}
ListView {
+ id: view
model: fruitModel; delegate: fruitDelegate
anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top }
}
+ // Attach scrollbar to the right edge of the view.
+ ScrollBar {
+ id: verticalScrollBar
+ opacity: 0
+ orientation: "Vertical"
+ position: view.visibleArea.yPosition
+ pageSize: view.visibleArea.heightRatio
+ width: 8
+ height: view.height
+ anchors.right: view.right
+ // Only show the scrollbar when the view is moving.
+ states: [
+ State {
+ name: "ShowBars"; when: view.moving
+ PropertyChanges { target: verticalScrollBar; opacity: 1 }
+ }
+ ]
+ transitions: [ Transition { NumberAnimation { properties: "opacity"; duration: 400 } } ]
+ }
+
Row {
x: 8; width: childrenRect.width
height: childrenRect.height
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 15680e1..f9ae0c0 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -343,6 +343,15 @@ public:
return true;
}
+ void updateViewport() {
+ Q_Q(QFxListView);
+ if (orient == QFxListView::Vertical)
+ q->setViewportHeight(endPosition() - startPosition());
+ else
+ q->setViewportWidth(endPosition() - startPosition());
+ }
+
+
// for debugging only
void checkVisible() const {
int skip = 0;
@@ -553,10 +562,7 @@ void QFxListViewPrivate::refill(qreal from, qreal to)
updateAverage();
if (!sectionExpression.isEmpty())
updateCurrentSection();
- if (orient == QFxListView::Vertical)
- q->setViewportHeight(endPosition() - startPosition());
- else
- q->setViewportWidth(endPosition() - startPosition());
+ updateViewport();
}
}
@@ -581,6 +587,7 @@ void QFxListViewPrivate::layout()
updateHighlight();
fixupPosition();
updateUnrequestedPositions();
+ updateViewport();
}
void QFxListViewPrivate::updateUnrequestedIndexes()
@@ -1804,6 +1811,7 @@ void QFxListView::itemsInserted(int modelIndex, int count)
for (int j = 0; j < added.count(); ++j)
added.at(j)->attached->emitAdd();
d->updateUnrequestedPositions();
+ d->updateViewport();
emit countChanged();
}