Added Month and Year buttons
Rearranged the DateRangeSelector dialog layout to also include a "Month" and "Year" view buttons, to make selecting a range of dates easier
This commit is contained in:
@@ -6,61 +6,90 @@ Dialog {
|
|||||||
width: 300
|
width: 300
|
||||||
height: 300
|
height: 300
|
||||||
|
|
||||||
|
id: dateRangeRootDialog
|
||||||
|
|
||||||
required property date currentDate
|
required property date currentDate
|
||||||
required property SystemPalette calendarActivePalette;
|
required property SystemPalette calendarActivePalette;
|
||||||
required property color disabledTextColor;
|
required property color disabledTextColor;
|
||||||
|
|
||||||
GridLayout {
|
enum ViewMode
|
||||||
columns: 1
|
{
|
||||||
|
DAY = 0,
|
||||||
|
MONTH = 1,
|
||||||
|
YEAR = 2
|
||||||
|
}
|
||||||
|
|
||||||
Label
|
property int viewMode: Qt.enumStringToValue(DateRangeSelector.ViewMode, "DAY")
|
||||||
{
|
property date beginDate;
|
||||||
font.pixelSize: 22
|
property date endDate;
|
||||||
text: getMyDate()
|
|
||||||
}
|
|
||||||
|
|
||||||
DayOfWeekRow {
|
Flickable
|
||||||
locale: grid.locale
|
{
|
||||||
Layout.fillWidth: true
|
onMovementStarted: console.log("Flick started")
|
||||||
}
|
onMovementEnded: console.log("Flick ended")
|
||||||
|
anchors.fill: parent
|
||||||
|
contentHeight: myGridLayout.height
|
||||||
|
|
||||||
MonthGrid
|
GridLayout {
|
||||||
{
|
id: myGridLayout
|
||||||
|
columns: 1
|
||||||
|
|
||||||
id: grid
|
Label
|
||||||
month: Calendar.January
|
{
|
||||||
year: currentDate.getFullYear()
|
font.pixelSize: 22
|
||||||
locale: Qt.locale("en_US")
|
text: getMyDate()
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
delegate: Rectangle {
|
|
||||||
border.color: model.day === currentDate.getDay() ? "green": "transparent"
|
|
||||||
border.width: 3
|
|
||||||
width: 30
|
|
||||||
height: 20
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
if (model.day === 11)
|
|
||||||
console.log(model.day)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
font.pixelSize: 12
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
text: model.day
|
|
||||||
color: model.month === currentDate.getMonth() ? calendarActivePalette.text : disabledTextColor
|
|
||||||
}
|
|
||||||
|
|
||||||
required property var model
|
|
||||||
}
|
}
|
||||||
|
|
||||||
property date currentlySelectedDate: currentDate;
|
DayOfWeekRow {
|
||||||
|
visible: dateRangeRootDialog.viewMode === Qt.enumStringToValue(DateRangeSelector.ViewMode, "DAY")
|
||||||
|
locale: grid.locale
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
MonthGrid
|
||||||
|
{
|
||||||
|
|
||||||
|
id: grid
|
||||||
|
month: currentDate.getMonth()
|
||||||
|
year: currentDate.getFullYear()
|
||||||
|
locale: Qt.locale("en_US")
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
delegate: Rectangle {
|
||||||
|
border.color: model.day === currentDate.getDay() ? "green": "transparent"
|
||||||
|
border.width: 3
|
||||||
|
width: 30
|
||||||
|
height: 20
|
||||||
|
color: calendarActivePalette.base
|
||||||
|
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
font.pixelSize: 12
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
text: model.day
|
||||||
|
color: model.month === currentDate.getMonth() ? calendarActivePalette.text : disabledTextColor
|
||||||
|
}
|
||||||
|
|
||||||
|
required property var model
|
||||||
|
}
|
||||||
|
|
||||||
|
property date currentlySelectedDate: currentDate;
|
||||||
|
}
|
||||||
|
Row
|
||||||
|
{
|
||||||
|
Button
|
||||||
|
{
|
||||||
|
text: "Month"
|
||||||
|
}
|
||||||
|
|
||||||
|
Button
|
||||||
|
{
|
||||||
|
text: "Year"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,4 +97,6 @@ Dialog {
|
|||||||
{
|
{
|
||||||
return Qt.formatDateTime(currentDate, "MMM yyyy");
|
return Qt.formatDateTime(currentDate, "MMM yyyy");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user