summaryrefslogtreecommitdiffstats
path: root/weather-qml/ParallaxView.qml
blob: cfd4414d76c41302c85cecb5e60c746a3874662a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Qt 4.6

Item {
    id: root

    Component {
        id: cityDelegate

        Item {
            id: itemInner
            width: 432
            height: window.height

            signal present();

            Component.onCompleted: {
                var component = createComponent(weather + ".qml");
                var element = component.createObject();

                if (element != 0) {
                    element.parent = itemInner;
                    element.cityName = cityName;
                    element.isDay = !isNight;
                    element.lowTemperature = lower;
                    element.highTemperature = upper;
                    element.currentTemperature = current;
                }
            }
        }
    }

    ListView {
        id: list
        property bool moving: false

        anchors.fill: parent
        orientation: "Horizontal"
        currentIndex: window.currentIndex

        onCurrentIndexChanged: {
            if (!moving && currentItem)
                currentItem.present();
        }

        onMovementStarted: {
            moving = true;
        }

        onMovementEnded: {
            moving = false;
            currentItem.present();
        }

        model: cityModel
        delegate: cityDelegate

        snapMode: ListView.SnapOneItem
        highlightRangeMode: "StrictlyEnforceRange"
    }
}