summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qdatetimeedit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Pass QDateTimeParser::SectionNode by value, not const refEdward Welbourne6 days1-1/+1
| | | | | | | | | It's trivially copyable and fits into a (128-bit) register. Delete one spurious line from a \internal doc in the process. Task-number: QTBUG-122619 Change-Id: I55bd39f176f58e0dcd0ecc86e88bd29d449c7fd7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Document calendar setting of QCalendarWidget and QDateTimeEditEdward Welbourne6 days1-0/+16
| | | | | | | | | | | | | It seems this was neglected in 5.14, when the methods were added. The calendar setting is also not a Q_PROPERTY; and hadn't been tested until recently. This follows up on commit 2dee00621632ab8acd0b3d59bdba264afe2f32c1 Pick-to: 6.7 6.5 Task-number: QTBUG-115200 Change-Id: I9625bf54d05a55a40867847bd58130be90e78271 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix -Wimplicit-fallthrough for clangTim Blechmann2024-03-011-0/+1
| | | | | | | | | | | | | | | | | | | Clang's `-Wimplicit-fallthrough` warnings are a little stricter than gcc's interpretation: switch (i) { case 0: foo(); case 4: break; } While gcc accepts the implicit fallthrough, if the following statement is a trivial `break`, clang will warn about it. Pick-to: 6.7 Change-Id: I38e0817f1bc034fbb552aeac21de1516edcbcbb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractSpinBox: use pmf-style connectsChristian Ehrlicher2023-11-091-3/+3
| | | | | | | | Use pmf-style connections instead old string-based ones. Change-Id: Idab3a9d60e7cddcd2076476a21dbb1b5d2e4189c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add a QDateTimeEdit::timeZone propertyEdward Welbourne2023-10-231-8/+42
| | | | | | | | | | | | | | This shall ultimately replace its timeSpec property, which had already been turned into a derived property of an internal timezone. [ChangeLog][QWidget][QDateTimeEdit] Added timeZone property to enable a datetime edit widget to control the timezone used. This makes the timeSpec property redundant; this old property shall be deprecated from 6.10. Fixes: QTBUG-80417 Change-Id: I3cdb686bd2dada0e5067f5b4c1828b73892e424a Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QDateTime: disambiguate times in a zone transitionEdward Welbourne2023-10-191-18/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, requesting a time that got repeated - on the given date, due to a fall-back transition - would get one of the two repeats, giving the caller (no hint that there was a choice and) no way to select the other. Add a flags parameter that captures the available ways to resolve such ambiguity or select a suitable time near a gap. Add such a parameter to relevant QDateTime methods, including constructors, to enable callers to indicate their preference in the same way. This replaces DST-hint parameters in various internal functions, including QTimeZonePrivate's dataForLocalTime(). Adapted tst_QDateTime to test the new feature. Adapt to gap-times no longer being invalid (by default; or, when they are, no longer having a useful toMSecsSinceEpoch() value). Instead, they don't match what was asked for. Amend documentation to reflect that. Most of the code change for this is to QDTParser and QDTEdit. [ChangeLog][QtCore][QDateTime] Added a TransitionResolution parameter to various QDateTime methods to enable the caller to indicate, when the indicated datetime falls in a time-zone transition, which side of the transition to fall or whether to produce an invalid result. [ChangeLog][QtCore][Possibly Significant Behavior Change] When QDateTime is instantiated for a combination of date and time that was skipped, by local time or a time-zone, for example during a spring-forward DST transition, the result is no longer marked invalid. Whether the selected nearby date-time is before or after the skipped interval may have changed on some platforms; unless overridden by an explicit TransitionResolution, it is now a date-time as long after the previous day's noon as a naive reading of the requested date and time would expect. This was the prior behavior at least on Linux. Fixes: QTBUG-79923 Change-Id: I11d5339abef9e7125c4e0dc95a09a7cd4f169dab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port QDateTimeEdit internals to QTimeZoneEdward Welbourne2022-12-091-85/+100
| | | | | | | | | | | | | | | | | | | | | In the process, centralize the creation of date-time values, where doing so requires catching invalid results caused by spring-forward gaps; this saves some repetition and extends the treatment to more places that did need it. Also, de-inline two overrides of virtuals; being inline does them no good. Replace the Qt::TimeSpec member of QDTEPrivate with a QTimeZone so that creation of values can be streamlined and to make it easier to add support for (currently unsupported) OffsetFromUTC and TimeZone timespecs in the public QDTE API. This greatly simplifies a lot of the code, while preparing it for a long-needed extension to its functionality. Task-number: QTBUG-80417 Task-number: QTBUG-108199 Change-Id: I0ac2c78025013bf89899e3ef1a56e89392f67ce5 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDateTimeEdit: check setDigit()'s return valueEdward Welbourne2022-10-181-4/+4
| | | | | | | | This way we only apply a spring-forward fix when it's relevant. Change-Id: I5fbbb68b6e474566e0497c6ae89d74097570dccc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix a date-time with invalid QTime to use a valid oneEdward Welbourne2022-08-041-1/+1
| | | | | | | | | Using QTime(), which is null and invalid, as the time field of a QDateTime is supported, but is ill-advised. Use the start of the day instead. Change-Id: If30db046218926f7634bbcfcf35cd000d7f6535f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix initialization of QDateEdit and QTimeEditEdward Welbourne2022-08-041-2/+2
| | | | | | | | | | | | Since 6.3 these use Qt::UTC as time-spec but I neglected to take that into account in QDateTimeEditPrivate::init()'s construction of a QDateTime from the QDate or QTime. This amends commit c00ee2f31013e99c79b820a0db57003c110a5510. Fixes: QTBUG-105322 Pick-to: 6.3 6.4 Change-Id: I11dec9808a54cf7da401b1734a9a2812f5fd2e63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix handling of invalid input to Q(Date|Time)Edit constructorsEdward Welbourne2022-08-041-2/+2
| | | | | | | | | | | Change to match how QDateTimeEdit()'s overloads taking a QDate or QTime work, substituting a default value in place of an invalid one. This fixes one surprising anomaly in a recently-extended test, so that it now only fails the way I expected. Task-number: QTBUG-105322 Change-Id: Ied4da6160b7efe70990f956798fb826b5b36d8bb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtWidgets: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-05-021-4/+6
| | | | | | Task-number: QTBUG-98434 Change-Id: I310ea8f19d73a79d985ebfb8bfbff7a02c424360 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-261-3/+3
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I133b80334b66e0a5ab9546dd8e1ff0631e79601e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QStylePainter when painting widgetsMorten Johan Sørvig2022-01-201-2/+3
| | | | | | | | This makes it easier to set global painter options which affect all style painting. Change-Id: I6a38204ed2d874255e92345e6a6a50d27939fb24 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* widgets: Fix typos in source code commentsJonas Kvinge2021-10-151-1/+1
| | | | | | Pick-to: 6.2 Change-Id: I22f71a53b0f7f0698450123343e25548c889c3e2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Use UTC when parsing only a date or only a time, not a date-timeEdward Welbourne2021-06-231-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | This should reduce the amount of fall-out from DST complications. Also document the assumptions of QDateTimeParser's two fromString() methods (and fix the punctuation on the QDateTime parameter). Adjusted some tests to match. Since only QDateTime-returning methods will show the difference, and it's at least somewhat odd to be using those on QDateEdit or QTimeEdit, this should have little impact on API users. [ChangeLog][QtCore][Behavior Change] QDateEdit and QTimeEdit now operate in UTC, to avoid spurious complications arising from time-zone transitions (e.g. DST) causing the implicit other half to combine with the part being edited to make an invalid result. Returns from their dateTime() and other methods returning QDateTime (max/min) shall thus be in UTC where previously they were in local time. QDateTimeEdit continues using local time. The default can be over-ridden by setTimeSpec(), as ever. Change-Id: I44fece004c12342fe536bbe3048217d236fd97b2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix handling of day-of-week in QDateTimeParser and QDateTimeEditEdward Welbourne2021-06-231-7/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDTP's absoluteMax(), setDigit() and getDigit() simply treated day-of-week as synonym for day-of-month. Consequently, QDTE::stepBy() did the same. This meant that wrapping happened at the month boundary, so would jump within the week if it wrapped around, otherwise the up/down arrow would "jam" at a particular day of the week when further steps would leave the month. Instead, when wrapping, wrap round the week while still moving the day-of-month to match, jumping back or forward a week to stay within the month on hitting a month boundary; otherwise, stop backwards stepping on hitting the locale-specific day of the week, or forward stepping when the step would be to or past this first day. Fixed various bugs found in the course of testing this. [ChangeLog][QtWidgets][QDateTimeEdit] Corrected handling of weekdays. Previously, changes to the week-day were simply changes to the day of the month. Weekday fields are now handled as such: changes to them do change the day of the month, but a change that would step past the end (or start) of the month is adjusted to the relevant day of the nearest week within the month. When wrapping is disabled, the locale-specific first and last days of the week are the bounds. Formats which specify day of week but not day of month will now preserve day of week when changing month or year, selecting the nearest day of month that matches. Change-Id: I7868b000fea7a4bc17a1b5687c44bcd56d42ae90 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QDateTime{Parser,EditPrivate}: clean up initializationEdward Welbourne2021-06-031-13/+1
| | | | | | | | Initialize members by assigning them where declared, where possible, rather than duplicating initializations in constructors. Change-Id: I35c398581ad649210aaec979ea7c6c2fc2cb0bca Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Reduce the scope of variable in focusInEvent()Wang Yu2020-12-021-1/+1
| | | | | | | | | The scope of the variable 'frm' can be reduced if the variable 'd->formatExplicitlySet' is true. So declare the variable when the variable 'd->formatExplicitlySet' is false. Change-Id: I27cea412af827d30ad9188106b7f14025e5ddb68 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Eliminate QDateTimeParser's mutable parameters at lastEdward Welbourne2020-09-301-1/+2
| | | | | | | | | | | | | | | | I noticed that QDTP has a mutable member, text, which gets set at the end of each call to parse(); this makes all the in-out parameters redundant, since relevant methods can simply access - and modify - text, if it's set *at the start* of parse instaed. (There are no early returns to complicate matters.) This also makes StateNode::input redundant. At the same time, rename the mutable member, as several methods shadow it with parameter or local variable names; it is too generic. Change-Id: I2259cd87de5c84201b25c9633d11e59a4a4d57a1 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify the preamble of QDateTimeEditPrivate::stepBy()Edward Welbourne2020-09-271-11/+3
| | | | | | | | Repetition and needless complexity: eleven lines rewritten in three. Change-Id: I1dadbbc5329b18d3e25f38f73b69abd2d7aac30d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Fix some qdoc warnings: broken linksVolker Hilsheimer2020-09-211-1/+1
| | | | | | | We can't split a \l{Class::}member over two lines. Change-Id: Id4806402ab349fd20fbf65eee9502e2d08e21dc5 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Document how keyboard tracking can prevent use of a date/time editorEdward Welbourne2020-08-111-9/+52
| | | | | | | | | | | | | This follows up on commit 580e9eedf783ccbdcb67baa3d1a9dcdd53922f86; if the allowed range is narrower than some time interval whose end it straddles, users can only access the later part of the range if keyboard tracking is disabled. Pick-to: 5.15 Task-number: QTBUG-65 Change-Id: Ie8882bd65bda603133abaa82ad83eb1cdd91f175 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Remove usage of QDesktopWidget(Private) from most places in QtWidgetsVolker Hilsheimer2020-07-071-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Call QGuiApplication and QScreen APIs directly to get geometries, and make use of QScreen::grabWindow grabbing the screen it's called on when called with WId == 0. This assumes that QGuiApplication::screen and QWidget::screen never return nullptr, which is already assumed in other places. In QSplashScreen, simplify the code to operate on the screen of the QSplashScreen itself. Remove the case that handles a QDesktopWidget parent - QSplashScreen doesn't have a constructor that takes a QWidget* parent anymore. In the QEffect implementation, we can rely on the widget pointer not being nullptr (it's tested in the free functions client code uses). Includes a few drive-by changes to coding style and logic in qtooltip.cpp, where the tip label placement now prefers the screen of the widget the label is created for, and uses the position only as a fallback. What remains is the special handling of QDesktopWidget and the Qt::Desktop type in QWidget and QApplication. Change-Id: I30b67bab8ae82ddfcc7bbbec3c10f6e935b74f06 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Use qsizetype in QListLars Knoll2020-07-061-2/+2
| | | | | | | | | | | | | | | | | | | | The change creates a slight source incompatibility. The main things to take care of are * code using printf statements on list.size(). Using qsizetype in printf statements will always require a cast to work on both 32 and 64 bit. * A few places where overloads now get ambiguous. One example is QRandomGenerator::bounded() that has overloads for int, uint and double, but not int64. * Streaming list.size() to a QDataStream will change the format depending on the architecture. [ChangeLog][QtCore][QList] QList now uses qsizetype to index into elements. Change-Id: Iaff562a4d072b97f458417b670f95971bd47cbc6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove deprecated QStyleOption::init()Christian Ehrlicher2020-06-211-4/+4
| | | | | | | | Even it was not marked as deprecated the replacement function initFrom() is available since Qt4 times (and init() is deprecated since then) Change-Id: I09a4ebbf66b01fbe7aec67691dc68d2e42d1cd78 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Phase 2 of removing QDesktopWidgetVolker Hilsheimer2020-06-081-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove QDestopWidget public header, simplify the implementation that maintains a Qt::Desktop type QWidget for each QScreen, and turn QWidget's initial target screen into a QScreen pointer. QApplication::desktop() now takes an optional QScreen pointer, and returns a QWidget pointer, so that applications and widgets can get access to the root widget for a specific screen without having to resort to private APIs. QDesktopWidgetPrivate implementations to look up a screen for an index, widget, or point are now all inline functions that thinly wrap QGuiApplication::screens/screenAt calls. We should consider adding those as convenience APIs to QScreen instead. Note that QWidget::screen is assumed to return a valid pointer; there is code that handles the case that it returns nullptr (but also code that trusts that it never is nullptr), so this needs to be defined, verified with tests, and asserted. We can then simplify the code further. Change-Id: Ifc89be65a0dce265b6729feaf54121c35137cb94 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Replace calls to deprecated QEvent accessor functionsShawn Rutledge2020-06-081-2/+2
| | | | | | | Many of these were generated by clazy using the new qevent-accessors check. Change-Id: Ie17af17f50fdc9f47d7859d267c14568cc350fd0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make qtbase compile without QT_CONFIG(timezone)Andrei Golubev2020-05-111-1/+4
| | | | | | | | Fixes: QTBUG-83795 Pick-to: 5.15 Change-Id: I05eaaf57d87a9111d3609ebab81bc707f8af98f0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove dead code from src/widgetsVolker Hilsheimer2020-05-111-9/+0
| | | | | | | | Code that's removed via QT_VERSION(6, 0, 0) check is already no longer compiled. Change-Id: I70865f330a6260ac2e9cf2770d599a5b6f7bb7d4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-231-0/+7
|\ | | | | | | Change-Id: Iaa439ba7dff19a17e3716b3d30f49f60fa6e38f8
| * Handle specified time-spec in date-time parsingAndrei Golubev2020-04-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a date-time was parsed from a string, the result was equal (as a date-time) to the correct value, but had (at least in some cases) the wrong spec, where it should have had a spec reflecting the zone specifier parsed. The time-spec imposed for the benefit of QDateTimeEdit is now moved from QDateTimeParser to QDateTimeEditPrivate, which takes over responsibility for imposing it. QDateTimeParser assumes Qt::LocalTime in member functions (where applicable) and uses the time-spec parsed from the string when constructing the date-time. QDateTime::fromString() and QLocale::toDateTime() are updated to use the full QDateTime returned by QDateTimeParser. Fixes: QTBUG-83075 Done-With: Edward Welbourne <edward.welbourne@qt.io> Change-Id: I8b79add2c7fc13a200e1252d48dbfa70b36757bf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QApplication: remove obsolete globalStrut functionalityVolker Hilsheimer2020-04-101-2/+1
| | | | | | | | | | | | Change-Id: If56873f86f5291264cac720f8db7dbd4db756f49 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devSimon Hausmann2020-03-161-2/+0
|\| | | | | | | | | | | | | Conflicts: src/corelib/kernel/qmetatype.cpp Change-Id: I88eb0d3e9c9a38abf7241a51e370c655ae74e38a
| * Doc: Remove incorrect see-also linkTopi Reinio2020-03-121-2/+0
| | | | | | | | | | | | | | | | The link is actually a self-reference; setCurrentSection() is setter for the currentSection property, and has no dedicated documentation. Change-Id: I4977650566913c590d46aede92d8678b7b7ea291 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devLars Knoll2020-02-281-5/+26
|\| | | | | | | Change-Id: I469b0501cc65fc5ce4d797a69ae89405cc69c7f8
| * Merge "Merge remote-tracking branch 'origin/5.14' into 5.15"Lars Knoll2020-02-271-4/+5
| |\
| | * Merge remote-tracking branch 'origin/5.14' into 5.15Lars Knoll2020-02-271-4/+5
| | |\ | | | | | | | | | | | | Change-Id: I4212d070d5752275085e754b96f0392113604dba
| | | * Documentation: correctly use see-also tags to link to related membersVolker Hilsheimer2020-02-261-4/+5
| | | | | | | | | | | | | | | | | | | | Change-Id: I764eb4730067cd704866191516dc4e8dd1820760 Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
| * | | Fix QDateTimeEdit's handling of invalid time in dst gapVolker Hilsheimer2020-02-271-1/+21
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During a spring forward, a time-zone omits an hour. A QDateTime with such an hour is invalid, but QDateTimeEdit's handling of this invalid time was not done correctly. With this fix, up/down changes of any field that would result in an invalid date-time corrects the time to be valid, while leaving as much as possible of the user-entered data unchanged. To do that, we rely on QDateTime::toMSecsSinceEpoch to return a value even for such an invalid time, which then can be used to construct a valid QDateTime. Edits that would result in an invalid hour are reverted to the previous when pressing return, if correctionMode is CorrectToPreviousValue. This change also implements support for CorrectToNearestValue, which uses the same mechanism as when stepping over an invalid time. Include a test that verifies that the various interactions result in a reasonable value. Since QDateTimeEdit does not respect the timezone or timespec of the QDateTime it is initialized with, we have to find the first hour of daylight saving time for a year that we know works for most time zones. Failing that, we have to skip the tests. Verified in a wide range of time zones. Change-Id: I05b906ae3b5f6681891d23704f00f9c10cd479ae Fixes: QTBUG-79803 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Pass QDate and QTime as value classesEdward Welbourne2020-02-271-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | It's what they are, so const refs are needless burden. In the process, consolidate two of the affected methods (one of which just adds another argument to the other's signature) into one. Change-Id: I80de35ffe078a652d1999889dede0b10302abaa9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-281-12/+20
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsettings.cpp src/corelib/kernel/qvariant.cpp src/corelib/serialization/qjsoncbor.cpp src/corelib/serialization/qjsonvalue.cpp src/corelib/tools/tools.pri src/gui/image/qimage.cpp src/gui/kernel/qguivariant.cpp src/widgets/kernel/qshortcut.cpp tests/auto/tools/moc/allmocs_baseline_in.json tests/auto/tools/moc/tst_moc.cpp src/opengl/qglframebufferobject.cpp Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Leander Beernaert <leander.beernaert@qt.io> Change-Id: Ie7f5fa646c607fe70c314bf7195f7578ded1d271
| * | Replace most use of QVariant::type and occurrences of QVariant::TypeOlivier Goffart2020-01-231-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-131-16/+17
|\| | | | | | | | | | | | | | | | | | | | Conflicts: tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp Change-Id: I4d3041fa291a918c774ffa5eb5c8792a0966451d
| * | Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2020-01-091-16/+17
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/kernel/qobject.cpp Change-Id: I4780b25665672692b086ee92092e506c814642f2
| | * Doc: Correct qdoc compilation errors qtbaseNico Vertriest2020-01-091-16/+17
| | | | | | | | | | | | | | | | | | Task-number: QTBUG-79824 Change-Id: I4be365d92b1adfde09efd04d088f75c506666a95 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-01-071-4/+3
|\| | | | | | | | | | | Change-Id: Ia2ce994c42adc010c453edaeea57f672556958f6
| * | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-061-4/+3
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/kernel/qvariant.h Change-Id: I8f3873e74b9795ac889e7c7ec5de2619bca92160