2
* Copyright (C) 2013-2014 Canonical Ltd
4
* This file is part of Ubuntu Calendar App
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.
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.
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/>.
20
import Ubuntu.Components 1.1
21
import Ubuntu.Components.ListItems 1.0 as ListItems
27
property variant value: model.get(listView.currentIndex) !== undefined ? model.get(listView.currentIndex).modelData : ""
28
property alias model: listView.model
29
property alias labelText: label.text
30
property alias currentIndex: listView.currentIndex
36
Component.onCompleted: {
37
var oldIndex = currentIndex
38
for (var i = 0; i < (max+1)-min; ++i) {
39
defaultModel.append({modelData: root.min + i})
41
listView.highlightMoveDuration = 0
42
currentIndex = oldIndex
43
listView.highlightMoveDuration = 300
47
if (defaultModel.get(0) === undefined) {
51
var oldMin = defaultModel.get(0).modelData
53
while (oldMin > min) {
54
defaultModel.insert(0, {modelData: --oldMin })
56
while (oldMin < min) {
57
defaultModel.remove(0)
63
if (defaultModel.get(defaultModel.count - 1) === undefined) {
67
var oldMax = defaultModel.get(defaultModel.count - 1).modelData
69
while (max < oldMax) {
70
defaultModel.remove(defaultModel.count - 1);
73
while (max > oldMax) {
74
defaultModel.insert(defaultModel.count, {modelData: ++oldMax})
89
anchors.centerIn: parent
104
anchors.topMargin: labelRect.height
105
pathItemCount: listView.height / highlightItem.height + 1
106
preferredHighlightBegin: 0.5
107
preferredHighlightEnd: 0.5
110
delegate: ListItems.Standard {
112
highlightWhenPressed: false
114
anchors.centerIn: parent
117
onClicked: listView.currentIndex = index
119
property int contentHeight: pathItemCount * highlightItem.height
121
startX: listView.width / 2; startY: -(listView.contentHeight - listView.height) / 2
122
PathLine { x: listView.width / 2; y: listView.height + (listView.contentHeight - listView.height) / 2 }
124
highlight: Rectangle {
127
property color baseColor: "#dd4814"
131
color: Qt.lighter(baseColor, 1.3);
142
bottom: parent.bottom