Merge remote-tracking branch 'origin/5.14' into dev
Change-Id: I525112b5afbbe8f7fbb54da527bddb94a0c2c242
This commit is contained in:
commit
a2a4c3a5ff
@ -205,7 +205,6 @@ Build environment:
|
|||||||
[$ANDROID_NDK_HOST]
|
[$ANDROID_NDK_HOST]
|
||||||
-android-abis ....... Comma separated Android abis, default is:
|
-android-abis ....... Comma separated Android abis, default is:
|
||||||
armeabi-v7a,arm64-v8a,x86,x86_64
|
armeabi-v7a,arm64-v8a,x86,x86_64
|
||||||
-android-toolchain-version ... Set Android toolchain version
|
|
||||||
-android-style-assets Automatically extract style assets from the device at
|
-android-style-assets Automatically extract style assets from the device at
|
||||||
run time. This option makes the Android style behave
|
run time. This option makes the Android style behave
|
||||||
correctly, but also makes the Android platform plugin
|
correctly, but also makes the Android platform plugin
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
"android-ndk-host": "string",
|
"android-ndk-host": "string",
|
||||||
"android-ndk-platform": "string",
|
"android-ndk-platform": "string",
|
||||||
"android-sdk": "string",
|
"android-sdk": "string",
|
||||||
"android-toolchain-version": "string",
|
|
||||||
|
|
||||||
"android-style-assets": "boolean",
|
"android-style-assets": "boolean",
|
||||||
"appstore-compliant": "boolean",
|
"appstore-compliant": "boolean",
|
||||||
|
@ -573,14 +573,7 @@ defineTest(qtConfOutput_prepareOptions) {
|
|||||||
qtConfFatalError("Cannot find Android NDK." \
|
qtConfFatalError("Cannot find Android NDK." \
|
||||||
"Please use -android-ndk option to specify one.")
|
"Please use -android-ndk option to specify one.")
|
||||||
|
|
||||||
ndk_tc_ver = $$eval(config.input.android-toolchain-version)
|
ndk_tc_pfx = $$ndk_root/toolchains/llvm/prebuilt
|
||||||
isEmpty(ndk_tc_ver): \
|
|
||||||
ndk_tc_ver = 4.9
|
|
||||||
!exists($$ndk_root/toolchains/arm-linux-androideabi-$$ndk_tc_ver/prebuilt/*): \
|
|
||||||
qtConfFatalError("Cannot detect Android NDK toolchain." \
|
|
||||||
"Please use -android-toolchain-version to specify it.")
|
|
||||||
|
|
||||||
ndk_tc_pfx = $$ndk_root/toolchains/arm-linux-androideabi-$$ndk_tc_ver/prebuilt
|
|
||||||
ndk_host = $$eval(config.input.android-ndk-host)
|
ndk_host = $$eval(config.input.android-ndk-host)
|
||||||
isEmpty(ndk_host): \
|
isEmpty(ndk_host): \
|
||||||
ndk_host = $$getenv(ANDROID_NDK_HOST)
|
ndk_host = $$getenv(ANDROID_NDK_HOST)
|
||||||
@ -632,8 +625,7 @@ defineTest(qtConfOutput_prepareOptions) {
|
|||||||
"DEFAULT_ANDROID_NDK_ROOT = $$val_escape(ndk_root)" \
|
"DEFAULT_ANDROID_NDK_ROOT = $$val_escape(ndk_root)" \
|
||||||
"DEFAULT_ANDROID_PLATFORM = $$platform" \
|
"DEFAULT_ANDROID_PLATFORM = $$platform" \
|
||||||
"DEFAULT_ANDROID_NDK_HOST = $$ndk_host" \
|
"DEFAULT_ANDROID_NDK_HOST = $$ndk_host" \
|
||||||
"DEFAULT_ANDROID_ABIS = $$split(android_abis, ',')" \
|
"DEFAULT_ANDROID_ABIS = $$split(android_abis, ',')"
|
||||||
"DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION = $$ndk_tc_ver"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export($${currentConfig}.output.devicePro)
|
export($${currentConfig}.output.devicePro)
|
||||||
|
@ -71,4 +71,3 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-embedded {
|
|||||||
|
|
||||||
write_file($$ANDROID_DEPLOYMENT_SETTINGS_FILE, FILE_CONTENT)|error()
|
write_file($$ANDROID_DEPLOYMENT_SETTINGS_FILE, FILE_CONTENT)|error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,19 +310,6 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request)
|
|||||||
\sa QDir, QFile
|
\sa QDir, QFile
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\enum QFileInfo::FileType
|
|
||||||
|
|
||||||
This enum is returned by type() to describe the type of the file system
|
|
||||||
entity described by the QFileInfo object.
|
|
||||||
|
|
||||||
\value Unknown The object refers to an unknown item.
|
|
||||||
\value Regular The object refers to a regular file.
|
|
||||||
\value Directory The object refers to a directory.
|
|
||||||
\value SymbolicLink The object refers to a symbolic link.
|
|
||||||
\value Shortcut The object refers to a shortcut.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QFileInfo &QFileInfo::operator=(QFileInfo &&other)
|
\fn QFileInfo &QFileInfo::operator=(QFileInfo &&other)
|
||||||
|
|
||||||
@ -1008,7 +995,11 @@ bool QFileInfo::isNativePath() const
|
|||||||
*/
|
*/
|
||||||
bool QFileInfo::isFile() const
|
bool QFileInfo::isFile() const
|
||||||
{
|
{
|
||||||
return (type() & FileTypeMask) == Regular;
|
Q_D(const QFileInfo);
|
||||||
|
return d->checkAttribute<bool>(
|
||||||
|
QFileSystemMetaData::FileType,
|
||||||
|
[d]() { return d->metaData.isFile(); },
|
||||||
|
[d]() { return d->getFileFlags(QAbstractFileEngine::FileType); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1019,7 +1010,11 @@ bool QFileInfo::isFile() const
|
|||||||
*/
|
*/
|
||||||
bool QFileInfo::isDir() const
|
bool QFileInfo::isDir() const
|
||||||
{
|
{
|
||||||
return (type() & FileTypeMask) == Directory;
|
Q_D(const QFileInfo);
|
||||||
|
return d->checkAttribute<bool>(
|
||||||
|
QFileSystemMetaData::DirectoryType,
|
||||||
|
[d]() { return d->metaData.isDirectory(); },
|
||||||
|
[d]() { return d->getFileFlags(QAbstractFileEngine::DirectoryType); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1070,8 +1065,6 @@ bool QFileInfo::isSymLink() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn bool QFileInfo::isSymbolicLink() const
|
|
||||||
|
|
||||||
Returns \c true if this object points to a symbolic link;
|
Returns \c true if this object points to a symbolic link;
|
||||||
otherwise returns \c false.
|
otherwise returns \c false.
|
||||||
|
|
||||||
@ -1091,9 +1084,16 @@ bool QFileInfo::isSymLink() const
|
|||||||
\sa isFile(), isDir(), isShortcut(), symLinkTarget()
|
\sa isFile(), isDir(), isShortcut(), symLinkTarget()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
bool QFileInfo::isSymbolicLink() const
|
||||||
\fn bool QFileInfo::isShortcut() const
|
{
|
||||||
|
Q_D(const QFileInfo);
|
||||||
|
return d->checkAttribute<bool>(
|
||||||
|
QFileSystemMetaData::LegacyLinkType,
|
||||||
|
[d]() { return d->metaData.isLink(); },
|
||||||
|
[d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); });
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
Returns \c true if this object points to a shortcut;
|
Returns \c true if this object points to a shortcut;
|
||||||
otherwise returns \c false.
|
otherwise returns \c false.
|
||||||
|
|
||||||
@ -1110,6 +1110,14 @@ bool QFileInfo::isSymLink() const
|
|||||||
|
|
||||||
\sa isFile(), isDir(), isSymbolicLink(), symLinkTarget()
|
\sa isFile(), isDir(), isSymbolicLink(), symLinkTarget()
|
||||||
*/
|
*/
|
||||||
|
bool QFileInfo::isShortcut() const
|
||||||
|
{
|
||||||
|
Q_D(const QFileInfo);
|
||||||
|
return d->checkAttribute<bool>(
|
||||||
|
QFileSystemMetaData::LegacyLinkType,
|
||||||
|
[d]() { return d->metaData.isLnkFile(); },
|
||||||
|
[d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); });
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns \c true if the object points to a directory or to a symbolic
|
Returns \c true if the object points to a directory or to a symbolic
|
||||||
@ -1314,53 +1322,6 @@ qint64 QFileInfo::size() const
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the QFileInfo::FileTypes.
|
|
||||||
|
|
||||||
QFileInfo::FileTypes combines with an indirection flag (link type) and a
|
|
||||||
base type it refers to.
|
|
||||||
|
|
||||||
For example, \c SymbolicLink combines with \c Regular meaning a symlink to
|
|
||||||
a regular file.
|
|
||||||
|
|
||||||
In addition, FileTypeMask and LinkTypeMask are used to extract the base
|
|
||||||
type and link type respectively.
|
|
||||||
|
|
||||||
\sa isFile(), isDir(), isShortcut(), isSymbolicLink()
|
|
||||||
*/
|
|
||||||
QFileInfo::FileTypes QFileInfo::type() const
|
|
||||||
{
|
|
||||||
Q_D(const QFileInfo);
|
|
||||||
|
|
||||||
QFileInfo::FileTypes type = QFileInfo::Unknown;
|
|
||||||
if (d->checkAttribute<bool>(
|
|
||||||
QFileSystemMetaData::LegacyLinkType,
|
|
||||||
[d]() { return d->metaData.isLnkFile(); },
|
|
||||||
[d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); })) {
|
|
||||||
type = QFileInfo::Shortcut;
|
|
||||||
} else if (d->checkAttribute<bool>(
|
|
||||||
QFileSystemMetaData::LegacyLinkType,
|
|
||||||
[d]() { return d->metaData.isLink(); },
|
|
||||||
[d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); })) {
|
|
||||||
type = QFileInfo::SymbolicLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->checkAttribute<bool>(
|
|
||||||
QFileSystemMetaData::DirectoryType,
|
|
||||||
[d]() { return d->metaData.isDirectory(); },
|
|
||||||
[d]() { return d->getFileFlags(QAbstractFileEngine::DirectoryType); })) {
|
|
||||||
return type | QFileInfo::Directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->checkAttribute<bool>(
|
|
||||||
QFileSystemMetaData::FileType,
|
|
||||||
[d]() { return d->metaData.isFile(); },
|
|
||||||
[d]() { return d->getFileFlags(QAbstractFileEngine::FileType); })) {
|
|
||||||
return type | QFileInfo::Regular;
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if QT_DEPRECATED_SINCE(5, 10)
|
#if QT_DEPRECATED_SINCE(5, 10)
|
||||||
/*!
|
/*!
|
||||||
\deprecated
|
\deprecated
|
||||||
|
@ -66,20 +66,6 @@ public:
|
|||||||
QFileInfo(const QFileInfo &fileinfo);
|
QFileInfo(const QFileInfo &fileinfo);
|
||||||
~QFileInfo();
|
~QFileInfo();
|
||||||
|
|
||||||
enum FileType {
|
|
||||||
Unknown,
|
|
||||||
// base type
|
|
||||||
Regular,
|
|
||||||
Directory,
|
|
||||||
// indirection flag
|
|
||||||
SymbolicLink = 0x10,
|
|
||||||
Shortcut = 0x20,
|
|
||||||
// mask
|
|
||||||
FileTypeMask = 0x0f,
|
|
||||||
LinkTypeMask = 0xf0
|
|
||||||
};
|
|
||||||
Q_DECLARE_FLAGS(FileTypes, FileType)
|
|
||||||
|
|
||||||
QFileInfo &operator=(const QFileInfo &fileinfo);
|
QFileInfo &operator=(const QFileInfo &fileinfo);
|
||||||
QFileInfo &operator=(QFileInfo &&other) noexcept { swap(other); return *this; }
|
QFileInfo &operator=(QFileInfo &&other) noexcept { swap(other); return *this; }
|
||||||
|
|
||||||
@ -125,8 +111,8 @@ public:
|
|||||||
bool isFile() const;
|
bool isFile() const;
|
||||||
bool isDir() const;
|
bool isDir() const;
|
||||||
bool isSymLink() const;
|
bool isSymLink() const;
|
||||||
inline bool isSymbolicLink() const { return type() & SymbolicLink; }
|
bool isSymbolicLink() const;
|
||||||
inline bool isShortcut() const { return type() & Shortcut; }
|
bool isShortcut() const;
|
||||||
bool isRoot() const;
|
bool isRoot() const;
|
||||||
bool isBundle() const;
|
bool isBundle() const;
|
||||||
|
|
||||||
@ -145,7 +131,6 @@ public:
|
|||||||
QFile::Permissions permissions() const;
|
QFile::Permissions permissions() const;
|
||||||
|
|
||||||
qint64 size() const;
|
qint64 size() const;
|
||||||
FileTypes type() const;
|
|
||||||
|
|
||||||
// ### Qt6: inline these functions
|
// ### Qt6: inline these functions
|
||||||
#if QT_DEPRECATED_SINCE(5, 10)
|
#if QT_DEPRECATED_SINCE(5, 10)
|
||||||
|
@ -116,8 +116,8 @@ struct QSystemLocalePrivate
|
|||||||
QVariant dateTimeFormat(QLocale::FormatType);
|
QVariant dateTimeFormat(QLocale::FormatType);
|
||||||
QVariant dayName(int, QLocale::FormatType);
|
QVariant dayName(int, QLocale::FormatType);
|
||||||
QVariant monthName(int, QLocale::FormatType);
|
QVariant monthName(int, QLocale::FormatType);
|
||||||
QVariant toString(const QDate &, QLocale::FormatType);
|
QVariant toString(QDate, QLocale::FormatType);
|
||||||
QVariant toString(const QTime &, QLocale::FormatType);
|
QVariant toString(QTime, QLocale::FormatType);
|
||||||
QVariant toString(const QDateTime &, QLocale::FormatType);
|
QVariant toString(const QDateTime &, QLocale::FormatType);
|
||||||
QVariant measurementSystem();
|
QVariant measurementSystem();
|
||||||
QVariant collation();
|
QVariant collation();
|
||||||
@ -394,7 +394,7 @@ QVariant QSystemLocalePrivate::monthName(int month, QLocale::FormatType type)
|
|||||||
return getLocaleInfo(lctype);
|
return getLocaleInfo(lctype);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QSystemLocalePrivate::toString(const QDate &date, QLocale::FormatType type)
|
QVariant QSystemLocalePrivate::toString(QDate date, QLocale::FormatType type)
|
||||||
{
|
{
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
memset(&st, 0, sizeof(SYSTEMTIME));
|
memset(&st, 0, sizeof(SYSTEMTIME));
|
||||||
@ -413,7 +413,7 @@ QVariant QSystemLocalePrivate::toString(const QDate &date, QLocale::FormatType t
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QSystemLocalePrivate::toString(const QTime &time, QLocale::FormatType type)
|
QVariant QSystemLocalePrivate::toString(QTime time, QLocale::FormatType type)
|
||||||
{
|
{
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
memset(&st, 0, sizeof(SYSTEMTIME));
|
memset(&st, 0, sizeof(SYSTEMTIME));
|
||||||
|
@ -810,7 +810,7 @@ bool QCalendar::isLuniSolar() const
|
|||||||
/*!
|
/*!
|
||||||
Returns \c true if this calendar is solar.
|
Returns \c true if this calendar is solar.
|
||||||
|
|
||||||
A solar calendar is based primaril on the Sun's varying position in the sky,
|
A solar calendar is based primarily on the Sun's varying position in the sky,
|
||||||
relative to the fixed stars.
|
relative to the fixed stars.
|
||||||
*/
|
*/
|
||||||
bool QCalendar::isSolar() const
|
bool QCalendar::isSolar() const
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "qcalendar.h"
|
#include "qcalendar.h"
|
||||||
|
#include "qgregoriancalendar_p.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -105,6 +106,17 @@ static inline QDate fixedDate(QCalendar::YearMonthDay &&parts, QCalendar cal)
|
|||||||
return cal.dateFromParts(parts);
|
return cal.dateFromParts(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline QDate fixedDate(QCalendar::YearMonthDay &&parts)
|
||||||
|
{
|
||||||
|
if (parts.year) {
|
||||||
|
parts.day = qMin(parts.day, QGregorianCalendar::monthLength(parts.month, parts.year));
|
||||||
|
qint64 jd;
|
||||||
|
if (QGregorianCalendar::julianFromParts(parts.year, parts.month, parts.day, &jd))
|
||||||
|
return QDate::fromJulianDay(jd);
|
||||||
|
}
|
||||||
|
return QDate();
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
Date/Time formatting helper functions
|
Date/Time formatting helper functions
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -340,7 +352,8 @@ static int fromOffsetString(const QStringRef &offsetString, bool *valid) noexcep
|
|||||||
|
|
||||||
QDate::QDate(int y, int m, int d)
|
QDate::QDate(int y, int m, int d)
|
||||||
{
|
{
|
||||||
*this = QCalendar().dateFromParts(y, m, d);
|
if (!QGregorianCalendar::julianFromParts(y, m, d, &jd))
|
||||||
|
jd = nullJd();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDate::QDate(int y, int m, int d, QCalendar cal)
|
QDate::QDate(int y, int m, int d, QCalendar cal)
|
||||||
@ -405,7 +418,12 @@ int QDate::year(QCalendar cal) const
|
|||||||
|
|
||||||
int QDate::year() const
|
int QDate::year() const
|
||||||
{
|
{
|
||||||
return year(QCalendar());
|
if (isValid()) {
|
||||||
|
const auto parts = QGregorianCalendar::partsFromJulian(jd);
|
||||||
|
if (parts.isValid())
|
||||||
|
return parts.year;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -452,7 +470,12 @@ int QDate::month(QCalendar cal) const
|
|||||||
|
|
||||||
int QDate::month() const
|
int QDate::month() const
|
||||||
{
|
{
|
||||||
return month(QCalendar());
|
if (isValid()) {
|
||||||
|
const auto parts = QGregorianCalendar::partsFromJulian(jd);
|
||||||
|
if (parts.isValid())
|
||||||
|
return parts.month;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -480,7 +503,12 @@ int QDate::day(QCalendar cal) const
|
|||||||
|
|
||||||
int QDate::day() const
|
int QDate::day() const
|
||||||
{
|
{
|
||||||
return day(QCalendar());
|
if (isValid()) {
|
||||||
|
const auto parts = QGregorianCalendar::partsFromJulian(jd);
|
||||||
|
if (parts.isValid())
|
||||||
|
return parts.day;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -507,7 +535,7 @@ int QDate::dayOfWeek(QCalendar cal) const
|
|||||||
|
|
||||||
int QDate::dayOfWeek() const
|
int QDate::dayOfWeek() const
|
||||||
{
|
{
|
||||||
return dayOfWeek(QCalendar());
|
return isValid() ? QGregorianCalendar::weekDayOfJulian(jd) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -535,7 +563,12 @@ int QDate::dayOfYear(QCalendar cal) const
|
|||||||
|
|
||||||
int QDate::dayOfYear() const
|
int QDate::dayOfYear() const
|
||||||
{
|
{
|
||||||
return dayOfYear(QCalendar());
|
if (isValid()) {
|
||||||
|
qint64 first;
|
||||||
|
if (QGregorianCalendar::julianFromParts(year(), 1, 1, &first))
|
||||||
|
return jd - first + 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -563,7 +596,12 @@ int QDate::daysInMonth(QCalendar cal) const
|
|||||||
|
|
||||||
int QDate::daysInMonth() const
|
int QDate::daysInMonth() const
|
||||||
{
|
{
|
||||||
return daysInMonth(QCalendar());
|
if (isValid()) {
|
||||||
|
const auto parts = QGregorianCalendar::partsFromJulian(jd);
|
||||||
|
if (parts.isValid())
|
||||||
|
return QGregorianCalendar::monthLength(parts.month, parts.year);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -589,7 +627,7 @@ int QDate::daysInYear(QCalendar cal) const
|
|||||||
|
|
||||||
int QDate::daysInYear() const
|
int QDate::daysInYear() const
|
||||||
{
|
{
|
||||||
return daysInYear(QCalendar());
|
return isValid() ? QGregorianCalendar::leapTest(year()) ? 366 : 365 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1303,7 +1341,11 @@ QString QDate::toString(const QString &format, QCalendar cal) const
|
|||||||
*/
|
*/
|
||||||
bool QDate::setDate(int year, int month, int day)
|
bool QDate::setDate(int year, int month, int day)
|
||||||
{
|
{
|
||||||
return setDate(year, month, day, QCalendar());
|
if (QGregorianCalendar::julianFromParts(year, month, day, &jd))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
jd = nullJd();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1339,7 +1381,7 @@ void QDate::getDate(int *year, int *month, int *day) const
|
|||||||
{
|
{
|
||||||
QCalendar::YearMonthDay parts; // invalid by default
|
QCalendar::YearMonthDay parts; // invalid by default
|
||||||
if (isValid())
|
if (isValid())
|
||||||
parts = QCalendar().partsFromDate(*this);
|
parts = QGregorianCalendar::partsFromJulian(jd);
|
||||||
|
|
||||||
const bool ok = parts.isValid();
|
const bool ok = parts.isValid();
|
||||||
if (year)
|
if (year)
|
||||||
@ -1428,7 +1470,30 @@ QDate QDate::addMonths(int nmonths, QCalendar cal) const
|
|||||||
|
|
||||||
QDate QDate::addMonths(int nmonths) const
|
QDate QDate::addMonths(int nmonths) const
|
||||||
{
|
{
|
||||||
return addMonths(nmonths, QCalendar());
|
if (isNull())
|
||||||
|
return QDate();
|
||||||
|
|
||||||
|
if (nmonths == 0)
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
auto parts = QGregorianCalendar::partsFromJulian(jd);
|
||||||
|
|
||||||
|
if (!parts.isValid())
|
||||||
|
return QDate();
|
||||||
|
Q_ASSERT(parts.year);
|
||||||
|
|
||||||
|
parts.month += nmonths;
|
||||||
|
while (parts.month <= 0) {
|
||||||
|
if (--parts.year) // skip over year 0
|
||||||
|
parts.month += 12;
|
||||||
|
}
|
||||||
|
while (parts.month > 12) {
|
||||||
|
parts.month -= 12;
|
||||||
|
if (!++parts.year) // skip over year 0
|
||||||
|
++parts.year;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fixedDate(std::move(parts));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1470,7 +1535,21 @@ QDate QDate::addYears(int nyears, QCalendar cal) const
|
|||||||
|
|
||||||
QDate QDate::addYears(int nyears) const
|
QDate QDate::addYears(int nyears) const
|
||||||
{
|
{
|
||||||
return addYears(nyears, QCalendar());
|
if (isNull())
|
||||||
|
return QDate();
|
||||||
|
|
||||||
|
auto parts = QGregorianCalendar::partsFromJulian(jd);
|
||||||
|
if (!parts.isValid())
|
||||||
|
return QDate();
|
||||||
|
|
||||||
|
int old_y = parts.year;
|
||||||
|
parts.year += nyears;
|
||||||
|
|
||||||
|
// If we just crossed (or hit) a missing year zero, adjust year by +/- 1:
|
||||||
|
if ((old_y > 0) != (parts.year > 0) || !parts.year)
|
||||||
|
parts.year += nyears > 0 ? +1 : -1;
|
||||||
|
|
||||||
|
return fixedDate(std::move(parts));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1719,7 +1798,7 @@ QDate QDate::fromString(const QString &string, const QString &format)
|
|||||||
|
|
||||||
bool QDate::isValid(int year, int month, int day)
|
bool QDate::isValid(int year, int month, int day)
|
||||||
{
|
{
|
||||||
return QCalendar().isDateValid(year, month, day);
|
return QGregorianCalendar::validParts(year, month, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1733,7 +1812,7 @@ bool QDate::isValid(int year, int month, int day)
|
|||||||
|
|
||||||
bool QDate::isLeapYear(int y)
|
bool QDate::isLeapYear(int y)
|
||||||
{
|
{
|
||||||
return QCalendar().isLeapYear(y);
|
return QGregorianCalendar::leapTest(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \fn static QDate QDate::fromJulianDay(qint64 jd)
|
/*! \fn static QDate QDate::fromJulianDay(qint64 jd)
|
||||||
|
@ -58,7 +58,7 @@ class QCalendar;
|
|||||||
class QTimeZone;
|
class QTimeZone;
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
|
|
||||||
class Q_CORE_EXPORT QDate
|
class Q_CORE_EXPORT QDate // ### Qt 6: change to be used by value, not const &
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum MonthNameType { // ### Qt 6: remove, along with methods using it
|
enum MonthNameType { // ### Qt 6: remove, along with methods using it
|
||||||
@ -138,7 +138,7 @@ public:
|
|||||||
Q_REQUIRED_RESULT QDate addYears(int years) const;
|
Q_REQUIRED_RESULT QDate addYears(int years) const;
|
||||||
Q_REQUIRED_RESULT QDate addMonths(int months, QCalendar cal) const;
|
Q_REQUIRED_RESULT QDate addMonths(int months, QCalendar cal) const;
|
||||||
Q_REQUIRED_RESULT QDate addYears(int years, QCalendar cal) const;
|
Q_REQUIRED_RESULT QDate addYears(int years, QCalendar cal) const;
|
||||||
qint64 daysTo(const QDate &) const;
|
qint64 daysTo(const QDate &) const; // ### Qt 6: QDate
|
||||||
|
|
||||||
Q_DECL_CONSTEXPR bool operator==(const QDate &other) const { return jd == other.jd; }
|
Q_DECL_CONSTEXPR bool operator==(const QDate &other) const { return jd == other.jd; }
|
||||||
Q_DECL_CONSTEXPR bool operator!=(const QDate &other) const { return jd != other.jd; }
|
Q_DECL_CONSTEXPR bool operator!=(const QDate &other) const { return jd != other.jd; }
|
||||||
@ -177,7 +177,7 @@ private:
|
|||||||
};
|
};
|
||||||
Q_DECLARE_TYPEINFO(QDate, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QDate, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
class Q_CORE_EXPORT QTime
|
class Q_CORE_EXPORT QTime // ### Qt 6: change to be used by value, not const &
|
||||||
{
|
{
|
||||||
explicit Q_DECL_CONSTEXPR QTime(int ms) : mds(ms)
|
explicit Q_DECL_CONSTEXPR QTime(int ms) : mds(ms)
|
||||||
{}
|
{}
|
||||||
@ -203,9 +203,9 @@ public:
|
|||||||
bool setHMS(int h, int m, int s, int ms = 0);
|
bool setHMS(int h, int m, int s, int ms = 0);
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QTime addSecs(int secs) const;
|
Q_REQUIRED_RESULT QTime addSecs(int secs) const;
|
||||||
int secsTo(const QTime &) const;
|
int secsTo(const QTime &) const; // ### Qt 6: plain QTime
|
||||||
Q_REQUIRED_RESULT QTime addMSecs(int ms) const;
|
Q_REQUIRED_RESULT QTime addMSecs(int ms) const;
|
||||||
int msecsTo(const QTime &) const;
|
int msecsTo(const QTime &) const; // ### Qt 6: plain QTime
|
||||||
|
|
||||||
Q_DECL_CONSTEXPR bool operator==(const QTime &other) const { return mds == other.mds; }
|
Q_DECL_CONSTEXPR bool operator==(const QTime &other) const { return mds == other.mds; }
|
||||||
Q_DECL_CONSTEXPR bool operator!=(const QTime &other) const { return mds != other.mds; }
|
Q_DECL_CONSTEXPR bool operator!=(const QTime &other) const { return mds != other.mds; }
|
||||||
@ -236,7 +236,7 @@ private:
|
|||||||
|
|
||||||
friend class QDateTime;
|
friend class QDateTime;
|
||||||
friend class QDateTimePrivate;
|
friend class QDateTimePrivate;
|
||||||
#ifndef QT_NO_DATASTREAM
|
#ifndef QT_NO_DATASTREAM // ### Qt 6: plain QTime
|
||||||
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QTime &);
|
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QTime &);
|
||||||
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QTime &);
|
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QTime &);
|
||||||
#endif
|
#endif
|
||||||
@ -287,7 +287,7 @@ class Q_CORE_EXPORT QDateTime
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QDateTime() noexcept(Data::CanBeSmall);
|
QDateTime() noexcept(Data::CanBeSmall);
|
||||||
explicit QDateTime(const QDate &);
|
explicit QDateTime(const QDate &); // ### Qt 6: plain QDate, QTime
|
||||||
QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime);
|
QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime);
|
||||||
// ### Qt 6: Merge with above with default offsetSeconds = 0
|
// ### Qt 6: Merge with above with default offsetSeconds = 0
|
||||||
QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds);
|
QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds);
|
||||||
@ -319,7 +319,7 @@ public:
|
|||||||
qint64 toMSecsSinceEpoch() const;
|
qint64 toMSecsSinceEpoch() const;
|
||||||
qint64 toSecsSinceEpoch() const;
|
qint64 toSecsSinceEpoch() const;
|
||||||
|
|
||||||
void setDate(const QDate &date);
|
void setDate(const QDate &date); // ### Qt 6: plain QDate
|
||||||
void setTime(const QTime &time);
|
void setTime(const QTime &time);
|
||||||
void setTimeSpec(Qt::TimeSpec spec);
|
void setTimeSpec(Qt::TimeSpec spec);
|
||||||
void setOffsetFromUtc(int offsetSeconds);
|
void setOffsetFromUtc(int offsetSeconds);
|
||||||
|
@ -60,6 +60,9 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using ShortVector = QVarLengthArray<T, 13>; // enough for month (incl. leap) and day-of-week names
|
||||||
|
|
||||||
QDateTimeParser::~QDateTimeParser()
|
QDateTimeParser::~QDateTimeParser()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -1538,7 +1541,7 @@ QDateTimeParser::parse(QString input, int position, const QDateTime &defaultValu
|
|||||||
length of overlap in *used (if \a used is non-NULL) and the first entry that
|
length of overlap in *used (if \a used is non-NULL) and the first entry that
|
||||||
overlapped this much in *usedText (if \a usedText is non-NULL).
|
overlapped this much in *usedText (if \a usedText is non-NULL).
|
||||||
*/
|
*/
|
||||||
static int findTextEntry(const QString &text, const QVector<QString> &entries, QString *usedText, int *used)
|
static int findTextEntry(const QString &text, const ShortVector<QString> &entries, QString *usedText, int *used)
|
||||||
{
|
{
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
return -1;
|
return -1;
|
||||||
@ -1586,7 +1589,7 @@ int QDateTimeParser::findMonth(const QString &str1, int startMonth, int sectionI
|
|||||||
|
|
||||||
QLocale::FormatType type = sn.count == 3 ? QLocale::ShortFormat : QLocale::LongFormat;
|
QLocale::FormatType type = sn.count == 3 ? QLocale::ShortFormat : QLocale::LongFormat;
|
||||||
QLocale l = locale();
|
QLocale l = locale();
|
||||||
QVector<QString> monthNames;
|
ShortVector<QString> monthNames;
|
||||||
monthNames.reserve(13 - startMonth);
|
monthNames.reserve(13 - startMonth);
|
||||||
for (int month = startMonth; month <= 12; ++month)
|
for (int month = startMonth; month <= 12; ++month)
|
||||||
monthNames.append(calendar.monthName(l, month, year, type));
|
monthNames.append(calendar.monthName(l, month, year, type));
|
||||||
@ -1605,7 +1608,7 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
|
|||||||
|
|
||||||
QLocale::FormatType type = sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat;
|
QLocale::FormatType type = sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat;
|
||||||
QLocale l = locale();
|
QLocale l = locale();
|
||||||
QVector<QString> daysOfWeek;
|
ShortVector<QString> daysOfWeek;
|
||||||
daysOfWeek.reserve(8 - startDay);
|
daysOfWeek.reserve(8 - startDay);
|
||||||
for (int day = startDay; day <= 7; ++day)
|
for (int day = startDay; day <= 7; ++day)
|
||||||
daysOfWeek.append(l.dayName(day, type));
|
daysOfWeek.append(l.dayName(day, type));
|
||||||
|
@ -77,6 +77,11 @@ QCalendar::System QGregorianCalendar::calendarSystem() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool QGregorianCalendar::isLeapYear(int year) const
|
bool QGregorianCalendar::isLeapYear(int year) const
|
||||||
|
{
|
||||||
|
return leapTest(year);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QGregorianCalendar::leapTest(int year)
|
||||||
{
|
{
|
||||||
if (year == QCalendar::Unspecified)
|
if (year == QCalendar::Unspecified)
|
||||||
return false;
|
return false;
|
||||||
@ -88,10 +93,37 @@ bool QGregorianCalendar::isLeapYear(int year) const
|
|||||||
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Duplicating code from QRomanCalendar, but inlining isLeapYear() as leapTest():
|
||||||
|
int QGregorianCalendar::monthLength(int month, int year)
|
||||||
|
{
|
||||||
|
if (month < 1 || month > 12)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (month == 2)
|
||||||
|
return leapTest(year) ? 29 : 28;
|
||||||
|
|
||||||
|
return 30 | ((month & 1) ^ (month >> 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QGregorianCalendar::validParts(int year, int month, int day)
|
||||||
|
{
|
||||||
|
return year && 0 < day && day <= monthLength(month, year);
|
||||||
|
}
|
||||||
|
|
||||||
|
int QGregorianCalendar::weekDayOfJulian(qint64 jd)
|
||||||
|
{
|
||||||
|
return qMod(jd, 7) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
bool QGregorianCalendar::dateToJulianDay(int year, int month, int day, qint64 *jd) const
|
bool QGregorianCalendar::dateToJulianDay(int year, int month, int day, qint64 *jd) const
|
||||||
|
{
|
||||||
|
return julianFromParts(year, month, day, jd);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QGregorianCalendar::julianFromParts(int year, int month, int day, qint64 *jd)
|
||||||
{
|
{
|
||||||
Q_ASSERT(jd);
|
Q_ASSERT(jd);
|
||||||
if (!isDateValid(year, month, day))
|
if (!validParts(year, month, day))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (year < 0)
|
if (year < 0)
|
||||||
@ -111,6 +143,11 @@ bool QGregorianCalendar::dateToJulianDay(int year, int month, int day, qint64 *j
|
|||||||
}
|
}
|
||||||
|
|
||||||
QCalendar::YearMonthDay QGregorianCalendar::julianDayToDate(qint64 jd) const
|
QCalendar::YearMonthDay QGregorianCalendar::julianDayToDate(qint64 jd) const
|
||||||
|
{
|
||||||
|
return partsFromJulian(jd);
|
||||||
|
}
|
||||||
|
|
||||||
|
QCalendar::YearMonthDay QGregorianCalendar::partsFromJulian(qint64 jd)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php
|
* Math from The Calendar FAQ at http://www.tondering.dk/claus/cal/julperiod.php
|
||||||
|
@ -75,6 +75,14 @@ public:
|
|||||||
QLocale::FormatType format) const override;
|
QLocale::FormatType format) const override;
|
||||||
QString standaloneMonthName(const QLocale &locale, int month, int year,
|
QString standaloneMonthName(const QLocale &locale, int month, int year,
|
||||||
QLocale::FormatType format) const override;
|
QLocale::FormatType format) const override;
|
||||||
|
|
||||||
|
// Static optimized versions for the benefit of QDate:
|
||||||
|
static int weekDayOfJulian(qint64 jd);
|
||||||
|
static bool leapTest(int year);
|
||||||
|
static int monthLength(int month, int year);
|
||||||
|
static bool validParts(int year, int month, int day);
|
||||||
|
static QCalendar::YearMonthDay partsFromJulian(qint64 jd);
|
||||||
|
static bool julianFromParts(int year, int month, int day, qint64 *jd);
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -77,7 +77,8 @@ public:
|
|||||||
if (containing != previous)
|
if (containing != previous)
|
||||||
QWindowSystemInterface::handleEnterLeaveEvent(containing, previous, local, pos);
|
QWindowSystemInterface::handleEnterLeaveEvent(containing, previous, local, pos);
|
||||||
|
|
||||||
QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
|
QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), Qt::NoButton,
|
||||||
|
QEvent::MouseMove, QGuiApplication::keyboardModifiers(), Qt::MouseEventSynthesizedByQt);
|
||||||
|
|
||||||
QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : 0;
|
QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : 0;
|
||||||
}
|
}
|
||||||
|
@ -587,9 +587,18 @@ void QVncClient::frameBufferUpdateRequest()
|
|||||||
void QVncClient::pointerEvent()
|
void QVncClient::pointerEvent()
|
||||||
{
|
{
|
||||||
QRfbPointerEvent ev;
|
QRfbPointerEvent ev;
|
||||||
|
static int buttonState = Qt::NoButton;
|
||||||
if (ev.read(m_clientSocket)) {
|
if (ev.read(m_clientSocket)) {
|
||||||
const QPoint pos = m_server->screen()->geometry().topLeft() + QPoint(ev.x, ev.y);
|
const QPointF pos = m_server->screen()->geometry().topLeft() + QPoint(ev.x, ev.y);
|
||||||
QWindowSystemInterface::handleMouseEvent(0, pos, pos, ev.buttons, QGuiApplication::keyboardModifiers());
|
int buttonStateChange = buttonState ^ int(ev.buttons);
|
||||||
|
QEvent::Type type = QEvent::MouseMove;
|
||||||
|
if (int(ev.buttons) > buttonState)
|
||||||
|
type = QEvent::MouseButtonPress;
|
||||||
|
else if (int(ev.buttons) < buttonState)
|
||||||
|
type = QEvent::MouseButtonRelease;
|
||||||
|
QWindowSystemInterface::handleMouseEvent(nullptr, pos, pos, ev.buttons, Qt::MouseButton(buttonStateChange),
|
||||||
|
type, QGuiApplication::keyboardModifiers());
|
||||||
|
buttonState = int(ev.buttons);
|
||||||
m_handleMsg = false;
|
m_handleMsg = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,10 +91,10 @@ public:
|
|||||||
QCalendarDateSectionValidator() {}
|
QCalendarDateSectionValidator() {}
|
||||||
virtual ~QCalendarDateSectionValidator() {}
|
virtual ~QCalendarDateSectionValidator() {}
|
||||||
virtual Section handleKey(int key) = 0;
|
virtual Section handleKey(int key) = 0;
|
||||||
virtual QDate applyToDate(const QDate &date, QCalendar cal = QCalendar()) const = 0;
|
virtual QDate applyToDate(QDate date, QCalendar cal = QCalendar()) const = 0;
|
||||||
virtual void setDate(const QDate &date, QCalendar cal = QCalendar()) = 0;
|
virtual void setDate(QDate date, QCalendar cal = QCalendar()) = 0;
|
||||||
virtual QString text() const = 0;
|
virtual QString text() const = 0;
|
||||||
virtual QString text(const QDate &date, QCalendar cal, int repeat) const = 0;
|
virtual QString text(QDate date, QCalendar cal, int repeat) const = 0;
|
||||||
|
|
||||||
QLocale m_locale;
|
QLocale m_locale;
|
||||||
|
|
||||||
@ -117,10 +117,10 @@ class QCalendarDayValidator : public QCalendarDateSectionValidator
|
|||||||
public:
|
public:
|
||||||
QCalendarDayValidator();
|
QCalendarDayValidator();
|
||||||
virtual Section handleKey(int key) override;
|
virtual Section handleKey(int key) override;
|
||||||
virtual QDate applyToDate(const QDate &date, QCalendar cal) const override;
|
virtual QDate applyToDate(QDate date, QCalendar cal) const override;
|
||||||
virtual void setDate(const QDate &date, QCalendar cal) override;
|
virtual void setDate(QDate date, QCalendar cal) override;
|
||||||
virtual QString text() const override;
|
virtual QString text() const override;
|
||||||
virtual QString text(const QDate &date, QCalendar cal, int repeat) const override;
|
virtual QString text(QDate date, QCalendar cal, int repeat) const override;
|
||||||
private:
|
private:
|
||||||
int m_pos;
|
int m_pos;
|
||||||
int m_day;
|
int m_day;
|
||||||
@ -181,7 +181,7 @@ QCalendarDateSectionValidator::Section QCalendarDayValidator::handleKey(int key)
|
|||||||
return QCalendarDateSectionValidator::ThisSection;
|
return QCalendarDateSectionValidator::ThisSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDate QCalendarDayValidator::applyToDate(const QDate &date, QCalendar cal) const
|
QDate QCalendarDayValidator::applyToDate(QDate date, QCalendar cal) const
|
||||||
{
|
{
|
||||||
auto parts = cal.partsFromDate(date);
|
auto parts = cal.partsFromDate(date);
|
||||||
if (!parts.isValid())
|
if (!parts.isValid())
|
||||||
@ -190,7 +190,7 @@ QDate QCalendarDayValidator::applyToDate(const QDate &date, QCalendar cal) const
|
|||||||
return cal.dateFromParts(parts);
|
return cal.dateFromParts(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarDayValidator::setDate(const QDate &date, QCalendar cal)
|
void QCalendarDayValidator::setDate(QDate date, QCalendar cal)
|
||||||
{
|
{
|
||||||
m_day = m_oldDay = date.day(cal);
|
m_day = m_oldDay = date.day(cal);
|
||||||
m_pos = 0;
|
m_pos = 0;
|
||||||
@ -201,7 +201,7 @@ QString QCalendarDayValidator::text() const
|
|||||||
return highlightString(formatNumber(m_day, 2), m_pos);
|
return highlightString(formatNumber(m_day, 2), m_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QCalendarDayValidator::text(const QDate &date, QCalendar cal, int repeat) const
|
QString QCalendarDayValidator::text(QDate date, QCalendar cal, int repeat) const
|
||||||
{
|
{
|
||||||
if (repeat <= 1) {
|
if (repeat <= 1) {
|
||||||
return QString::number(date.day(cal));
|
return QString::number(date.day(cal));
|
||||||
@ -222,10 +222,10 @@ class QCalendarMonthValidator : public QCalendarDateSectionValidator
|
|||||||
public:
|
public:
|
||||||
QCalendarMonthValidator();
|
QCalendarMonthValidator();
|
||||||
virtual Section handleKey(int key) override;
|
virtual Section handleKey(int key) override;
|
||||||
virtual QDate applyToDate(const QDate &date, QCalendar cal) const override;
|
virtual QDate applyToDate(QDate date, QCalendar cal) const override;
|
||||||
virtual void setDate(const QDate &date, QCalendar cal) override;
|
virtual void setDate(QDate date, QCalendar cal) override;
|
||||||
virtual QString text() const override;
|
virtual QString text() const override;
|
||||||
virtual QString text(const QDate &date, QCalendar cal, int repeat) const override;
|
virtual QString text(QDate date, QCalendar cal, int repeat) const override;
|
||||||
private:
|
private:
|
||||||
int m_pos;
|
int m_pos;
|
||||||
int m_month;
|
int m_month;
|
||||||
@ -286,7 +286,7 @@ QCalendarDateSectionValidator::Section QCalendarMonthValidator::handleKey(int ke
|
|||||||
return QCalendarDateSectionValidator::ThisSection;
|
return QCalendarDateSectionValidator::ThisSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDate QCalendarMonthValidator::applyToDate(const QDate &date, QCalendar cal) const
|
QDate QCalendarMonthValidator::applyToDate(QDate date, QCalendar cal) const
|
||||||
{
|
{
|
||||||
auto parts = cal.partsFromDate(date);
|
auto parts = cal.partsFromDate(date);
|
||||||
if (!parts.isValid())
|
if (!parts.isValid())
|
||||||
@ -296,7 +296,7 @@ QDate QCalendarMonthValidator::applyToDate(const QDate &date, QCalendar cal) con
|
|||||||
return cal.dateFromParts(parts);
|
return cal.dateFromParts(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarMonthValidator::setDate(const QDate &date, QCalendar cal)
|
void QCalendarMonthValidator::setDate(QDate date, QCalendar cal)
|
||||||
{
|
{
|
||||||
m_month = m_oldMonth = date.month(cal);
|
m_month = m_oldMonth = date.month(cal);
|
||||||
m_pos = 0;
|
m_pos = 0;
|
||||||
@ -307,7 +307,7 @@ QString QCalendarMonthValidator::text() const
|
|||||||
return highlightString(formatNumber(m_month, 2), m_pos);
|
return highlightString(formatNumber(m_month, 2), m_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QCalendarMonthValidator::text(const QDate &date, QCalendar cal, int repeat) const
|
QString QCalendarMonthValidator::text(QDate date, QCalendar cal, int repeat) const
|
||||||
{
|
{
|
||||||
if (repeat <= 1) {
|
if (repeat <= 1) {
|
||||||
return QString::number(date.month(cal));
|
return QString::number(date.month(cal));
|
||||||
@ -328,10 +328,10 @@ class QCalendarYearValidator : public QCalendarDateSectionValidator
|
|||||||
public:
|
public:
|
||||||
QCalendarYearValidator();
|
QCalendarYearValidator();
|
||||||
virtual Section handleKey(int key) override;
|
virtual Section handleKey(int key) override;
|
||||||
virtual QDate applyToDate(const QDate &date, QCalendar cal) const override;
|
virtual QDate applyToDate(QDate date, QCalendar cal) const override;
|
||||||
virtual void setDate(const QDate &date, QCalendar cal) override;
|
virtual void setDate(QDate date, QCalendar cal) override;
|
||||||
virtual QString text() const override;
|
virtual QString text() const override;
|
||||||
virtual QString text(const QDate &date, QCalendar cal, int repeat) const override;
|
virtual QString text(QDate date, QCalendar cal, int repeat) const override;
|
||||||
private:
|
private:
|
||||||
int pow10(int n);
|
int pow10(int n);
|
||||||
int m_pos;
|
int m_pos;
|
||||||
@ -392,7 +392,7 @@ QCalendarDateSectionValidator::Section QCalendarYearValidator::handleKey(int key
|
|||||||
return QCalendarDateSectionValidator::ThisSection;
|
return QCalendarDateSectionValidator::ThisSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDate QCalendarYearValidator::applyToDate(const QDate &date, QCalendar cal) const
|
QDate QCalendarYearValidator::applyToDate(QDate date, QCalendar cal) const
|
||||||
{
|
{
|
||||||
auto parts = cal.partsFromDate(date);
|
auto parts = cal.partsFromDate(date);
|
||||||
if (!parts.isValid())
|
if (!parts.isValid())
|
||||||
@ -403,7 +403,7 @@ QDate QCalendarYearValidator::applyToDate(const QDate &date, QCalendar cal) cons
|
|||||||
return cal.dateFromParts(parts);
|
return cal.dateFromParts(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarYearValidator::setDate(const QDate &date, QCalendar cal)
|
void QCalendarYearValidator::setDate(QDate date, QCalendar cal)
|
||||||
{
|
{
|
||||||
m_year = m_oldYear = date.year(cal);
|
m_year = m_oldYear = date.year(cal);
|
||||||
m_pos = 0;
|
m_pos = 0;
|
||||||
@ -414,7 +414,7 @@ QString QCalendarYearValidator::text() const
|
|||||||
return highlightString(formatNumber(m_year, 4), m_pos);
|
return highlightString(formatNumber(m_year, 4), m_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QCalendarYearValidator::text(const QDate &date, QCalendar cal, int repeat) const
|
QString QCalendarYearValidator::text(QDate date, QCalendar cal, int repeat) const
|
||||||
{
|
{
|
||||||
if (repeat < 4)
|
if (repeat < 4)
|
||||||
return formatNumber(date.year(cal) % 100, 2);
|
return formatNumber(date.year(cal) % 100, 2);
|
||||||
@ -444,7 +444,7 @@ public:
|
|||||||
QString currentText(QCalendar cal) const;
|
QString currentText(QCalendar cal) const;
|
||||||
QDate currentDate() const { return m_currentDate; }
|
QDate currentDate() const { return m_currentDate; }
|
||||||
void setFormat(const QString &format);
|
void setFormat(const QString &format);
|
||||||
void setInitialDate(const QDate &date, QCalendar cal);
|
void setInitialDate(QDate date, QCalendar cal);
|
||||||
|
|
||||||
void setLocale(const QLocale &locale);
|
void setLocale(const QLocale &locale);
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ int QCalendarDateValidator::countRepeat(const QString &str, int index) const
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarDateValidator::setInitialDate(const QDate &date, QCalendar cal)
|
void QCalendarDateValidator::setInitialDate(QDate date, QCalendar cal)
|
||||||
{
|
{
|
||||||
m_yearValidator.setDate(date, cal);
|
m_yearValidator.setDate(date, cal);
|
||||||
m_monthValidator.setDate(date, cal);
|
m_monthValidator.setDate(date, cal);
|
||||||
@ -648,13 +648,13 @@ public:
|
|||||||
int dateEditAcceptDelay() const;
|
int dateEditAcceptDelay() const;
|
||||||
void setDateEditAcceptDelay(int delay);
|
void setDateEditAcceptDelay(int delay);
|
||||||
|
|
||||||
void setDate(const QDate &date);
|
void setDate(QDate date);
|
||||||
|
|
||||||
bool eventFilter(QObject *o, QEvent *e) override;
|
bool eventFilter(QObject *o, QEvent *e) override;
|
||||||
void timerEvent(QTimerEvent *e) override;
|
void timerEvent(QTimerEvent *e) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dateChanged(const QDate &date);
|
void dateChanged(QDate date);
|
||||||
void editingFinished();
|
void editingFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -684,7 +684,7 @@ void QCalendarTextNavigator::setWidget(QWidget *widget)
|
|||||||
m_widget = widget;
|
m_widget = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarTextNavigator::setDate(const QDate &date)
|
void QCalendarTextNavigator::setDate(QDate date)
|
||||||
{
|
{
|
||||||
m_date = date;
|
m_date = date;
|
||||||
}
|
}
|
||||||
@ -891,15 +891,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showMonth(int year, int month);
|
void showMonth(int year, int month);
|
||||||
void setDate(const QDate &d);
|
void setDate(QDate d);
|
||||||
|
|
||||||
void setCalendar(QCalendar c);
|
void setCalendar(QCalendar c);
|
||||||
QCalendar calendar() const;
|
QCalendar calendar() const;
|
||||||
|
|
||||||
void setMinimumDate(const QDate &date);
|
void setMinimumDate(QDate date);
|
||||||
void setMaximumDate(const QDate &date);
|
void setMaximumDate(QDate date);
|
||||||
|
|
||||||
void setRange(const QDate &min, const QDate &max);
|
void setRange(QDate min, QDate max);
|
||||||
|
|
||||||
void setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat format);
|
void setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat format);
|
||||||
|
|
||||||
@ -913,7 +913,7 @@ public:
|
|||||||
Qt::DayOfWeek dayOfWeekForColumn(int section) const;
|
Qt::DayOfWeek dayOfWeekForColumn(int section) const;
|
||||||
int columnForDayOfWeek(Qt::DayOfWeek day) const;
|
int columnForDayOfWeek(Qt::DayOfWeek day) const;
|
||||||
QDate dateForCell(int row, int column) const;
|
QDate dateForCell(int row, int column) const;
|
||||||
void cellForDate(const QDate &date, int *row, int *column) const;
|
void cellForDate(QDate date, int *row, int *column) const;
|
||||||
QString dayName(Qt::DayOfWeek day) const;
|
QString dayName(Qt::DayOfWeek day) const;
|
||||||
|
|
||||||
void setView(QCalendarView *view)
|
void setView(QCalendarView *view)
|
||||||
@ -921,7 +921,7 @@ public:
|
|||||||
|
|
||||||
void internalUpdate();
|
void internalUpdate();
|
||||||
QDate referenceDate() const;
|
QDate referenceDate() const;
|
||||||
int columnForFirstOfMonth(const QDate &date) const;
|
int columnForFirstOfMonth(QDate date) const;
|
||||||
|
|
||||||
int m_firstColumn;
|
int m_firstColumn;
|
||||||
int m_firstRow;
|
int m_firstRow;
|
||||||
@ -951,9 +951,9 @@ public:
|
|||||||
virtual void keyboardSearch(const QString & search) override { Q_UNUSED(search) }
|
virtual void keyboardSearch(const QString & search) override { Q_UNUSED(search) }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void showDate(const QDate &date);
|
void showDate(QDate date);
|
||||||
void changeDate(const QDate &date, bool changeMonth);
|
void changeDate(QDate date, bool changeMonth);
|
||||||
void clicked(const QDate &date);
|
void clicked(QDate date);
|
||||||
void editingFinished();
|
void editingFinished();
|
||||||
protected:
|
protected:
|
||||||
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
|
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
|
||||||
@ -1039,7 +1039,7 @@ QDate QCalendarModel::referenceDate() const
|
|||||||
return QDate();
|
return QDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QCalendarModel::columnForFirstOfMonth(const QDate &date) const
|
int QCalendarModel::columnForFirstOfMonth(QDate date) const
|
||||||
{
|
{
|
||||||
return (columnForDayOfWeek(static_cast<Qt::DayOfWeek>(m_calendar.dayOfWeek(date)))
|
return (columnForDayOfWeek(static_cast<Qt::DayOfWeek>(m_calendar.dayOfWeek(date)))
|
||||||
- (date.day(m_calendar) % 7) + 8) % 7;
|
- (date.day(m_calendar) % 7) + 8) % 7;
|
||||||
@ -1063,7 +1063,7 @@ QDate QCalendarModel::dateForCell(int row, int column) const
|
|||||||
return refDate.addDays(requestedDay);
|
return refDate.addDays(requestedDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarModel::cellForDate(const QDate &date, int *row, int *column) const
|
void QCalendarModel::cellForDate(QDate date, int *row, int *column) const
|
||||||
{
|
{
|
||||||
if (!row && !column)
|
if (!row && !column)
|
||||||
return;
|
return;
|
||||||
@ -1206,7 +1206,7 @@ Qt::ItemFlags QCalendarModel::flags(const QModelIndex &index) const
|
|||||||
return QAbstractTableModel::flags(index);
|
return QAbstractTableModel::flags(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarModel::setDate(const QDate &d)
|
void QCalendarModel::setDate(QDate d)
|
||||||
{
|
{
|
||||||
m_date = d;
|
m_date = d;
|
||||||
if (m_date < m_minimumDate)
|
if (m_date < m_minimumDate)
|
||||||
@ -1240,7 +1240,7 @@ void QCalendarModel::showMonth(int year, int month)
|
|||||||
internalUpdate();
|
internalUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarModel::setMinimumDate(const QDate &d)
|
void QCalendarModel::setMinimumDate(QDate d)
|
||||||
{
|
{
|
||||||
if (!d.isValid() || d == m_minimumDate)
|
if (!d.isValid() || d == m_minimumDate)
|
||||||
return;
|
return;
|
||||||
@ -1253,7 +1253,7 @@ void QCalendarModel::setMinimumDate(const QDate &d)
|
|||||||
internalUpdate();
|
internalUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarModel::setMaximumDate(const QDate &d)
|
void QCalendarModel::setMaximumDate(QDate d)
|
||||||
{
|
{
|
||||||
if (!d.isValid() || d == m_maximumDate)
|
if (!d.isValid() || d == m_maximumDate)
|
||||||
return;
|
return;
|
||||||
@ -1266,7 +1266,7 @@ void QCalendarModel::setMaximumDate(const QDate &d)
|
|||||||
internalUpdate();
|
internalUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarModel::setRange(const QDate &min, const QDate &max)
|
void QCalendarModel::setRange(QDate min, QDate max)
|
||||||
{
|
{
|
||||||
m_minimumDate = min;
|
m_minimumDate = min;
|
||||||
m_maximumDate = max;
|
m_maximumDate = max;
|
||||||
@ -1597,7 +1597,7 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const override;
|
const QModelIndex &index) const override;
|
||||||
void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;
|
void paintCell(QPainter *painter, const QRect &rect, QDate date) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QCalendarWidgetPrivate *calendarWidgetPrivate;
|
QCalendarWidgetPrivate *calendarWidgetPrivate;
|
||||||
@ -1658,11 +1658,11 @@ public:
|
|||||||
|
|
||||||
void showMonth(int year, int month);
|
void showMonth(int year, int month);
|
||||||
void update();
|
void update();
|
||||||
void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;
|
void paintCell(QPainter *painter, const QRect &rect, QDate date) const;
|
||||||
|
|
||||||
void _q_slotShowDate(const QDate &date);
|
void _q_slotShowDate(QDate date);
|
||||||
void _q_slotChangeDate(const QDate &date);
|
void _q_slotChangeDate(QDate date);
|
||||||
void _q_slotChangeDate(const QDate &date, bool changeMonth);
|
void _q_slotChangeDate(QDate date, bool changeMonth);
|
||||||
void _q_editingFinished();
|
void _q_editingFinished();
|
||||||
void _q_monthChanged(QAction*);
|
void _q_monthChanged(QAction*);
|
||||||
void _q_prevMonthClicked();
|
void _q_prevMonthClicked();
|
||||||
@ -1675,7 +1675,7 @@ public:
|
|||||||
void updateMonthMenu();
|
void updateMonthMenu();
|
||||||
void updateMonthMenuNames();
|
void updateMonthMenuNames();
|
||||||
void updateNavigationBar();
|
void updateNavigationBar();
|
||||||
void updateCurrentPage(const QDate &newDate);
|
void updateCurrentPage(QDate newDate);
|
||||||
inline QDate getCurrentDate();
|
inline QDate getCurrentDate();
|
||||||
void setNavigatorEnabled(bool enable);
|
void setNavigatorEnabled(bool enable);
|
||||||
|
|
||||||
@ -1714,7 +1714,7 @@ void QCalendarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarDelegate::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const
|
void QCalendarDelegate::paintCell(QPainter *painter, const QRect &rect, QDate date) const
|
||||||
{
|
{
|
||||||
storedOption.rect = rect;
|
storedOption.rect = rect;
|
||||||
int row = -1;
|
int row = -1;
|
||||||
@ -1881,7 +1881,7 @@ void QCalendarWidgetPrivate::updateMonthMenuNames()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarWidgetPrivate::updateCurrentPage(const QDate &date)
|
void QCalendarWidgetPrivate::updateCurrentPage(QDate date)
|
||||||
{
|
{
|
||||||
Q_Q(QCalendarWidget);
|
Q_Q(QCalendarWidget);
|
||||||
QCalendar cal = m_model->calendar();
|
QCalendar cal = m_model->calendar();
|
||||||
@ -1999,23 +1999,23 @@ void QCalendarWidgetPrivate::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarWidgetPrivate::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const
|
void QCalendarWidgetPrivate::paintCell(QPainter *painter, const QRect &rect, QDate date) const
|
||||||
{
|
{
|
||||||
Q_Q(const QCalendarWidget);
|
Q_Q(const QCalendarWidget);
|
||||||
q->paintCell(painter, rect, date);
|
q->paintCell(painter, rect, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarWidgetPrivate::_q_slotShowDate(const QDate &date)
|
void QCalendarWidgetPrivate::_q_slotShowDate(QDate date)
|
||||||
{
|
{
|
||||||
updateCurrentPage(date);
|
updateCurrentPage(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarWidgetPrivate::_q_slotChangeDate(const QDate &date)
|
void QCalendarWidgetPrivate::_q_slotChangeDate(QDate date)
|
||||||
{
|
{
|
||||||
_q_slotChangeDate(date, true);
|
_q_slotChangeDate(date, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarWidgetPrivate::_q_slotChangeDate(const QDate &date, bool changeMonth)
|
void QCalendarWidgetPrivate::_q_slotChangeDate(QDate date, bool changeMonth)
|
||||||
{
|
{
|
||||||
QDate oldDate = m_model->m_date;
|
QDate oldDate = m_model->m_date;
|
||||||
m_model->setDate(date);
|
m_model->setDate(date);
|
||||||
|
@ -2636,13 +2636,13 @@ void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCalendarPopup::setDate(const QDate &date)
|
void QCalendarPopup::setDate(QDate date)
|
||||||
{
|
{
|
||||||
oldDate = date;
|
oldDate = date;
|
||||||
verifyCalendarInstance()->setSelectedDate(date);
|
verifyCalendarInstance()->setSelectedDate(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCalendarPopup::setDateRange(const QDate &min, const QDate &max)
|
void QCalendarPopup::setDateRange(QDate min, QDate max)
|
||||||
{
|
{
|
||||||
QCalendarWidget *cw = verifyCalendarInstance();
|
QCalendarWidget *cw = verifyCalendarInstance();
|
||||||
cw->setMinimumDate(min);
|
cw->setMinimumDate(min);
|
||||||
@ -2686,7 +2686,7 @@ void QCalendarPopup::dateSelectionChanged()
|
|||||||
dateChanged = true;
|
dateChanged = true;
|
||||||
emit newDateSelected(verifyCalendarInstance()->selectedDate());
|
emit newDateSelected(verifyCalendarInstance()->selectedDate());
|
||||||
}
|
}
|
||||||
void QCalendarPopup::dateSelected(const QDate &date)
|
void QCalendarPopup::dateSelected(QDate date)
|
||||||
{
|
{
|
||||||
dateChanged = true;
|
dateChanged = true;
|
||||||
emit activated(date);
|
emit activated(date);
|
||||||
|
@ -148,19 +148,19 @@ public:
|
|||||||
explicit QCalendarPopup(QWidget *parent = nullptr, QCalendarWidget *cw = nullptr,
|
explicit QCalendarPopup(QWidget *parent = nullptr, QCalendarWidget *cw = nullptr,
|
||||||
QCalendar ca = QCalendar());
|
QCalendar ca = QCalendar());
|
||||||
QDate selectedDate() { return verifyCalendarInstance()->selectedDate(); }
|
QDate selectedDate() { return verifyCalendarInstance()->selectedDate(); }
|
||||||
void setDate(const QDate &date);
|
void setDate(QDate date);
|
||||||
void setDateRange(const QDate &min, const QDate &max);
|
void setDateRange(QDate min, QDate max);
|
||||||
void setFirstDayOfWeek(Qt::DayOfWeek dow) { verifyCalendarInstance()->setFirstDayOfWeek(dow); }
|
void setFirstDayOfWeek(Qt::DayOfWeek dow) { verifyCalendarInstance()->setFirstDayOfWeek(dow); }
|
||||||
QCalendarWidget *calendarWidget() const { return const_cast<QCalendarPopup*>(this)->verifyCalendarInstance(); }
|
QCalendarWidget *calendarWidget() const { return const_cast<QCalendarPopup*>(this)->verifyCalendarInstance(); }
|
||||||
void setCalendarWidget(QCalendarWidget *cw);
|
void setCalendarWidget(QCalendarWidget *cw);
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void activated(const QDate &date);
|
void activated(QDate date);
|
||||||
void newDateSelected(const QDate &newDate);
|
void newDateSelected(QDate newDate);
|
||||||
void hidingCalendar(const QDate &oldDate);
|
void hidingCalendar(QDate oldDate);
|
||||||
void resetButton();
|
void resetButton();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void dateSelected(const QDate &date);
|
void dateSelected(QDate date);
|
||||||
void dateSelectionChanged();
|
void dateSelectionChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -236,6 +236,13 @@ private slots:
|
|||||||
|
|
||||||
void isSymLink_data();
|
void isSymLink_data();
|
||||||
void isSymLink();
|
void isSymLink();
|
||||||
|
|
||||||
|
void isSymbolicLink_data();
|
||||||
|
void isSymbolicLink();
|
||||||
|
|
||||||
|
void isShortcut_data();
|
||||||
|
void isShortcut();
|
||||||
|
|
||||||
void link_data();
|
void link_data();
|
||||||
void link();
|
void link();
|
||||||
|
|
||||||
@ -279,9 +286,6 @@ private slots:
|
|||||||
void invalidState();
|
void invalidState();
|
||||||
void nonExistingFile();
|
void nonExistingFile();
|
||||||
|
|
||||||
void type_data();
|
|
||||||
void type();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_currentDir;
|
const QString m_currentDir;
|
||||||
QString m_sourceFile;
|
QString m_sourceFile;
|
||||||
@ -1342,7 +1346,92 @@ void tst_QFileInfo::isSymLink()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QFileInfo::FileType)
|
void tst_QFileInfo::isShortcut_data()
|
||||||
|
{
|
||||||
|
QFile::remove("link.lnk");
|
||||||
|
QFile::remove("symlink.lnk");
|
||||||
|
QFile::remove("link");
|
||||||
|
QFile::remove("symlink");
|
||||||
|
QFile::remove("directory.lnk");
|
||||||
|
QFile::remove("directory");
|
||||||
|
|
||||||
|
QTest::addColumn<QString>("path");
|
||||||
|
QTest::addColumn<bool>("isShortcut");
|
||||||
|
|
||||||
|
QFile regularFile(m_sourceFile);
|
||||||
|
QTest::newRow("regular")
|
||||||
|
<< regularFile.fileName() << false;
|
||||||
|
QTest::newRow("directory")
|
||||||
|
<< QDir::currentPath() << false;
|
||||||
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||||
|
// windows shortcuts
|
||||||
|
QVERIFY(regularFile.link("link.lnk"));
|
||||||
|
QTest::newRow("shortcut")
|
||||||
|
<< "link.lnk" << true;
|
||||||
|
QVERIFY(regularFile.link("link"));
|
||||||
|
QTest::newRow("invalid-shortcut")
|
||||||
|
<< "link" << false;
|
||||||
|
QVERIFY(QFile::link(QDir::currentPath(), "directory.lnk"));
|
||||||
|
QTest::newRow("directory-shortcut")
|
||||||
|
<< "directory.lnk" << true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QFileInfo::isShortcut()
|
||||||
|
{
|
||||||
|
QFETCH(QString, path);
|
||||||
|
QFETCH(bool, isShortcut);
|
||||||
|
|
||||||
|
QFileInfo fi(path);
|
||||||
|
QCOMPARE(fi.isShortcut(), isShortcut);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QFileInfo::isSymbolicLink_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QString>("path");
|
||||||
|
QTest::addColumn<bool>("isSymbolicLink");
|
||||||
|
|
||||||
|
QFile regularFile(m_sourceFile);
|
||||||
|
QTest::newRow("regular")
|
||||||
|
<< regularFile.fileName() << false;
|
||||||
|
QTest::newRow("directory")
|
||||||
|
<< QDir::currentPath() << false;
|
||||||
|
|
||||||
|
#ifndef Q_NO_SYMLINKS
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#if !defined(Q_OS_WINRT)
|
||||||
|
QString errorMessage;
|
||||||
|
const DWORD creationResult = createSymbolicLink("symlink", m_sourceFile, &errorMessage);
|
||||||
|
if (creationResult == ERROR_PRIVILEGE_NOT_HELD) {
|
||||||
|
QWARN(msgInsufficientPrivileges(errorMessage));
|
||||||
|
} else {
|
||||||
|
QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
|
||||||
|
QTest::newRow("NTFS-symlink")
|
||||||
|
<< "symlink" << true;
|
||||||
|
}
|
||||||
|
#endif // !Q_OS_WINRT
|
||||||
|
#else // Unix:
|
||||||
|
QVERIFY(regularFile.link("symlink.lnk"));
|
||||||
|
QTest::newRow("symlink.lnk")
|
||||||
|
<< "symlink.lnk" << true;
|
||||||
|
QVERIFY(regularFile.link("symlink"));
|
||||||
|
QTest::newRow("symlink")
|
||||||
|
<< "symlink" << true;
|
||||||
|
QVERIFY(QFile::link(QDir::currentPath(), "directory"));
|
||||||
|
QTest::newRow("directory-symlink")
|
||||||
|
<< "directory" << true;
|
||||||
|
#endif
|
||||||
|
#endif // !Q_NO_SYMLINKS
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QFileInfo::isSymbolicLink()
|
||||||
|
{
|
||||||
|
QFETCH(QString, path);
|
||||||
|
QFETCH(bool, isSymbolicLink);
|
||||||
|
|
||||||
|
QFileInfo fi(path);
|
||||||
|
QCOMPARE(fi.isSymbolicLink(), isSymbolicLink);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QFileInfo::link_data()
|
void tst_QFileInfo::link_data()
|
||||||
{
|
{
|
||||||
@ -1354,23 +1443,24 @@ void tst_QFileInfo::link_data()
|
|||||||
QFile::remove("relative/link");
|
QFile::remove("relative/link");
|
||||||
|
|
||||||
QTest::addColumn<QString>("path");
|
QTest::addColumn<QString>("path");
|
||||||
QTest::addColumn<QFileInfo::FileType>("linkType");
|
QTest::addColumn<bool>("isShortcut");
|
||||||
|
QTest::addColumn<bool>("isSymbolicLink");
|
||||||
QTest::addColumn<QString>("linkTarget");
|
QTest::addColumn<QString>("linkTarget");
|
||||||
|
|
||||||
QFile file1(m_sourceFile);
|
QFile file1(m_sourceFile);
|
||||||
QFile file2("dummyfile");
|
QFile file2("dummyfile");
|
||||||
file2.open(QIODevice::WriteOnly);
|
file2.open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
QTest::newRow("existent file") << m_sourceFile << QFileInfo::Unknown << "";
|
QTest::newRow("existent file") << m_sourceFile << false << false << "";
|
||||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||||
// windows shortcuts
|
// windows shortcuts
|
||||||
QVERIFY(file1.link("link.lnk"));
|
QVERIFY(file1.link("link.lnk"));
|
||||||
QTest::newRow("link.lnk")
|
QTest::newRow("link.lnk")
|
||||||
<< "link.lnk" << QFileInfo::Shortcut << QFileInfo(m_sourceFile).absoluteFilePath();
|
<< "link.lnk" << true << false << QFileInfo(m_sourceFile).absoluteFilePath();
|
||||||
|
|
||||||
QVERIFY(file2.link("brokenlink.lnk"));
|
QVERIFY(file2.link("brokenlink.lnk"));
|
||||||
QTest::newRow("broken link.lnk")
|
QTest::newRow("broken link.lnk")
|
||||||
<< "brokenlink.lnk" << QFileInfo::Shortcut << QFileInfo("dummyfile").absoluteFilePath();
|
<< "brokenlink.lnk" << true << false << QFileInfo("dummyfile").absoluteFilePath();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef Q_NO_SYMLINKS
|
#ifndef Q_NO_SYMLINKS
|
||||||
@ -1383,7 +1473,7 @@ void tst_QFileInfo::link_data()
|
|||||||
} else {
|
} else {
|
||||||
QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
|
QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
|
||||||
QTest::newRow("link")
|
QTest::newRow("link")
|
||||||
<< "link" << QFileInfo::SymbolicLink << QFileInfo(m_sourceFile).absoluteFilePath();
|
<< "link" << false << true << QFileInfo(m_sourceFile).absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
creationResult = createSymbolicLink("brokenlink", "dummyfile", &errorMessage);
|
creationResult = createSymbolicLink("brokenlink", "dummyfile", &errorMessage);
|
||||||
@ -1392,22 +1482,22 @@ void tst_QFileInfo::link_data()
|
|||||||
} else {
|
} else {
|
||||||
QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
|
QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
|
||||||
QTest::newRow("broken link")
|
QTest::newRow("broken link")
|
||||||
<< "brokenlink" << QFileInfo::SymbolicLink << QFileInfo("dummyfile").absoluteFilePath();
|
<< "brokenlink" << false << true << QFileInfo("dummyfile").absoluteFilePath();
|
||||||
}
|
}
|
||||||
#endif // !Q_OS_WINRT
|
#endif // !Q_OS_WINRT
|
||||||
#else // Unix:
|
#else // Unix:
|
||||||
QVERIFY(file1.link("link"));
|
QVERIFY(file1.link("link"));
|
||||||
QTest::newRow("link")
|
QTest::newRow("link")
|
||||||
<< "link" << QFileInfo::SymbolicLink << QFileInfo(m_sourceFile).absoluteFilePath();
|
<< "link" << false << true << QFileInfo(m_sourceFile).absoluteFilePath();
|
||||||
|
|
||||||
QVERIFY(file2.link("brokenlink"));
|
QVERIFY(file2.link("brokenlink"));
|
||||||
QTest::newRow("broken link")
|
QTest::newRow("broken link")
|
||||||
<< "brokenlink" << QFileInfo::SymbolicLink << QFileInfo("dummyfile").absoluteFilePath();
|
<< "brokenlink" << false << true << QFileInfo("dummyfile").absoluteFilePath();
|
||||||
|
|
||||||
QDir::current().mkdir("relative");
|
QDir::current().mkdir("relative");
|
||||||
QFile::link("../dummyfile", "relative/link");
|
QFile::link("../dummyfile", "relative/link");
|
||||||
QTest::newRow("relative link")
|
QTest::newRow("relative link")
|
||||||
<< "relative/link" << QFileInfo::SymbolicLink << QFileInfo("dummyfile").absoluteFilePath();
|
<< "relative/link" << false << true << QFileInfo("dummyfile").absoluteFilePath();
|
||||||
#endif
|
#endif
|
||||||
#endif // !Q_NO_SYMLINKS
|
#endif // !Q_NO_SYMLINKS
|
||||||
file2.remove();
|
file2.remove();
|
||||||
@ -1416,11 +1506,13 @@ void tst_QFileInfo::link_data()
|
|||||||
void tst_QFileInfo::link()
|
void tst_QFileInfo::link()
|
||||||
{
|
{
|
||||||
QFETCH(QString, path);
|
QFETCH(QString, path);
|
||||||
QFETCH(QFileInfo::FileType, linkType);
|
QFETCH(bool, isShortcut);
|
||||||
|
QFETCH(bool, isSymbolicLink);
|
||||||
QFETCH(QString, linkTarget);
|
QFETCH(QString, linkTarget);
|
||||||
|
|
||||||
QFileInfo fi(path);
|
QFileInfo fi(path);
|
||||||
QCOMPARE(fi.type() & QFileInfo::LinkTypeMask, linkType);
|
QCOMPARE(fi.isShortcut(), isShortcut);
|
||||||
|
QCOMPARE(fi.isSymbolicLink(), isSymbolicLink);
|
||||||
QCOMPARE(fi.symLinkTarget(), linkTarget);
|
QCOMPARE(fi.symLinkTarget(), linkTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2179,73 +2271,6 @@ void tst_QFileInfo::nonExistingFile()
|
|||||||
stateCheck(info, dirname, filename);
|
stateCheck(info, dirname, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QFileInfo::FileTypes)
|
|
||||||
|
|
||||||
void tst_QFileInfo::type_data()
|
|
||||||
{
|
|
||||||
QFile::remove("link.lnk");
|
|
||||||
QFile::remove("symlink.lnk");
|
|
||||||
QFile::remove("link");
|
|
||||||
QFile::remove("symlink");
|
|
||||||
QFile::remove("directory.lnk");
|
|
||||||
QFile::remove("directory");
|
|
||||||
|
|
||||||
QTest::addColumn<QString>("path");
|
|
||||||
QTest::addColumn<QFileInfo::FileTypes>("type");
|
|
||||||
|
|
||||||
QFile regularFile(m_sourceFile);
|
|
||||||
QTest::newRow("regular")
|
|
||||||
<< regularFile.fileName() << QFileInfo::FileTypes(QFileInfo::Regular);
|
|
||||||
QTest::newRow("directory")
|
|
||||||
<< QDir::currentPath() << QFileInfo::FileTypes(QFileInfo::Directory);
|
|
||||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
|
||||||
// windows shortcuts
|
|
||||||
QVERIFY(regularFile.link("link.lnk"));
|
|
||||||
QTest::newRow("shortcut")
|
|
||||||
<< "link.lnk" << QFileInfo::FileTypes(QFileInfo::Shortcut | QFileInfo::Regular);
|
|
||||||
QVERIFY(regularFile.link("link"));
|
|
||||||
QTest::newRow("invalid-shortcut")
|
|
||||||
<< "link" << QFileInfo::FileTypes(QFileInfo::Regular);
|
|
||||||
QVERIFY(QFile::link(QDir::currentPath(), "directory.lnk"));
|
|
||||||
QTest::newRow("directory-shortcut")
|
|
||||||
<< "directory.lnk" << QFileInfo::FileTypes(QFileInfo::Shortcut | QFileInfo::Directory);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef Q_NO_SYMLINKS
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
#if !defined(Q_OS_WINRT)
|
|
||||||
QString errorMessage;
|
|
||||||
const DWORD creationResult = createSymbolicLink("symlink", m_sourceFile, &errorMessage);
|
|
||||||
if (creationResult == ERROR_PRIVILEGE_NOT_HELD) {
|
|
||||||
QWARN(msgInsufficientPrivileges(errorMessage));
|
|
||||||
} else {
|
|
||||||
QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage));
|
|
||||||
QTest::newRow("NTFS-symlink")
|
|
||||||
<< "symlink" << QFileInfo::FileTypes(QFileInfo::SymbolicLink | QFileInfo::Regular);
|
|
||||||
}
|
|
||||||
#endif // !Q_OS_WINRT
|
|
||||||
#else // Unix:
|
|
||||||
QVERIFY(regularFile.link("symlink.lnk"));
|
|
||||||
QTest::newRow("symlink.lnk")
|
|
||||||
<< "symlink.lnk" << QFileInfo::FileTypes(QFileInfo::SymbolicLink | QFileInfo::Regular);
|
|
||||||
QVERIFY(regularFile.link("symlink"));
|
|
||||||
QTest::newRow("symlink")
|
|
||||||
<< "symlink" << QFileInfo::FileTypes(QFileInfo::SymbolicLink | QFileInfo::Regular);
|
|
||||||
QVERIFY(QFile::link(QDir::currentPath(), "directory"));
|
|
||||||
QTest::newRow("directory-symlink")
|
|
||||||
<< "directory" << QFileInfo::FileTypes(QFileInfo::SymbolicLink | QFileInfo::Directory);
|
|
||||||
#endif
|
|
||||||
#endif // !Q_NO_SYMLINKS
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QFileInfo::type()
|
|
||||||
{
|
|
||||||
QFETCH(QString, path);
|
|
||||||
QFETCH(QFileInfo::FileTypes, type);
|
|
||||||
|
|
||||||
QFileInfo info(path);
|
|
||||||
QCOMPARE(info.type(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTEST_MAIN(tst_QFileInfo)
|
QTEST_MAIN(tst_QFileInfo)
|
||||||
#include "tst_qfileinfo.moc"
|
#include "tst_qfileinfo.moc"
|
||||||
|
@ -348,8 +348,7 @@ static QLatin1String sectionToName(const QDateTimeEdit::Section section)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QDate stepDate(const QDate& startDate, const QDateTimeEdit::Section section,
|
static QDate stepDate(QDate startDate, const QDateTimeEdit::Section section, const int steps)
|
||||||
const int steps)
|
|
||||||
{
|
{
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case QDateTimeEdit::DaySection:
|
case QDateTimeEdit::DaySection:
|
||||||
@ -364,8 +363,7 @@ static QDate stepDate(const QDate& startDate, const QDateTimeEdit::Section secti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QTime stepTime(const QTime& startTime, const QDateTimeEdit::Section section,
|
static QTime stepTime(QTime startTime, const QDateTimeEdit::Section section, const int steps)
|
||||||
const int steps)
|
|
||||||
{
|
{
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case QDateTimeEdit::SecondSection:
|
case QDateTimeEdit::SecondSection:
|
||||||
|
@ -26,27 +26,187 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDate>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
class tst_QDate : public QObject
|
class tst_QDate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
enum : qint64
|
||||||
|
{
|
||||||
|
JULIAN_DAY_2010 = 2455198,
|
||||||
|
JULIAN_DAY_2011 = 2455563,
|
||||||
|
JULIAN_DAY_2020 = 2458850,
|
||||||
|
};
|
||||||
|
|
||||||
|
static QVector<QDate> daily(qint64 start, qint64 end);
|
||||||
|
static QVector<QDate> yearly(qint32 first, qint32 last);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void monthLengths();
|
void create();
|
||||||
|
void year();
|
||||||
|
void month();
|
||||||
|
void day();
|
||||||
|
void dayOfWeek();
|
||||||
|
void dayOfYear();
|
||||||
|
void monthLengths(); // isValid() and daysInMonth()
|
||||||
|
void daysInYear();
|
||||||
|
void isLeapYear();
|
||||||
|
void getSetDate();
|
||||||
|
void addDays();
|
||||||
|
void addMonths();
|
||||||
|
void addYears();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QVector<QDate> tst_QDate::daily(qint64 start, qint64 end)
|
||||||
|
{
|
||||||
|
QVector<QDate> list;
|
||||||
|
list.reserve(end - start);
|
||||||
|
for (qint64 jd = start; jd < end; ++jd)
|
||||||
|
list.append(QDate::fromJulianDay(jd));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QDate> tst_QDate::yearly(qint32 first, qint32 last)
|
||||||
|
{
|
||||||
|
QVector<QDate> list;
|
||||||
|
list.reserve(last + 1 - first);
|
||||||
|
for (qint32 year = first; year <= last; ++year)
|
||||||
|
list.append(QDate(year, 3, 21));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::create()
|
||||||
|
{
|
||||||
|
QDate test;
|
||||||
|
QBENCHMARK {
|
||||||
|
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
||||||
|
test = QDate::fromJulianDay(jd);
|
||||||
|
}
|
||||||
|
Q_UNUSED(test);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::year()
|
||||||
|
{
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const QDate &test : list)
|
||||||
|
test.year();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::month()
|
||||||
|
{
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const QDate &test : list)
|
||||||
|
test.month();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::day()
|
||||||
|
{
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const QDate &test : list)
|
||||||
|
test.day();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::dayOfWeek()
|
||||||
|
{
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const QDate &test : list)
|
||||||
|
test.dayOfWeek();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::dayOfYear()
|
||||||
|
{
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const QDate &test : list)
|
||||||
|
test.dayOfYear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QDate::monthLengths()
|
void tst_QDate::monthLengths()
|
||||||
{
|
{
|
||||||
|
bool check = true;
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int year = 1900; year <= 2100; year++) {
|
for (int year = 1900; year <= 2100; year++) {
|
||||||
bool check = true;
|
|
||||||
for (int month = 1; month <= 12; month++)
|
for (int month = 1; month <= 12; month++)
|
||||||
check &= QDate::isValid(year, month, QDate(year, month, 1).daysInMonth());
|
check = QDate::isValid(year, month, QDate(year, month, 1).daysInMonth());
|
||||||
Q_UNUSED(check);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Q_UNUSED(check);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::daysInYear()
|
||||||
|
{
|
||||||
|
const auto list = yearly(1601, 2401);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const QDate date : list)
|
||||||
|
date.daysInYear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::isLeapYear()
|
||||||
|
{
|
||||||
|
QBENCHMARK {
|
||||||
|
for (qint32 year = 1601; year <= 2401; year++)
|
||||||
|
QDate::isLeapYear(year);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::getSetDate()
|
||||||
|
{
|
||||||
|
QDate store;
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const auto test : list) {
|
||||||
|
int year, month, day;
|
||||||
|
test.getDate(&year, &month, &day);
|
||||||
|
store.setDate(year, month, day);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Q_UNUSED(store);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::addDays()
|
||||||
|
{
|
||||||
|
QDate store;
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const auto test : list)
|
||||||
|
store = test.addDays(17);
|
||||||
|
}
|
||||||
|
Q_UNUSED(store);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::addMonths()
|
||||||
|
{
|
||||||
|
QDate store;
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const auto test : list)
|
||||||
|
store = test.addMonths(17);
|
||||||
|
}
|
||||||
|
Q_UNUSED(store);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QDate::addYears()
|
||||||
|
{
|
||||||
|
QDate store;
|
||||||
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
|
QBENCHMARK {
|
||||||
|
for (const auto test : list)
|
||||||
|
store = test.addYears(17);
|
||||||
|
}
|
||||||
|
Q_UNUSED(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QDate)
|
QTEST_MAIN(tst_QDate)
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QTimeZone>
|
#include <QTimeZone>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
#include <QVector>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
|
|
||||||
class tst_QDateTime : public QObject
|
class tst_QDateTime : public QObject
|
||||||
@ -41,6 +42,7 @@ class tst_QDateTime : public QObject
|
|||||||
MSECS_PER_DAY = 86400000,
|
MSECS_PER_DAY = 86400000,
|
||||||
JULIAN_DAY_1950 = 2433283,
|
JULIAN_DAY_1950 = 2433283,
|
||||||
JULIAN_DAY_1960 = 2436935,
|
JULIAN_DAY_1960 = 2436935,
|
||||||
|
JULIAN_DAY_1970 = 2440588, // Epoch
|
||||||
JULIAN_DAY_2010 = 2455198,
|
JULIAN_DAY_2010 = 2455198,
|
||||||
JULIAN_DAY_2011 = 2455563,
|
JULIAN_DAY_2011 = 2455563,
|
||||||
JULIAN_DAY_2020 = 2458850,
|
JULIAN_DAY_2020 = 2458850,
|
||||||
@ -48,6 +50,9 @@ class tst_QDateTime : public QObject
|
|||||||
JULIAN_DAY_2060 = 2473460
|
JULIAN_DAY_2060 = 2473460
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static QVector<QDateTime> daily(qint64 start, qint64 end);
|
||||||
|
static QVector<QDateTime> norse(qint64 start, qint64 end);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void create();
|
void create();
|
||||||
void isNull();
|
void isNull();
|
||||||
@ -97,6 +102,25 @@ private Q_SLOTS:
|
|||||||
void fromMSecsSinceEpochTz();
|
void fromMSecsSinceEpochTz();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QVector<QDateTime> tst_QDateTime::daily(qint64 start, qint64 end)
|
||||||
|
{
|
||||||
|
QVector<QDateTime> list;
|
||||||
|
list.reserve(end - start);
|
||||||
|
for (int jd = start; jd < end; ++jd)
|
||||||
|
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QDateTime> tst_QDateTime::norse(qint64 start, qint64 end)
|
||||||
|
{
|
||||||
|
const QTimeZone cet("Europe/Oslo");
|
||||||
|
QVector<QDateTime> list;
|
||||||
|
list.reserve(end - start);
|
||||||
|
for (int jd = start; jd < end; ++jd)
|
||||||
|
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QDateTime::create()
|
void tst_QDateTime::create()
|
||||||
{
|
{
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
@ -109,339 +133,286 @@ void tst_QDateTime::create()
|
|||||||
|
|
||||||
void tst_QDateTime::isNull()
|
void tst_QDateTime::isNull()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.isNull();
|
test.isNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::isValid()
|
void tst_QDateTime::isValid()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.isValid();
|
test.isValid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::date()
|
void tst_QDateTime::date()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.date();
|
test.date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::time()
|
void tst_QDateTime::time()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.time();
|
test.time();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::timeSpec()
|
void tst_QDateTime::timeSpec()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.timeSpec();
|
test.timeSpec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::offsetFromUtc()
|
void tst_QDateTime::offsetFromUtc()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.offsetFromUtc();
|
test.offsetFromUtc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::timeZoneAbbreviation()
|
void tst_QDateTime::timeZoneAbbreviation()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.timeZoneAbbreviation();
|
test.timeZoneAbbreviation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toMSecsSinceEpoch()
|
void tst_QDateTime::toMSecsSinceEpoch()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.toMSecsSinceEpoch();
|
test.toMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toMSecsSinceEpoch1950()
|
void tst_QDateTime::toMSecsSinceEpoch1950()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_1950, JULIAN_DAY_1960);
|
||||||
for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.toMSecsSinceEpoch();
|
test.toMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toMSecsSinceEpoch2050()
|
void tst_QDateTime::toMSecsSinceEpoch2050()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2050, JULIAN_DAY_2060);
|
||||||
for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.toMSecsSinceEpoch();
|
test.toMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toMSecsSinceEpochTz()
|
void tst_QDateTime::toMSecsSinceEpochTz()
|
||||||
{
|
{
|
||||||
QTimeZone cet = QTimeZone("Europe/Oslo");
|
qint64 result;
|
||||||
QList<QDateTime> list;
|
const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
qint64 result = test.toMSecsSinceEpoch();
|
result = test.toMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
|
Q_UNUSED(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toMSecsSinceEpoch1950Tz()
|
void tst_QDateTime::toMSecsSinceEpoch1950Tz()
|
||||||
{
|
{
|
||||||
QTimeZone cet = QTimeZone("Europe/Oslo");
|
qint64 result;
|
||||||
QList<QDateTime> list;
|
const auto list = norse(JULIAN_DAY_1950, JULIAN_DAY_1960);
|
||||||
for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
qint64 result = test.toMSecsSinceEpoch();
|
result = test.toMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
|
Q_UNUSED(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toMSecsSinceEpoch2050Tz()
|
void tst_QDateTime::toMSecsSinceEpoch2050Tz()
|
||||||
{
|
{
|
||||||
QTimeZone cet = QTimeZone("Europe/Oslo");
|
qint64 result;
|
||||||
QList<QDateTime> list;
|
const auto list = norse(JULIAN_DAY_2050, JULIAN_DAY_2060);
|
||||||
for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
qint64 result = test.toMSecsSinceEpoch();
|
result = test.toMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
|
Q_UNUSED(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::setDate()
|
void tst_QDateTime::setDate()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (QDateTime test, list)
|
for (QDateTime test : list)
|
||||||
test.setDate(QDate::fromJulianDay(JULIAN_DAY_2010));
|
test.setDate(QDate::fromJulianDay(JULIAN_DAY_2010));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::setTime()
|
void tst_QDateTime::setTime()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (QDateTime test, list)
|
for (QDateTime test : list)
|
||||||
test.setTime(QTime(12, 0, 0));
|
test.setTime(QTime(12, 0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::setTimeSpec()
|
void tst_QDateTime::setTimeSpec()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (QDateTime test, list)
|
for (QDateTime test : list)
|
||||||
test.setTimeSpec(Qt::UTC);
|
test.setTimeSpec(Qt::UTC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::setOffsetFromUtc()
|
void tst_QDateTime::setOffsetFromUtc()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (QDateTime test, list)
|
for (QDateTime test : list)
|
||||||
test.setOffsetFromUtc(3600);
|
test.setOffsetFromUtc(3600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::setMSecsSinceEpoch()
|
void tst_QDateTime::setMSecsSinceEpoch()
|
||||||
{
|
{
|
||||||
qint64 msecs = qint64(JULIAN_DAY_2010 + 180) * MSECS_PER_DAY;
|
qint64 msecs = qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970 + 180) * MSECS_PER_DAY;
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (QDateTime test, list)
|
for (QDateTime test : list)
|
||||||
test.setMSecsSinceEpoch(msecs);
|
test.setMSecsSinceEpoch(msecs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::setMSecsSinceEpochTz()
|
void tst_QDateTime::setMSecsSinceEpochTz()
|
||||||
{
|
{
|
||||||
QTimeZone cet = QTimeZone("Europe/Oslo");
|
const qint64 msecs = qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970 + 180) * MSECS_PER_DAY;
|
||||||
QList<QDateTime> list;
|
const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (QDateTime test, list)
|
for (QDateTime test : list)
|
||||||
test.setMSecsSinceEpoch((JULIAN_DAY_2010 + 180) * MSECS_PER_DAY);
|
test.setMSecsSinceEpoch(msecs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toString()
|
void tst_QDateTime::toString()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.toString(QStringLiteral("yyy-MM-dd hh:mm:ss.zzz t"));
|
test.toString(QStringLiteral("yyy-MM-dd hh:mm:ss.zzz t"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toStringTextFormat()
|
void tst_QDateTime::toStringTextFormat()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.toString(Qt::TextDate);
|
test.toString(Qt::TextDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toStringIsoFormat()
|
void tst_QDateTime::toStringIsoFormat()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.toString(Qt::ISODate);
|
test.toString(Qt::ISODate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::addDays()
|
void tst_QDateTime::addDays()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
QDateTime next;
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.addDays(1);
|
next = test.addDays(1);
|
||||||
}
|
}
|
||||||
|
Q_UNUSED(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::addDaysTz()
|
void tst_QDateTime::addDaysTz()
|
||||||
{
|
{
|
||||||
QTimeZone cet = QTimeZone("Europe/Oslo");
|
const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
QList<QDateTime> list;
|
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
QDateTime result = test.addDays(1);
|
QDateTime result = test.addDays(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::addMSecs()
|
void tst_QDateTime::addMSecs()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
QDateTime next;
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.addMSecs(1);
|
next = test.addMSecs(1);
|
||||||
}
|
}
|
||||||
|
Q_UNUSED(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::addMSecsTz()
|
void tst_QDateTime::addMSecsTz()
|
||||||
{
|
{
|
||||||
QTimeZone cet = QTimeZone("Europe/Oslo");
|
const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
QList<QDateTime> list;
|
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
QDateTime result = test.addMSecs(1);
|
QDateTime result = test.addMSecs(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toTimeSpec()
|
void tst_QDateTime::toTimeSpec()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.toTimeSpec(Qt::UTC);
|
test.toTimeSpec(Qt::UTC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::toOffsetFromUtc()
|
void tst_QDateTime::toOffsetFromUtc()
|
||||||
{
|
{
|
||||||
QList<QDateTime> list;
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.toOffsetFromUtc(3600);
|
test.toOffsetFromUtc(3600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::daysTo()
|
void tst_QDateTime::daysTo()
|
||||||
{
|
{
|
||||||
QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY);
|
const QDateTime other = QDateTime::fromMSecsSinceEpoch(
|
||||||
QList<QDateTime> list;
|
qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.daysTo(other);
|
test.daysTo(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::msecsTo()
|
void tst_QDateTime::msecsTo()
|
||||||
{
|
{
|
||||||
QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY);
|
const QDateTime other = QDateTime::fromMSecsSinceEpoch(
|
||||||
QList<QDateTime> list;
|
qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
test.msecsTo(other);
|
test.msecsTo(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,12 +420,11 @@ void tst_QDateTime::msecsTo()
|
|||||||
void tst_QDateTime::equivalent()
|
void tst_QDateTime::equivalent()
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY);
|
const QDateTime other = QDateTime::fromMSecsSinceEpoch(
|
||||||
QList<QDateTime> list;
|
qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
result = (test == other);
|
result = (test == other);
|
||||||
}
|
}
|
||||||
Q_UNUSED(result)
|
Q_UNUSED(result)
|
||||||
@ -463,12 +433,11 @@ void tst_QDateTime::equivalent()
|
|||||||
void tst_QDateTime::equivalentUtc()
|
void tst_QDateTime::equivalentUtc()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC);
|
const QDateTime other = QDateTime::fromMSecsSinceEpoch(
|
||||||
QList<QDateTime> list;
|
qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, Qt::UTC);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
result = (test == other);
|
result = (test == other);
|
||||||
}
|
}
|
||||||
Q_UNUSED(result)
|
Q_UNUSED(result)
|
||||||
@ -477,12 +446,11 @@ void tst_QDateTime::equivalentUtc()
|
|||||||
void tst_QDateTime::lessThan()
|
void tst_QDateTime::lessThan()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY);
|
const QDateTime other = QDateTime::fromMSecsSinceEpoch(
|
||||||
QList<QDateTime> list;
|
qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
result = (test < other);
|
result = (test < other);
|
||||||
}
|
}
|
||||||
Q_UNUSED(result)
|
Q_UNUSED(result)
|
||||||
@ -491,12 +459,11 @@ void tst_QDateTime::lessThan()
|
|||||||
void tst_QDateTime::lessThanUtc()
|
void tst_QDateTime::lessThanUtc()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC);
|
const QDateTime other = QDateTime::fromMSecsSinceEpoch(
|
||||||
QList<QDateTime> list;
|
qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, Qt::UTC);
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
|
||||||
list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
foreach (const QDateTime &test, list)
|
for (const QDateTime &test : list)
|
||||||
result = (test < other);
|
result = (test < other);
|
||||||
}
|
}
|
||||||
Q_UNUSED(result)
|
Q_UNUSED(result)
|
||||||
@ -573,25 +540,31 @@ void tst_QDateTime::fromStringIso()
|
|||||||
|
|
||||||
void tst_QDateTime::fromMSecsSinceEpoch()
|
void tst_QDateTime::fromMSecsSinceEpoch()
|
||||||
{
|
{
|
||||||
|
const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970;
|
||||||
|
const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970;
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
for (int jd = start; jd < end; ++jd)
|
||||||
QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::LocalTime);
|
QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::LocalTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::fromMSecsSinceEpochUtc()
|
void tst_QDateTime::fromMSecsSinceEpochUtc()
|
||||||
{
|
{
|
||||||
|
const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970;
|
||||||
|
const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970;
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
for (int jd = start; jd < end; ++jd)
|
||||||
QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::UTC);
|
QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::UTC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::fromMSecsSinceEpochTz()
|
void tst_QDateTime::fromMSecsSinceEpochTz()
|
||||||
{
|
{
|
||||||
QTimeZone cet = QTimeZone("Europe/Oslo");
|
const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970;
|
||||||
|
const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970;
|
||||||
|
const QTimeZone cet("Europe/Oslo");
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
|
for (int jd = start; jd < end; ++jd)
|
||||||
QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet);
|
QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user