Commit 4df4d8f1 authored by Chupligin Sergey's avatar Chupligin Sergey

[DatePicker] Add listing and signals

parent 157b66b4
...@@ -42,6 +42,9 @@ Item { ...@@ -42,6 +42,9 @@ Item {
property var monthNames: [qsTr("January"), qsTr("February"), qsTr("March"), qsTr("April"), qsTr("May"), qsTr("June"),qsTr("July"), qsTr("August"), qsTr("September"), qsTr("October"), qsTr("November"), qsTr("December")]; property var monthNames: [qsTr("January"), qsTr("February"), qsTr("March"), qsTr("April"), qsTr("May"), qsTr("June"),qsTr("July"), qsTr("August"), qsTr("September"), qsTr("October"), qsTr("November"), qsTr("December")];
signal monthChanged()
signal dateSelect(var date)
Item { Item {
id: header id: header
width: parent.width width: parent.width
...@@ -64,6 +67,24 @@ Item { ...@@ -64,6 +67,24 @@ Item {
topMargin: (Theme.itemHeightLarge-Theme.itemHeightMedium)/2 topMargin: (Theme.itemHeightLarge-Theme.itemHeightMedium)/2
} }
source: "image://theme/caret-left" source: "image://theme/caret-left"
MouseArea{
anchors.fill: parent
onClicked: {
var newDate = currentDate;
if(newDate.getMonth() == 1)
{
newDate.setFullYear(currentDate.getFullYear()-1)
newDate.setMonth(12)
}
else
{
newDate.setMonth(currentDate.getMonth()-1)
}
datePicker.currentDate = newDate
monthChanged()
}
}
} }
Label{ Label{
...@@ -86,6 +107,24 @@ Item { ...@@ -86,6 +107,24 @@ Item {
topMargin: (Theme.itemHeightLarge-Theme.itemHeightMedium)/2 topMargin: (Theme.itemHeightLarge-Theme.itemHeightMedium)/2
} }
source: "image://theme/caret-right" source: "image://theme/caret-right"
MouseArea{
anchors.fill: parent
onClicked: {
var newDate = currentDate;
if(newDate.getMonth() == 12)
{
newDate.setFullYear(currentDate.getFullYear()+1)
newDate.setMonth(1)
}
else
{
newDate.setMonth(currentDate.getMonth()+1)
}
datePicker.currentDate = newDate
monthChanged()
}
}
} }
} }
...@@ -215,6 +254,14 @@ Item { ...@@ -215,6 +254,14 @@ Item {
color: setColor(model) color: setColor(model)
font.pixelSize: (parent.height*0.45 < Theme.fontSizeLarge) ? parent.height*0.45 : Theme.fontSizeLarge font.pixelSize: (parent.height*0.45 < Theme.fontSizeLarge) ? parent.height*0.45 : Theme.fontSizeLarge
} }
MouseArea{
anchors.fill: parent
onClicked: {
datePicker.dateSelect(model.dateOfDay)
}
}
} }
Component.onCompleted: { Component.onCompleted: {
...@@ -223,6 +270,12 @@ Item { ...@@ -223,6 +270,12 @@ Item {
} }
} }
onMonthChanged: {
dateModel.selectedDate = datePicker.currentDate
dateModel.clear()
dateModel.fillModel()
}
ListModel { ListModel {
id: dateModel id: dateModel
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment