~pkunal-parmar/ubuntu-calendar-app/Minor-Performance

63.1.1 by Kunal Parmar
year view implementation
1
import QtQuick 2.0
2
3
PathView {
4
    id: root
5
6
    model: 3
7
    snapMode: PathView.SnapOneItem
8
9
    signal nextItemHighlighted();
10
    signal previousItemHighlighted();
11
12
    path: Path {
72.2.16 by Kunal Parmar
unnecessary space remoevd
13
        startX: -(root.width/2); startY: root.height/2
63.1.1 by Kunal Parmar
year view implementation
14
        PathLine { relativeX: root.width; relativeY: 0 }
15
        PathLine { relativeX: root.width; relativeY: 0 }
16
        PathLine { relativeX: root.width; relativeY: 0 }
17
    }
18
114.2.1 by Kunal Parmar
dayview weekview transition added
19
    // 0= current index, -1= previous index, 1 next index
20
    function indexType(index) {
21
        if (index === root.currentIndex) {
22
            return 0;
23
        }
24
25
        var previousIndex = root.currentIndex > 0 ? root.currentIndex - 1 : 2
26
        if ( index === previousIndex ) {
27
            return -1;
28
        }
29
30
        return 1;
31
    }
32
63.1.1 by Kunal Parmar
year view implementation
33
    onCurrentIndexChanged: {
34
        var diff = currentIndex - intern.previousIndex
35
36
        if (intern.previousIndex === count - 1 && currentIndex === 0) diff = 1
37
        if (intern.previousIndex === 0 && currentIndex === count - 1) diff = -1
38
39
        intern.previousIndex = currentIndex
40
41
        if ( diff > 0 ) {
42
            root.nextItemHighlighted();
43
        }
44
        else {
45
            root.previousItemHighlighted();
46
        }
47
    }
48
49
    QtObject{
50
        id: intern
51
        property int previousIndex: root.currentIndex
52
    }
53
}