Skip to content
Permalink
Browse files

[QgsQuick] Support for custom formats and strings

  • Loading branch information
vsklencar authored and wonder-sk committed Sep 11, 2020
1 parent 3fc61a4 commit 7aa18dab5ef4c78be9636a03ecb2996e66387926
Showing with 11 additions and 7 deletions.
  1. +10 −6 src/quickgui/plugin/editor/qgsquickdatetime.qml
  2. +1 −1 src/quickgui/qgsquickutils.cpp
@@ -116,7 +116,7 @@ Item {
onClicked: {
var usedDate = new Date();
if (value !== undefined && value !== '') {
usedDate = value;
usedDate = main.isDateOrTime ? value : Date.fromLocaleString(Qt.locale(), value, config['field_format'])
}

calendar.selectedDate = usedDate
@@ -147,7 +147,8 @@ Item {
anchors.fill: parent
onClicked: {
var newDate = new Date()
valueChanged(newDate, false)
var newValue = field.isDateOrTime ? newDate : Qt.formatDateTime(newDate, config['field_format'])
valueChanged(newValue, false)
}
}
}
@@ -197,7 +198,10 @@ Item {

Controls1.Calendar {
id: calendar
selectedDate: main.currentValue || new Date()
selectedDate: {
var date = field.isDateOrTime ? main.currentValue : Date.fromLocaleString(Qt.locale(), value, config['field_format'])
date || new Date()
}
weekNumbersVisible: true
focus: false
implicitWidth: calendarOverlay.width
@@ -302,8 +306,8 @@ Item {
newDate.setSeconds(secondsSpinBox.value);
}

label.text = timeToString(newDate)
valueChanged(newDate, newDate === undefined)
var newValue = field.isDateOrTime ? newDate : Qt.formatDateTime(newDate, config['field_format'])
valueChanged(newValue, newValue === undefined)
popup.close()
}
}
@@ -313,7 +317,7 @@ Item {
}

onCurrentValueChanged: {
label.text = timeToString(main.currentValue)
label.text = field.isDateOrTime ? timeToString(main.currentValue) : main.currentValue
}
}

@@ -405,7 +405,7 @@ QString QgsQuickUtils::dateTimeFieldFormat( const QString &fieldFormat )
}
else
{
return QString();
return QString( "Date Time" );
}
}

0 comments on commit 7aa18da

Please sign in to comment.
You can’t perform that action at this time.