| 1 |
/* |
| 2 |
* Copyright 2012 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.0 |
| 18 |
import Lomiri.Components 1.1 |
| 19 |
import Lomiri.Components.Pickers 1.0 |
| 20 |
|
| 21 |
MainView { |
| 22 |
width: units.gu(40) |
| 23 |
height: units.gu(71) |
| 24 |
|
| 25 |
Page { |
| 26 |
title: "DatePicker test" |
| 27 |
Column { |
| 28 |
anchors.fill: parent |
| 29 |
DatePicker { |
| 30 |
id: picker |
| 31 |
locale: Qt.locale("en_UK") |
| 32 |
date: new Date() |
| 33 |
|
| 34 |
onDateChanged: print("CHANGED DATE=" + Qt.formatDateTime(date, "yyyy/MM/dd, hh:mm:ss")) |
| 35 |
onMovingChanged: print("MOVING?", moving) |
| 36 |
} |
| 37 |
Slider { |
| 38 |
value: 0.0//units.gu(36) |
| 39 |
live: true |
| 40 |
height: units.gu(2) |
| 41 |
minimumValue: 0.0 |
| 42 |
maximumValue: parent.width |
| 43 |
onValueChanged: picker.width = value |
| 44 |
} |
| 45 |
|
| 46 |
Flow { |
| 47 |
width: parent.width |
| 48 |
spacing: units.gu(1) |
| 49 |
Button { |
| 50 |
text: "HU" |
| 51 |
width: units.gu(5) |
| 52 |
height: units.gu(2) |
| 53 |
onClicked: picker.locale = Qt.locale("hu_HU") |
| 54 |
} |
| 55 |
Button { |
| 56 |
text: "DE" |
| 57 |
width: units.gu(5) |
| 58 |
height: units.gu(2) |
| 59 |
onClicked: picker.locale = Qt.locale("de_DE") |
| 60 |
} |
| 61 |
Button { |
| 62 |
text: "EN(US)" |
| 63 |
width: units.gu(9) |
| 64 |
height: units.gu(2) |
| 65 |
onClicked: picker.locale = Qt.locale("en_US") |
| 66 |
} |
| 67 |
Button { |
| 68 |
text: "FI" |
| 69 |
width: units.gu(5) |
| 70 |
height: units.gu(2) |
| 71 |
onClicked: { |
| 72 |
picker.locale = Qt.locale("fi_FI") |
| 73 |
picker.width = units.gu(37); |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
Button { |
| 78 |
text: "infinite" |
| 79 |
height: units.gu(2) |
| 80 |
onClicked: picker.maximum = picker.maximum.getInvalidDate() |
| 81 |
} |
| 82 |
Button { |
| 83 |
text: "Jan-Mar" |
| 84 |
height: units.gu(2) |
| 85 |
onClicked: { |
| 86 |
var date = new Date(); |
| 87 |
date.setMonth(0); |
| 88 |
picker.minimum = date; |
| 89 |
date.setMonth(2); |
| 90 |
picker.maximum = date; |
| 91 |
picker.date = new Date(date); |
| 92 |
} |
| 93 |
} |
| 94 |
Button { |
| 95 |
text: "Change minimum" |
| 96 |
height: units.gu(2) |
| 97 |
onClicked: { |
| 98 |
picker.minimum = new Date(2012, 11, 1); |
| 99 |
} |
| 100 |
} |
| 101 |
Button { |
| 102 |
text: "minimum & date" |
| 103 |
height: units.gu(2) |
| 104 |
onClicked: { |
| 105 |
picker.minimum = new Date(2013, 11, 1); |
| 106 |
picker.date = new Date(2014, 11, 5); |
| 107 |
} |
| 108 |
} |
| 109 |
Button { |
| 110 |
text: "today" |
| 111 |
height: units.gu(2) |
| 112 |
onClicked: picker.date = new Date() |
| 113 |
} |
| 114 |
|
| 115 |
Repeater { |
| 116 |
model: ["Years|Months|Days", "Years|Months", "Months|Days", "Years", "Months", "Days", |
| 117 |
"Hours|Minutes|Seconds", "Hours|Minutes", "Minutes|Seconds", "Hours", "Minutes", "Seconds", |
| 118 |
"Years|Months|Days|Hours|Minutes"] |
| 119 |
Button { |
| 120 |
text: "model: " + modelData |
| 121 |
height: units.gu(2) |
| 122 |
onClicked: picker.mode = modelData |
| 123 |
} |
| 124 |
} |
| 125 |
Button { |
| 126 |
text: "disable hours" |
| 127 |
height: units.gu(2) |
| 128 |
onClicked: { |
| 129 |
picker.mode = "Hours|Minutes|Seconds"; |
| 130 |
var min = new Date(); |
| 131 |
min.setHours(23); min.setMinutes(0); min.setSeconds(0); |
| 132 |
var max = new Date(); |
| 133 |
max.setHours(23); max.setMinutes(59); max.setSeconds(59); |
| 134 |
picker.minimum = min; |
| 135 |
picker.maximum = max; |
| 136 |
} |
| 137 |
} |
| 138 |
Button { |
| 139 |
text: "disable hours and minutes" |
| 140 |
height: units.gu(2) |
| 141 |
onClicked: { |
| 142 |
picker.mode = "Hours|Minutes|Seconds"; |
| 143 |
var min = new Date(); |
| 144 |
min.setHours(23); min.setMinutes(10); min.setSeconds(0); |
| 145 |
var max = new Date(); |
| 146 |
max.setHours(23); max.setMinutes(10); max.setSeconds(59); |
| 147 |
picker.minimum = min; |
| 148 |
picker.maximum = max; |
| 149 |
} |
| 150 |
} |
| 151 |
Button { |
| 152 |
text: "second range" |
| 153 |
height: units.gu(2) |
| 154 |
onClicked: { |
| 155 |
picker.mode = "Hours|Minutes|Seconds"; |
| 156 |
var min = new Date(); |
| 157 |
min.setHours(23); min.setMinutes(10); min.setSeconds(20); |
| 158 |
var max = new Date(); |
| 159 |
max.setHours(23); max.setMinutes(10); max.setSeconds(59); |
| 160 |
picker.minimum = min; |
| 161 |
picker.maximum = max; |
| 162 |
} |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
} |
| 167 |
} |