Commit 43aa3afb authored by Kai Koehne's avatar Kai Koehne Committed by Daniel Molkentin
Browse files

WelcomeScreen: Use ListView instead of Repeater for news

This reduces number of objects created on startup, and also
allows us to simplify the logic a bit.

Change-Id: I6c7c2c5e537ff9a1882e133551f89c056cbe4fe5
Reviewed-on: http://codereview.qt-project.org/6359


Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarDaniel Molkentin <daniel.molkentin@nokia.com>
parent 58f987cd
......@@ -37,40 +37,29 @@ Item {
id: root
property int currentItem: 0
property alias model: repeater.model
property alias itemCount: repeater.count
property alias model: view.model
property alias itemCount: view.count
Timer {
id: nextItemTimer
repeat: true
interval: 30*1000
onTriggered: repeater.incrementIndex()
onTriggered: view.incrementCurrentIndex()
}
Timer {
id: modelUpdateTimer
repeat: false
interval: 1000
onTriggered: repeater.handleModelUpdate();
onTriggered: view.handleModelUpdate();
}
Repeater {
id: repeater
function incrementIndex() {
repeater.itemAt(currentItem).active = false
currentItem = (currentItem+1) % repeater.count
repeater.itemAt(currentItem).active = true
}
ListView {
id: view
function handleModelUpdate() {
nextItemTimer.stop();
currentItem = 0;
for (var i = 0; i < count; ++i) {
if (i != currentItem)
repeater.itemAt(i).active = false;
else
repeater.itemAt(i).active = true;
}
currentIndex = 0;
nextItemTimer.start();
}
......@@ -78,21 +67,16 @@ Item {
modelUpdateTimer.restart();
}
function handleItemRemoved(index, item) {
modelUpdateTimer.restart();
}
function handleItemAdded(index, item) {
modelUpdateTimer.restart();
}
anchors.fill: parent
highlightMoveDuration: 1 // don't show any scrolling
keyNavigationWraps: true // start from 0 again if at end
interactive: false
onModelChanged: handleModelChanged()
onItemAdded: handleItemAdded(index, item)
onItemRemoved: handleItemRemoved(index, item)
delegate: Item {
property bool active: false
id: delegateItem
property bool active: ListView.isCurrentItem
opacity: 0
height: root.height
width: root.width
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment