Commit 7bc3ffef authored by Martin Straka's avatar Martin Straka

Fixed qml calendar

parent 764485ff
......@@ -39,17 +39,17 @@ Dialog {
return d instanceof Date && !isNaN(d);
}
function openCalendarDialogue(index, selDate, maxDate, title, dateDescr) {
root.title = title + " " + dateDescr
root.open()
function openCalendarDialogue(index, selDate, title) {
root.title = title
root.fieldIndex = index
if (isValidDate(selDate)) {
calendar.selectedDate = selDate
}
if (isValidDate(maxDate)) {
calendar.maximumDate = maxDate
var locale = Qt.locale()
var today = new Date()
var filledDate = Date.fromLocaleDateString(locale, selDate, "yyyy-MM-dd")
if (isValidDate(today)) {
calendar.maximumDate = today
}
calendar.selectedDate = (isValidDate(filledDate)) ? filledDate : today
root.open()
}
// center dialogue
......
......@@ -23,7 +23,6 @@
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQml 2.0 // Date
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.models 1.0
......@@ -174,11 +173,7 @@ Item {
emptyList.visible = (formList.count === 0)
}
onCalendarClicked: {
var locale = Qt.locale()
var today = new Date()
//var tomorow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000)
var filledDate = Date.fromLocaleDateString(locale, dateVal, "yyyy-MM-dd")
calendarDialogue.openCalendarDialogue(index, filledDate, today, "Select date", dateDescr)
calendarDialogue.openCalendarDialogue(index, dateVal, qsTr("Select date") + " " + dateDescr)
}
}
Connections {
......
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