400.1.1
by mihirsoni-123
Added copyright header comments in all the pages |
1 |
/*
|
400.1.2
by mihirsoni-123
updated copyright year |
2 |
* Copyright (C) 2013-2014 Canonical Ltd
|
400.1.1
by mihirsoni-123
Added copyright header comments in all the pages |
3 |
*
|
4 |
* This file is part of Ubuntu Calendar App
|
|
5 |
*
|
|
6 |
* Ubuntu Calendar App is free software: you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License version 3 as
|
|
8 |
* published by the Free Software Foundation.
|
|
9 |
*
|
|
10 |
* Ubuntu Calendar App is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
*/
|
|
463.1.1
by Akiva Avraham
Updated library imports to qtquick-2.3 |
18 |
import QtQuick 2.3 |
63.1.1
by Kunal Parmar
year view implementation |
19 |
|
20 |
PathView { |
|
21 |
id: root
|
|
22 |
||
23 |
model: 3 |
|
24 |
snapMode: PathView.SnapOneItem |
|
25 |
||
26 |
signal nextItemHighlighted(); |
|
27 |
signal previousItemHighlighted(); |
|
28 |
||
183.1.1
by Kunal Parmar
Key Navigation implemented |
29 |
signal scrollUp(); |
30 |
signal scrollDown(); |
|
31 |
||
172.2.3
by Kunal Parmar
PathView changed |
32 |
preferredHighlightBegin: 0.5 |
33 |
preferredHighlightEnd: 0.5 |
|
34 |
||
63.1.1
by Kunal Parmar
year view implementation |
35 |
path: Path { |
172.2.3
by Kunal Parmar
PathView changed |
36 |
startX: -(root.width); startY: root.height/2 |
37 |
PathLine { x: (root.width)*2 ; relativeY: 0; } |
|
63.1.1
by Kunal Parmar
year view implementation |
38 |
}
|
39 |
||
114.2.1
by Kunal Parmar
dayview weekview transition added |
40 |
// 0= current index, -1= previous index, 1 next index
|
41 |
function indexType(index) { |
|
42 |
if (index === root.currentIndex) { |
|
43 |
return 0; |
|
44 |
}
|
|
45 |
||
46 |
var previousIndex = root.currentIndex > 0 ? root.currentIndex - 1 : 2 |
|
47 |
if ( index === previousIndex ) { |
|
48 |
return -1; |
|
49 |
}
|
|
50 |
||
51 |
return 1; |
|
52 |
}
|
|
53 |
||
183.1.1
by Kunal Parmar
Key Navigation implemented |
54 |
Keys.onLeftPressed:{ |
55 |
root.decrementCurrentIndex(); |
|
56 |
}
|
|
57 |
||
58 |
Keys.onRightPressed:{ |
|
59 |
root.incrementCurrentIndex(); |
|
60 |
}
|
|
61 |
||
62 |
Keys.onSpacePressed: { |
|
63 |
root.scrollDown(); |
|
64 |
}
|
|
65 |
||
66 |
Keys.onDownPressed: { |
|
67 |
root.scrollDown(); |
|
68 |
}
|
|
69 |
||
70 |
Keys.onUpPressed: { |
|
71 |
root.scrollUp(); |
|
72 |
}
|
|
73 |
||
63.1.1
by Kunal Parmar
year view implementation |
74 |
onCurrentIndexChanged: { |
75 |
var diff = currentIndex - intern.previousIndex |
|
183.1.1
by Kunal Parmar
Key Navigation implemented |
76 |
if(diff == 0) return; |
63.1.1
by Kunal Parmar
year view implementation |
77 |
|
78 |
if (intern.previousIndex === count - 1 && currentIndex === 0) diff = 1 |
|
79 |
if (intern.previousIndex === 0 && currentIndex === count - 1) diff = -1 |
|
80 |
||
81 |
intern.previousIndex = currentIndex |
|
82 |
||
83 |
if ( diff > 0 ) { |
|
84 |
root.nextItemHighlighted(); |
|
85 |
}
|
|
86 |
else { |
|
87 |
root.previousItemHighlighted(); |
|
88 |
}
|
|
89 |
}
|
|
90 |
||
91 |
QtObject{ |
|
92 |
id: intern
|
|
93 |
property int previousIndex: root.currentIndex |
|
94 |
}
|
|
95 |
}
|