summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-02-09 12:59:42 +0100
committerMitch Curtis <mitch.curtis@qt.io>2018-02-09 12:30:34 +0000
commit9dc39b7f0610990dabf9f8544ca64ff5175e7c77 (patch)
tree4a12bcd9e8c0a93b3f985f9f4ba941540d6aaaf3 /src
parent48bfc02e82cb4b666fb832ef0ace59af8a0c7ef2 (diff)
downloadqtquickcontrols-9dc39b7f0610990dabf9f8544ca64ff5175e7c77.tar.gz
Calendar: make clicked(date) emit the correct date5.10
Calendar was implemented in such a way that pressing on a date selects that date, rather than releasing or clicking. With the current code, this presents issues when the month changes as a result of the press. For example, clicking on a date in an adjacent month will result in the clicked() signal passing the date under the mouse in the new month, instead of the originally pressed date. This patches fixes the issue by storing the pressed date and using it when emitting the released() and clicked() signals. Task-number: QTBUG-54129 Change-Id: I0c16293033b77f6ae783b5365d198b4a516af90b Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/controls/Styles/Base/CalendarStyle.qml8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/controls/Styles/Base/CalendarStyle.qml b/src/controls/Styles/Base/CalendarStyle.qml
index d1b172e0..9da43ce5 100644
--- a/src/controls/Styles/Base/CalendarStyle.qml
+++ b/src/controls/Styles/Base/CalendarStyle.qml
@@ -369,6 +369,7 @@ Style {
property int hoveredCellIndex: -1
property int pressedCellIndex: -1
property int pressCellIndex: -1
+ property var pressDate: null
Rectangle {
anchors.fill: parent
@@ -581,9 +582,11 @@ Style {
onPressed: {
pressCellIndex = cellIndexAt(mouse.x, mouse.y);
+ pressDate = null;
if (pressCellIndex !== -1) {
var date = view.model.dateAt(pressCellIndex);
pressedCellIndex = pressCellIndex;
+ pressDate = date;
if (__isValidDate(date)) {
control.selectedDate = date;
control.pressed(date);
@@ -608,9 +611,8 @@ Style {
onClicked: {
var indexOfCell = cellIndexAt(mouse.x, mouse.y);
if (indexOfCell !== -1 && indexOfCell === pressCellIndex) {
- var date = view.model.dateAt(indexOfCell);
- if (__isValidDate(date))
- control.clicked(date);
+ if (__isValidDate(pressDate))
+ control.clicked(pressDate);
}
}