diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-17 01:00:14 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-17 01:00:15 +0200 |
commit | 73bce0411defd11ed96f4ceefe11e44288cd0ad4 (patch) | |
tree | 51c634bcf0d84ab0daf476f7d14134c9bed82346 | |
parent | Add support for UTC[+-]\d+(:\d+){,2} time zone IDs (diff) | |
parent | Fix mis-handling of actual TLD in qIsEffectiveTLD() (diff) | |
download | qtbase-73bce0411defd11ed96f4ceefe11e44288cd0ad4.tar.xz qtbase-73bce0411defd11ed96f4ceefe11e44288cd0ad4.zip |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I4d7f0e35f4a6ccb6d5494f947fd82fc276feadd3
21 files changed, 558 insertions, 603 deletions
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp index 912609ec91..fc3e16b241 100644 --- a/src/corelib/io/qtldurl.cpp +++ b/src/corelib/io/qtldurl.cpp @@ -125,10 +125,10 @@ Q_CORE_EXPORT bool qIsEffectiveTLD(const QStringRef &domain) return true; const int dot = domain.indexOf(QLatin1Char('.')); - if (dot >= 0) { - if (containsTLDEntry(domain.mid(dot), SuffixMatch)) // 2 - return !containsTLDEntry(domain, ExceptionMatch); // 3 - } + if (dot < 0) // Actual TLD: may be effective if the subject of a wildcard rule: + return containsTLDEntry(QString(QLatin1Char('.') + domain), SuffixMatch); + if (containsTLDEntry(domain.mid(dot), SuffixMatch)) // 2 + return !containsTLDEntry(domain, ExceptionMatch); // 3 return false; } diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index dc976819ef..9804e60119 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -99,8 +99,10 @@ public: typename Ops::Type _q_value; // Everything below is either implemented in ../arch/qatomic_XXX.h or (as fallback) in qgenericatomic.h - T load() const noexcept { return loadRelaxed(); } - void store(T newValue) noexcept { storeRelaxed(newValue); } +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_VERSION_X_5_14("Use loadRelaxed") T load() const noexcept { return loadRelaxed(); } + QT_DEPRECATED_VERSION_X_5_14("Use storeRelaxed") void store(T newValue) noexcept { storeRelaxed(newValue); } +#endif T loadRelaxed() const noexcept { return Ops::loadRelaxed(_q_value); } void storeRelaxed(T newValue) noexcept { Ops::storeRelaxed(_q_value, newValue); } @@ -238,8 +240,10 @@ public: AtomicType _q_value; - Type load() const noexcept { return loadRelaxed(); } - void store(Type newValue) noexcept { storeRelaxed(newValue); } +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_VERSION_X_5_14("Use loadRelaxed") Type load() const noexcept { return loadRelaxed(); } + QT_DEPRECATED_VERSION_X_5_14("Use storeRelaxed") void store(Type newValue) noexcept { storeRelaxed(newValue); } +#endif Type loadRelaxed() const noexcept { return Ops::loadRelaxed(_q_value); } void storeRelaxed(Type newValue) noexcept { Ops::storeRelaxed(_q_value, newValue); } diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp index 4d3f1627b5..d706f1d5ab 100644 --- a/src/corelib/time/qcalendar.cpp +++ b/src/corelib/time/qcalendar.cpp @@ -201,7 +201,7 @@ QCalendar::System QCalendarBackend::calendarSystem() const } /*! - The primary name of this calendar. + The primary name of this calendar. */ QString QCalendar::name() const { @@ -440,101 +440,104 @@ int QCalendarBackend::dayOfWeek(qint64 jd) const // Month and week-day name look-ups (implemented in qlocale.cpp): /*! - \fn QString QCalendarBackend::monthName(const QLocale &locale, int month, int year, - QLocale::FormatType format) const + \fn QString QCalendarBackend::monthName(const QLocale &locale, int month, int year, + QLocale::FormatType format) const - Returns the name of the specified \a month in the given \a year for the chosen - \a locale, using the given \a format to determine how complete the name is. + Returns the name of the specified \a month in the given \a year for the + chosen \a locale, using the given \a format to determine how complete the + name is. - If \a year is Unspecified, return the name for the month that usually has this - number within a typical year. Calendars with a leap month that isn't always - the last may need to take account of the year to map the month number to the - particular year's month with that number. + If \a year is Unspecified, return the name for the month that usually has + this number within a typical year. Calendars with a leap month that isn't + always the last may need to take account of the year to map the month number + to the particular year's month with that number. - \note Backends for which CLDR provides data can configure the default - implementation of the two month name look-up methods by arranging for - localeMonthIndexData() and localeMonthData() to provide access to the CLDR - data (see cldr2qlocalexml.py, qlocalexml2cpp.py and existing backends). - Conversely, backends that override both month name look-up methods need not - return anything meaningful from localeMonthIndexData() or localeMonthData(). + \note Backends for which CLDR provides data can configure the default + implementation of the two month name look-up methods by arranging for + localeMonthIndexData() and localeMonthData() to provide access to the CLDR + data (see cldr2qlocalexml.py, qlocalexml2cpp.py and existing backends). + Conversely, backends that override both month name look-up methods need not + return anything meaningful from localeMonthIndexData() or localeMonthData(). - \sa standaloneMonthName(), QLocale::monthName() + \sa standaloneMonthName(), QLocale::monthName() */ /*! - \fn QString QCalendarBackend::standaloneMonthName(const QLocale &locale, int month, int year - QLocale::FormatType format) const + \fn QString QCalendarBackend::standaloneMonthName(const QLocale &locale, int month, int year + QLocale::FormatType format) const - Returns the standalone name of the specified \a month in the chosen \a locale, - using the specified \a format to determine how complete the name is. + Returns the standalone name of the specified \a month in the chosen \a + locale, using the specified \a format to determine how complete the name is. - If \a year is Unspecified, return the standalone name for the month that - usually has this number within a typical year. Calendars with a leap month - that isn't always the last may need to take account of the year to map the - month number to the particular year's month with that number. + If \a year is Unspecified, return the standalone name for the month that + usually has this number within a typical year. Calendars with a leap month + that isn't always the last may need to take account of the year to map the + month number to the particular year's month with that number. - \sa monthName(), QLocale::standaloneMonthName() + \sa monthName(), QLocale::standaloneMonthName() */ /*! - \fn QString QCalendarBackend::weekDayName(const QLocale &locale, int day, - QLocale::FormatType format) const + \fn QString QCalendarBackend::weekDayName(const QLocale &locale, int day, + QLocale::FormatType format) const - Returns the name of the specified \a day of the week in the chosen \a locale, - using the specified \a format to determine how complete the name is. + Returns the name of the specified \a day of the week in the chosen \a + locale, using the specified \a format to determine how complete the name is. - The base implementation handles \a day values from 1 to 7 using the day names - CLDR provides, which are suitable for calendards that use the same - (Hebrew-derived) week as the Gregorian calendar. + The base implementation handles \a day values from 1 to 7 using the day + names CLDR provides, which are suitable for calendards that use the same + (Hebrew-derived) week as the Gregorian calendar. - Calendars whose dayOfWeek() returns a value outside the range from 1 to 7 need - to reimplement this method to handle such extra week-day values. They can - assume that \a day is a value returned by the same calendar's dayOfWeek(). + Calendars whose dayOfWeek() returns a value outside the range from 1 to 7 + need to reimplement this method to handle such extra week-day values. They + can assume that \a day is a value returned by the same calendar's + dayOfWeek(). - \sa dayOfWeek(), standaloneWeekDayName(), QLocale::dayName() + \sa dayOfWeek(), standaloneWeekDayName(), QLocale::dayName() */ /*! - \fn QString QCalendarBackend::standaloneWeekDayName(const QLocale &locale, int day, - QLocale::FormatType format) const + \fn QString QCalendarBackend::standaloneWeekDayName(const QLocale &locale, int day, + QLocale::FormatType format) const - Returns the standalone name of the specified \a day of the week in the chosen - \a locale, using the specified \a format to determine how complete the name - is. + Returns the standalone name of the specified \a day of the week in the + chosen \a locale, using the specified \a format to determine how complete + the name is. - The base implementation handles \a day values from 1 to 7 using the standalone - day names CLDR provides, which are suitable for calendards that use the same - (Hebrew-derived) week as the Gregorian calendar. + The base implementation handles \a day values from 1 to 7 using the + standalone day names CLDR provides, which are suitable for calendards that + use the same (Hebrew-derived) week as the Gregorian calendar. - Calendars whose dayOfWeek() returns a value outside the range from 1 to 7 need - to reimplement this method to handle such extra week-day values. They can - assume that \a day is a value returned by the same calendar's dayOfWeek(). + Calendars whose dayOfWeek() returns a value outside the range from 1 to 7 + need to reimplement this method to handle such extra week-day values. They + can assume that \a day is a value returned by the same calendar's + dayOfWeek(). - \sa dayOfWeek(), weekDayName(), QLocale::standaloneDayName() + \sa dayOfWeek(), weekDayName(), QLocale::standaloneDayName() */ /*! - \fn QString QCalendarBackend::dateTimeToString(QStringView format, const QDateTime &datetime, - const QDate &dateOnly, const QTime &timeOnly, - const QLocale &locale) const - - Returns a string representing a given date, time or date-time. - - If \a datetime is specified and valid, it is used and both date and time - format tokens are converted to appropriate representations of the parts of the - datetime. Otherwise, if \a dateOnly is valid, only date format tokens are - converted; else, if \a timeOnly is valid, only time format tokens are - converted. If none are valid, an empty string is returned. - - The specified \a locale influences how some format tokens are converted; for - example, when substituting day and month names and their short-forms. For the - supported formatting tokens, see QDate::toString() and QTime::toString(). As - described above, the provided date, time and date-time determine which of - these tokens are recognized: where these appear in \a format they are replaced - by data. Any text in \a format not recognized as a format token is copied - verbatim into the result string. - - \sa QDate::toString(), QTime::toString(), QDateTime::toString() + \fn QString QCalendarBackend::dateTimeToString(QStringView format, const QDateTime &datetime, + const QDate &dateOnly, const QTime &timeOnly, + const QLocale &locale) const + + Returns a string representing a given date, time or date-time. + + If \a datetime is specified and valid, it is used and both date and time + format tokens are converted to appropriate representations of the parts of + the datetime. Otherwise, if \a dateOnly is valid, only date format tokens + are converted; else, if \a timeOnly is valid, only time format tokens are + converted. If none are valid, an empty string is returned. + + The specified \a locale influences how some format tokens are converted; for + example, when substituting day and month names and their short-forms. For + the supported formatting tokens, see QDate::toString() and + QTime::toString(). As described above, the provided date, time and date-time + determine which of these tokens are recognized: where these appear in \a + format they are replaced by data. Any text in \a format not recognized as a + format token is copied verbatim into the result string. + + \sa QDate::toString(), QTime::toString(), QDateTime::toString() */ // End of methods implemented in qlocale.cpp @@ -571,16 +574,16 @@ bool QCalendarBackend::registerAlias(const QString &name) } /*! - Returns a pointer to a named calendar backend. + Returns a pointer to a named calendar backend. - If the given \a name is present in availableCalendars(), the backend matching - it is returned; otherwise, \c nullptr is returned. Matching of names ignores - case. Note that this won't provoke construction of a calendar backend, it will - only return ones that have been instantiated (and not yet destroyed) by some - other means. However, calendars available via the QCalendar::System enum are - always registered when this is called. + If the given \a name is present in availableCalendars(), the backend + matching it is returned; otherwise, \c nullptr is returned. Matching of + names ignores case. Note that this won't provoke construction of a calendar + backend, it will only return ones that have been instantiated (and not yet + destroyed) by some other means. However, calendars available via the + QCalendar::System enum are always registered when this is called. - \sa availableCalendars(), registerAlias(), fromEnum() + \sa availableCalendars(), registerAlias(), fromEnum() */ const QCalendarBackend *QCalendarBackend::fromName(QStringView name) { @@ -592,7 +595,7 @@ const QCalendarBackend *QCalendarBackend::fromName(QStringView name) } /*! - \overload + \overload */ const QCalendarBackend *QCalendarBackend::fromName(QLatin1String name) { @@ -604,11 +607,11 @@ const QCalendarBackend *QCalendarBackend::fromName(QLatin1String name) } /*! - Returns a pointer to a calendar backend, specified by enum. + Returns a pointer to a calendar backend, specified by enum. - This will instantiate the indicated calendar (which will enable fromName() to - return it subsequently), but only for the Qt-supported calendars for which - (where relevant) the appropriate feature has been enabled. + This will instantiate the indicated calendar (which will enable fromName() + to return it subsequently), but only for the Qt-supported calendars for + which (where relevant) the appropriate feature has been enabled. */ const QCalendarBackend *QCalendarBackend::fromEnum(QCalendar::System system) { @@ -643,28 +646,29 @@ const QCalendarBackend *QCalendarBackend::fromEnum(QCalendar::System system) } /*! - \since 5.14 - - \class QCalendar - \inmodule QtCore - \reentrant - \brief The QCalendar class describes calendar systems. - - A QCalendar object maps a year, month, and day-number to a specific day - (ultimately identified by its Julian day number), using the rules of a - particular system. + \since 5.14 - The default QCalendar() is a proleptic Gregorian calendar, which has no year - zero. Other calendars may be supported by enabling suitable features or - loading plugins. Calendars supported as features can be constructed by passing - the QCalendar::System enumeration to the constructor. All supported calendars - may be constructed by name, once they have been constructed. (Thus plugins - instantiate their calendar backend to register it.) Built-in backends, - accessible via QCalendar::System, are also always available by name. + \class QCalendar + \inmodule QtCore + \reentrant + \brief The QCalendar class describes calendar systems. + + A QCalendar object maps a year, month, and day-number to a specific day + (ultimately identified by its Julian day number), using the rules of a + particular system. + + The default QCalendar() is a proleptic Gregorian calendar, which has no year + zero. Other calendars may be supported by enabling suitable features or + loading plugins. Calendars supported as features can be constructed by + passing the QCalendar::System enumeration to the constructor. All supported + calendars may be constructed by name, once they have been constructed. (Thus + plugins instantiate their calendar backend to register it.) Built-in + backends, accessible via QCalendar::System, are also always available by + name. - A QCalendar value is immutable. + A QCalendar value is immutable. - \sa QDate, QDateTime + \sa QDate, QDateTime */ /*! @@ -684,20 +688,20 @@ const QCalendarBackend *QCalendarBackend::fromEnum(QCalendar::System system) */ /*! - \fn QCalendar::QCalendar() - \fn QCalendar::QCalendar(QCalendar::System system) - \fn QCalendar::QCalendar(QLatin1String name) - \fn QCalendar::QCalendar(QStringView name) + \fn QCalendar::QCalendar() + \fn QCalendar::QCalendar(QCalendar::System system) + \fn QCalendar::QCalendar(QLatin1String name) + \fn QCalendar::QCalendar(QStringView name) - Constructs a calendar object. + Constructs a calendar object. - The choice of calendar to use may be indicated as \a system, using the - enumeration QCalendar::System, or by \a name, using a string (either Unicode - or Latin 1). Construction by name may depend on an instance of the given - calendar being constructed by other means first. With no argument, the default - constructor returns the Gregorian calendar. + The choice of calendar to use may be indicated as \a system, using the + enumeration QCalendar::System, or by \a name, using a string (either Unicode + or Latin 1). Construction by name may depend on an instance of the given + calendar being constructed by other means first. With no argument, the + default constructor returns the Gregorian calendar. - \sa QCalendar, System + \sa QCalendar, System */ QCalendar::QCalendar() @@ -722,13 +726,13 @@ QCalendar::QCalendar(QStringView name) // Date queries: /*! - Returns the number of days in the given \a month of the given \a year. + Returns the number of days in the given \a month of the given \a year. - Months are numbered consecutively, starting with 1 for the first month of each - year. If \a year is \c Unspecified (its default, if not passed), the month's - length in a normal year is returned. + Months are numbered consecutively, starting with 1 for the first month of + each year. If \a year is \c Unspecified (its default, if not passed), the + month's length in a normal year is returned. - \sa maximumDaysInMonth(), minimumDaysInMonth() + \sa maximumDaysInMonth(), minimumDaysInMonth() */ int QCalendar::daysInMonth(int month, int year) const { @@ -736,7 +740,7 @@ int QCalendar::daysInMonth(int month, int year) const } /*! - Returns the number of days in the given \a year. + Returns the number of days in the given \a year. */ int QCalendar::daysInYear(int year) const { @@ -752,12 +756,12 @@ int QCalendar::monthsInYear(int year) const } /*! - Returns \c true precisely if the given \a year, \a month, and \a day specify a - valid date in this calendar. + Returns \c true precisely if the given \a year, \a month, and \a day specify + a valid date in this calendar. - Usually this means 1 <= month <= monthsInYear(year) and 1 <= day <= - daysInMonth(month, year). However, calendars with intercallary days or months - may complicate that. + Usually this means 1 <= month <= monthsInYear(year) and 1 <= day <= + daysInMonth(month, year). However, calendars with intercallary days or + months may complicate that. */ bool QCalendar::isDateValid(int year, int month, int day) const { @@ -777,13 +781,13 @@ bool QCalendar::isGregorian() const } /*! - Returns \c true if the given \a year is a leap year. + Returns \c true if the given \a year is a leap year. - Since the year is not a whole number of days long, some years are longer than - others. The difference may be a whole month or just a single day; the details - vary between calendars. + Since the year is not a whole number of days long, some years are longer + than others. The difference may be a whole month or just a single day; the + details vary between calendars. - \sa isDateValid() + \sa isDateValid() */ bool QCalendar::isLeapYear(int year) const { @@ -791,9 +795,9 @@ bool QCalendar::isLeapYear(int year) const } /*! - Returns \c true if this calendar is a lunar calendar. + Returns \c true if this calendar is a lunar calendar. - A lunar calendar is one based primarily on the phases of the moon. + A lunar calendar is one based primarily on the phases of the moon. */ bool QCalendar::isLunar() const { @@ -801,11 +805,11 @@ bool QCalendar::isLunar() const } /*! - Returns \c true if this calendar is luni-solar. + Returns \c true if this calendar is luni-solar. - A luni-solar calendar expresses the phases of the moon but adapts itself to - also keep track of the Sun's varying position in the sky, relative to the - fixed stars. + A luni-solar calendar expresses the phases of the moon but adapts itself to + also keep track of the Sun's varying position in the sky, relative to the + fixed stars. */ bool QCalendar::isLuniSolar() const { @@ -813,10 +817,10 @@ 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 primarily on the Sun's varying position in the sky, - relative to the fixed stars. + A solar calendar is based primarily on the Sun's varying position in the + sky, relative to the fixed stars. */ bool QCalendar::isSolar() const { @@ -824,13 +828,13 @@ bool QCalendar::isSolar() const } /*! - Returns \c true if this calendar is proleptic. + Returns \c true if this calendar is proleptic. - A proleptic calendar is able to describe years arbitrarily long before its - first. These are represented by negative year numbers and possibly by a year - zero. + A proleptic calendar is able to describe years arbitrarily long before its + first. These are represented by negative year numbers and possibly by a year + zero. - \sa hasYearZero() + \sa hasYearZero() */ bool QCalendar::isProleptic() const { @@ -868,9 +872,9 @@ bool QCalendar::hasYearZero() const } /*! - Returns the number of days in the longest month in the calendar, in any year. + Returns the number of days in the longest month in the calendar, in any year. - \sa daysInMonth(), minimumDaysInMonth() + \sa daysInMonth(), minimumDaysInMonth() */ int QCalendar::maximumDaysInMonth() const { @@ -878,9 +882,9 @@ int QCalendar::maximumDaysInMonth() const } /*! - Returns the number of days in the shortest month in the calendar, in any year. + Returns the number of days in the shortest month in the calendar, in any year. - \sa daysInMonth(), maximumDaysInMonth() + \sa daysInMonth(), maximumDaysInMonth() */ int QCalendar::minimumDaysInMonth() const { @@ -888,9 +892,9 @@ int QCalendar::minimumDaysInMonth() const } /*! - Returns the largest number of months that any year may contain. + Returns the largest number of months that any year may contain. - \sa monthName(), standaloneMonthName(), monthsInYear() + \sa monthName(), standaloneMonthName(), monthsInYear() */ int QCalendar::maximumMonthsInYear() const { @@ -940,13 +944,13 @@ QCalendar::YearMonthDay QCalendar::partsFromDate(QDate date) const } /*! - Returns the day of the week number for the given \a date. + Returns the day of the week number for the given \a date. - Returns zero if the calendar is unable to represent the indicated date. - Returns 1 for Monday through 7 for Sunday. Calendars with intercallary days - may use other numbers to represent these. + Returns zero if the calendar is unable to represent the indicated date. + Returns 1 for Monday through 7 for Sunday. Calendars with intercallary days + may use other numbers to represent these. - \sa partsFromDate(), Qt::DayOfWeek + \sa partsFromDate(), Qt::DayOfWeek */ int QCalendar::dayOfWeek(QDate date) const { @@ -956,23 +960,23 @@ int QCalendar::dayOfWeek(QDate date) const // Locale data access /*! - Returns a suitably localised name for a month. + Returns a suitably localised name for a month. - The month is indicated by a number, with \a month = 1 meaning the first month - of the year and subsequent months numbered accordingly. Returns an empty - string if the \a month number is unrecognized. + The month is indicated by a number, with \a month = 1 meaning the first + month of the year and subsequent months numbered accordingly. Returns an + empty string if the \a month number is unrecognized. - The \a year may be Unspecified, in which case the mapping from numbers to - names for a typical year's months should be used. Some calendars have leap - months that aren't always at the end of the year; their mapping of month - numbers to names may then depend on the placement of a leap month. Thus the - year should normally be specified, if known. + The \a year may be Unspecified, in which case the mapping from numbers to + names for a typical year's months should be used. Some calendars have leap + months that aren't always at the end of the year; their mapping of month + numbers to names may then depend on the placement of a leap month. Thus the + year should normally be specified, if known. - The name is returned in the form that would normally be used in a full date, - in the specified \a locale; the \a format determines how fully it shall be - expressed (i.e. to what extent it is abbreviated). + The name is returned in the form that would normally be used in a full date, + in the specified \a locale; the \a format determines how fully it shall be + expressed (i.e. to what extent it is abbreviated). - \sa standaloneMonthName(), maximumMonthsInYear(), dateTimeToString() + \sa standaloneMonthName(), maximumMonthsInYear(), dateTimeToString() */ QString QCalendar::monthName(const QLocale &locale, int month, int year, QLocale::FormatType format) const @@ -985,23 +989,23 @@ QString QCalendar::monthName(const QLocale &locale, int month, int year, } /*! - Returns a suitably localised standalone name for a month. + Returns a suitably localised standalone name for a month. - The month is indicated by a number, with \a month = 1 meaning the first month - of the year and subsequent months numbered accordingly. Returns an empty - string if the \a month number is unrecognized. + The month is indicated by a number, with \a month = 1 meaning the first + month of the year and subsequent months numbered accordingly. Returns an + empty string if the \a month number is unrecognized. - The \a year may be Unspecified, in which case the mapping from numbers to - names for a typical year's months should be used. Some calendars have leap - months that aren't always at the end of the year; their mapping of month - numbers to names may then depend on the placement of a leap month. Thus the - year should normally be specified, if known. + The \a year may be Unspecified, in which case the mapping from numbers to + names for a typical year's months should be used. Some calendars have leap + months that aren't always at the end of the year; their mapping of month + numbers to names may then depend on the placement of a leap month. Thus the + year should normally be specified, if known. - The name is returned in the form that would be used in isolation in the - specified \a locale; the \a format determines how fully it shall be expressed - (i.e. to what extent it is abbreviated). + The name is returned in the form that would be used in isolation in the + specified \a locale; the \a format determines how fully it shall be + expressed (i.e. to what extent it is abbreviated). - \sa monthName(), maximumMonthsInYear(), dateTimeToString() + \sa monthName(), maximumMonthsInYear(), dateTimeToString() */ QString QCalendar::standaloneMonthName(const QLocale &locale, int month, int year, QLocale::FormatType format) const @@ -1014,18 +1018,18 @@ QString QCalendar::standaloneMonthName(const QLocale &locale, int month, int yea } /*! - Returns a suitably localised name for a day of the week. + Returns a suitably localised name for a day of the week. - The days of the week are numbered from 1 for Monday through 7 for Sunday. Some - calendars may support higher numbers for other days (e.g. intercallary days, - that are not part of any week). Returns an empty string if the \a day number - is unrecognized. + The days of the week are numbered from 1 for Monday through 7 for + Sunday. Some calendars may support higher numbers for other days + (e.g. intercallary days, that are not part of any week). Returns an empty + string if the \a day number is unrecognized. - The name is returned in the form that would normally be used in a full date, - in the specified \a locale; the \a format determines how fully it shall be - expressed (i.e. to what extent it is abbreviated). + The name is returned in the form that would normally be used in a full date, + in the specified \a locale; the \a format determines how fully it shall be + expressed (i.e. to what extent it is abbreviated). - \sa standaloneWeekDayName(), dayOfWeek() + \sa standaloneWeekDayName(), dayOfWeek() */ QString QCalendar::weekDayName(const QLocale &locale, int day, QLocale::FormatType format) const @@ -1034,19 +1038,20 @@ QString QCalendar::weekDayName(const QLocale &locale, int day, } /*! - Returns a suitably localised standalone name for a day of the week. + Returns a suitably localised standalone name for a day of the week. - The days of the week are numbered from 1 for Monday through 7 for Sunday. Some - calendars may support higher numbers for other days (e.g. intercallary days, - that are not part of any week). Returns an empty string if the \a day number - is unrecognized. + The days of the week are numbered from 1 for Monday through 7 for + Sunday. Some calendars may support higher numbers for other days + (e.g. intercallary days, that are not part of any week). Returns an empty + string if the \a day number is unrecognized. - The name is returned in the form that would be used in isolation (for example - as a column heading in a calendar's tabular display of a month with successive - weeks as rows) in the specified \a locale; the \a format determines how fully - it shall be expressed (i.e. to what extent it is abbreviated). + The name is returned in the form that would be used in isolation (for + example as a column heading in a calendar's tabular display of a month with + successive weeks as rows) in the specified \a locale; the \a format + determines how fully it shall be expressed (i.e. to what extent it is + abbreviated). - \sa weekDayName(), dayOfWeek() + \sa weekDayName(), dayOfWeek() */ QString QCalendar::standaloneWeekDayName(const QLocale &locale, int day, QLocale::FormatType format) const @@ -1055,23 +1060,23 @@ QString QCalendar::standaloneWeekDayName(const QLocale &locale, int day, } /*! - Returns a string representing a given date, time or date-time. - - If \a datetime is valid, it is represented and format specifiers for both date - and time fields are recognized; otherwise, if \a dateOnly is valid, it is - represented and only format specifiers for date fields are recognized; - finally, if \a timeOnly is valid, it is represented and only format specifiers - for time fields are recognized. If none of these is valid, an empty string is - returned. - - See QDate::toString and QTime::toString() for the supported field specifiers. - Characters in \a format that are recognized as field specifiers are replaced - by text representing appropriate data from the date and/or time being - represented. The texts to represent them may depend on the \a locale - specified. Other charagers in \a format are copied verbatim into the returned - string. - - \sa monthName(), weekDayName(), QDate::toString(), QTime::toString() + Returns a string representing a given date, time or date-time. + + If \a datetime is valid, it is represented and format specifiers for both + date and time fields are recognized; otherwise, if \a dateOnly is valid, it + is represented and only format specifiers for date fields are recognized; + finally, if \a timeOnly is valid, it is represented and only format + specifiers for time fields are recognized. If none of these is valid, an + empty string is returned. + + See QDate::toString and QTime::toString() for the supported field + specifiers. Characters in \a format that are recognized as field specifiers + are replaced by text representing appropriate data from the date and/or time + being represented. The texts to represent them may depend on the \a locale + specified. Other charagers in \a format are copied verbatim into the + returned string. + + \sa monthName(), weekDayName(), QDate::toString(), QTime::toString() */ QString QCalendar::dateTimeToString(QStringView format, const QDateTime &datetime, const QDate &dateOnly, const QTime &timeOnly, diff --git a/src/corelib/time/qhijricalendar.cpp b/src/corelib/time/qhijricalendar.cpp index a0e6905e91..b5d89fbc5c 100644 --- a/src/corelib/time/qhijricalendar.cpp +++ b/src/corelib/time/qhijricalendar.cpp @@ -44,37 +44,37 @@ QT_BEGIN_NAMESPACE /*! - \since 5.14 - \internal + \since 5.14 + \internal - \class QHijriCalendar - \inmodule QtCore - \brief The QHijriCalendar class supports Islamic (Hijri) calendar implementations. + \class QHijriCalendar + \inmodule QtCore + \brief The QHijriCalendar class supports Islamic (Hijri) calendar implementations. - \section1 Islamic Calendar System + \section1 Islamic Calendar System - The Islamic, Muslim, or Hijri calendar is a lunar calendar consisting of 12 - months in a year of 354 or 355 days. It is used (often alongside the - Gregorian calendar) to date events in many Muslim countries. It is also used - by Muslims to determine the proper days of Islamic holidays and rituals, - such as the annual period of fasting and the proper time for the pilgrimage - to Mecca. + The Islamic, Muslim, or Hijri calendar is a lunar calendar consisting of 12 + months in a year of 354 or 355 days. It is used (often alongside the + Gregorian calendar) to date events in many Muslim countries. It is also used + by Muslims to determine the proper days of Islamic holidays and rituals, + such as the annual period of fasting and the proper time for the pilgrimage + to Mecca. - Source: \l {https://en.wikipedia.org/wiki/Islamic_calendar}{Wikipedia page on - Hijri Calendar} + Source: \l {https://en.wikipedia.org/wiki/Islamic_calendar}{Wikipedia page + on Hijri Calendar} - \section1 Support for variants + \section1 Support for variants - This base class provides the common details shared by all variants on the - Islamic calendar. Each year comprises 12 months of 29 or 30 days each; most - years have as many of 29 as of 30, but leap years extend one 29-day month to - 30 days. In tabular versions of the calendar (where mathematical rules are - used to determine the details), odd-numbered months have 30 days, as does the - last (twelfth) month of a leap year; all other months have 29 days. Other - versions are based on actual astronomical observations of the moon's phase at - sunset, which vary from place to place. + This base class provides the common details shared by all variants on the + Islamic calendar. Each year comprises 12 months of 29 or 30 days each; most + years have as many of 29 as of 30, but leap years extend one 29-day month to + 30 days. In tabular versions of the calendar (where mathematical rules are + used to determine the details), odd-numbered months have 30 days, as does + the last (twelfth) month of a leap year; all other months have 29 + days. Other versions are based on actual astronomical observations of the + moon's phase at sunset, which vary from place to place. - \sa QIslamicCivilCalendar, QCalendar + \sa QIslamicCivilCalendar, QCalendar */ bool QHijriCalendar::isLunar() const diff --git a/src/corelib/time/qislamiccivilcalendar.cpp b/src/corelib/time/qislamiccivilcalendar.cpp index 84562849cc..a6a2afd207 100644 --- a/src/corelib/time/qislamiccivilcalendar.cpp +++ b/src/corelib/time/qislamiccivilcalendar.cpp @@ -47,28 +47,29 @@ QT_BEGIN_NAMESPACE using namespace QRoundingDown; /*! - \since 5.14 - \internal + \since 5.14 + \internal - \class QIslamicCivilCalendar - \inmodule QtCore - \brief Implements a commonly-used computed version of the Islamic calendar. + \class QIslamicCivilCalendar + \inmodule QtCore + \brief Implements a commonly-used computed version of the Islamic calendar. - \section1 Civil Islamic Calendar + \section1 Civil Islamic Calendar - QIslamicCivilCalendar implements a tabular version of the Hijri calendar which - is known as the Islamic Civil Calendar. It has the same numbering of years and - months, but the months are determined by arithmetical rules rather than by - observation or astronomical calculations. + QIslamicCivilCalendar implements a tabular version of the Hijri calendar + which is known as the Islamic Civil Calendar. It has the same numbering of + years and months, but the months are determined by arithmetical rules rather + than by observation or astronomical calculations. - \section2 Calendar Organization + \section2 Calendar Organization - The civil calendar follows the usual tabular scheme of odd-numbered months and - the last month of each leap year being 30 days long, the rest being 29 days - long. Its determination of leap years follows a 30-year cycle, in each of - which the years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26 and 29 are leap years. + The civil calendar follows the usual tabular scheme of odd-numbered months + and the last month of each leap year being 30 days long, the rest being 29 + days long. Its determination of leap years follows a 30-year cycle, in each + of which the years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26 and 29 are leap + years. - \sa QHijriCalendar, QCalendar + \sa QHijriCalendar, QCalendar */ QIslamicCivilCalendar::QIslamicCivilCalendar() diff --git a/src/corelib/time/qromancalendar.cpp b/src/corelib/time/qromancalendar.cpp index 36cad01b81..c3cd134490 100644 --- a/src/corelib/time/qromancalendar.cpp +++ b/src/corelib/time/qromancalendar.cpp @@ -44,20 +44,20 @@ QT_BEGIN_NAMESPACE /*! - \since 5.14 + \since 5.14 - \class QRomanCalendar - \inmodule QtCore - \brief The QRomanCalendar class is a shared base for calendars based on the - ancient Roman calendar. + \class QRomanCalendar + \inmodule QtCore + \brief The QRomanCalendar class is a shared base for calendars based on the + ancient Roman calendar. - \section1 + \section1 - Calendars based on the ancient Roman calendar share the names of months, whose - lengths depend in a common way on whether the year is a leap year. They differ - in how they determine which years are leap years. + Calendars based on the ancient Roman calendar share the names of months, + whose lengths depend in a common way on whether the year is a leap + year. They differ in how they determine which years are leap years. - \sa QGregorianCalendar, QJulianCalendar, QMilankovicCalendar + \sa QGregorianCalendar, QJulianCalendar, QMilankovicCalendar */ int QRomanCalendar::daysInMonth(int month, int year) const diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h index 86a16eb32b..3a0c4381f1 100644 --- a/src/corelib/tools/qcontainertools_impl.h +++ b/src/corelib/tools/qcontainertools_impl.h @@ -49,8 +49,6 @@ #include <QtCore/qglobal.h> #include <iterator> -#ifndef Q_QDOC - QT_BEGIN_NAMESPACE namespace QtPrivate @@ -131,6 +129,4 @@ using IfAssociativeIteratorHasFirstAndSecond = QT_END_NAMESPACE -#endif // Q_QDOC - #endif // QCONTAINERTOOLS_IMPL_H diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 047773d8e3..a52e157768 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -100,20 +100,6 @@ static const char *languageForWritingSystem[] = { }; enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; -#ifdef Q_OS_OSX -static NSInteger languageMapSort(id obj1, id obj2, void *context) -{ - NSArray<NSString *> *map1 = reinterpret_cast<NSArray<NSString *> *>(obj1); - NSArray<NSString *> *map2 = reinterpret_cast<NSArray<NSString *> *>(obj2); - NSArray<NSString *> *languages = reinterpret_cast<NSArray<NSString *> *>(context); - - NSString *lang1 = [map1 objectAtIndex:0]; - NSString *lang2 = [map2 objectAtIndex:0]; - - return [languages indexOfObject:lang1] - [languages indexOfObject:lang2]; -} -#endif - QCoreTextFontDatabase::QCoreTextFontDatabase() : m_hasPopulatedAliases(false) { @@ -406,142 +392,99 @@ template class QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>; template class QCoreTextFontDatabaseEngineFactory<QFontEngineFT>; #endif -QFont::StyleHint styleHintFromNSString(NSString *style) +QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family) { - if ([style isEqual: @"sans-serif"]) - return QFont::SansSerif; - else if ([style isEqual: @"monospace"]) - return QFont::Monospace; - else if ([style isEqual: @"cursive"]) - return QFont::Cursive; - else if ([style isEqual: @"serif"]) - return QFont::Serif; - else if ([style isEqual: @"fantasy"]) - return QFont::Fantasy; - else // if ([style isEqual: @"default"]) - return QFont::AnyStyle; -} + if (family.isEmpty()) + return QStringList(); -#ifdef Q_OS_OSX -static QString familyNameFromPostScriptName(NSString *psName) -{ - QCFType<CTFontDescriptorRef> fontDescriptor = (CTFontDescriptorRef) CTFontDescriptorCreateWithNameAndSize((CFStringRef)psName, 12.0); - QCFString familyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontFamilyNameAttribute); - QString name = QString::fromCFString(familyName); - if (name.isEmpty()) - qWarning() << "QCoreTextFontDatabase: Failed to resolve family name for PostScript name " << QString::fromCFString((CFStringRef)psName); + auto attributes = @{ id(kCTFontFamilyNameAttribute): family.toNSString() }; + QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(CFDictionaryRef(attributes)); + if (!fontDescriptor) { + qWarning() << "Failed to create fallback font descriptor for" << family; + return QStringList(); + } - return name; -} -#endif + QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0); + if (!font) { + qWarning() << "Failed to create fallback font for" << family; + return QStringList(); + } -static void addExtraFallbacks(QStringList *fallbackList) -{ -#if defined(Q_OS_MACOS) - // Since we are only returning a list of default fonts for the current language, we do not - // cover all unicode completely. This was especially an issue for some of the common script - // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk - // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most - // of Unicode 2.1. - if (!fallbackList->contains(QStringLiteral("Arial Unicode MS"))) - fallbackList->append(QStringLiteral("Arial Unicode MS")); - // Since some symbols (specifically Braille) are not in Arial Unicode MS, we - // add Apple Symbols to cover those too. - if (!fallbackList->contains(QStringLiteral("Apple Symbols"))) - fallbackList->append(QStringLiteral("Apple Symbols")); -#else - Q_UNUSED(fallbackList) -#endif + QCFType<CFArrayRef> cascadeList = CFArrayRef(CTFontCopyDefaultCascadeListForLanguages(font, + (CFArrayRef)[NSUserDefaults.standardUserDefaults stringArrayForKey:@"AppleLanguages"])); + if (!cascadeList) { + qWarning() << "Failed to create fallback cascade list for" << family; + return QStringList(); + } + + QStringList fallbackList; + const int numCascades = CFArrayGetCount(cascadeList); + for (int i = 0; i < numCascades; ++i) { + CTFontDescriptorRef fontFallback = CTFontDescriptorRef(CFArrayGetValueAtIndex(cascadeList, i)); + QCFString fallbackFamilyName = CFStringRef(CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute)); + fallbackList.append(QString::fromCFString(fallbackFamilyName)); + } + + return fallbackList; } QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { Q_UNUSED(style); - Q_UNUSED(script); QMacAutoReleasePool pool; - static QHash<QString, QStringList> fallbackLists; - - if (!family.isEmpty()) { - QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(family)); - if (QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(attributes)) { - if (QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0)) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"]; - - QCFType<CFArrayRef> cascadeList = (CFArrayRef) CTFontCopyDefaultCascadeListForLanguages(font, (CFArrayRef) languages); - if (cascadeList) { - QStringList fallbackList; - const int numCascades = CFArrayGetCount(cascadeList); - for (int i = 0; i < numCascades; ++i) { - CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i); - QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute); - fallbackList.append(QString::fromCFString(fallbackFamilyName)); - } - - addExtraFallbacks(&fallbackList); - extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &); - fallbackList = qt_sort_families_by_writing_system(script, fallbackList); - - return fallbackList; + QStringList fallbackList = fallbacksForFamily(family); + + if (fallbackList.isEmpty()) { + // We were not able to find a fallback for the specific family, + // or the family was empty, so we fall back to the style hint. + QString styleFamily = [styleHint]{ + switch (styleHint) { + case QFont::SansSerif: return QStringLiteral("Helvetica"); + case QFont::Serif: return QStringLiteral("Times New Roman"); + case QFont::Monospace: return QStringLiteral("Menlo"); +#ifdef Q_OS_MACOS + case QFont::Cursive: return QStringLiteral("Apple Chancery"); +#endif + case QFont::Fantasy: return QStringLiteral("Zapfino"); + case QFont::TypeWriter: return QStringLiteral("American Typewriter"); + case QFont::AnyStyle: Q_FALLTHROUGH(); + case QFont::System: { + QCFType<CTFontRef> font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 12.0, NULL); + return static_cast<QString>(QCFString(CTFontCopyFullName(font))); } + default: return QString(); // No matching font on this platform } + }(); + if (!styleFamily.isEmpty()) { + fallbackList = fallbacksForFamily(styleFamily); + if (!fallbackList.contains(styleFamily)) + fallbackList.prepend(styleFamily); } } - // We were not able to find a fallback for the specific family, - // so we fall back to the stylehint. - - static const QString styleLookupKey = QString::fromLatin1(".QFontStyleHint_%1"); - - static bool didPopulateStyleFallbacks = false; - if (!didPopulateStyleFallbacks) { -#if defined(Q_OS_MACX) - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSArray<NSString *> *languages = [defaults stringArrayForKey:@"AppleLanguages"]; - - NSDictionary<NSString *, id> *fallbackDict = [NSDictionary<NSString *, id> dictionaryWithContentsOfFile:@"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist"]; - - for (NSString *style in [fallbackDict allKeys]) { - NSArray *list = [fallbackDict valueForKey:style]; - QFont::StyleHint fallbackStyleHint = styleHintFromNSString(style); - QStringList fallbackList; - for (id item in list) { - // sort the array based on system language preferences - if ([item isKindOfClass:[NSArray class]]) { - NSArray *langs = [reinterpret_cast<NSArray *>(item) - sortedArrayUsingFunction:languageMapSort context:languages]; - for (NSArray<NSString *> *map in langs) - fallbackList.append(familyNameFromPostScriptName([map objectAtIndex:1])); - } - else if ([item isKindOfClass: [NSString class]]) - fallbackList.append(familyNameFromPostScriptName(item)); - } - - fallbackList.append(QLatin1String("Apple Color Emoji")); + if (fallbackList.isEmpty()) + return fallbackList; - addExtraFallbacks(&fallbackList); - fallbackLists[styleLookupKey.arg(fallbackStyleHint)] = fallbackList; - } -#else - QStringList staticFallbackList; - staticFallbackList << QString::fromLatin1("Helvetica,Apple Color Emoji,Geeza Pro,Arial Hebrew,Thonburi,Kailasa" - "Hiragino Kaku Gothic ProN,.Heiti J,Apple SD Gothic Neo,.Heiti K,Heiti SC,Heiti TC" - "Bangla Sangam MN,Devanagari Sangam MN,Gujarati Sangam MN,Gurmukhi MN,Kannada Sangam MN" - "Malayalam Sangam MN,Oriya Sangam MN,Sinhala Sangam MN,Tamil Sangam MN,Telugu Sangam MN" - "Euphemia UCAS,.PhoneFallback").split(QLatin1String(",")); - - for (int i = QFont::Helvetica; i <= QFont::Fantasy; ++i) - fallbackLists[styleLookupKey.arg(i)] = staticFallbackList; +#if defined(Q_OS_MACOS) + // Since we are only returning a list of default fonts for the current language, we do not + // cover all Unicode completely. This was especially an issue for some of the common script + // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk + // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most + // of Unicode 2.1. + if (!fallbackList.contains(QStringLiteral("Arial Unicode MS"))) + fallbackList.append(QStringLiteral("Arial Unicode MS")); + // Since some symbols (specifically Braille) are not in Arial Unicode MS, we + // add Apple Symbols to cover those too. + if (!fallbackList.contains(QStringLiteral("Apple Symbols"))) + fallbackList.append(QStringLiteral("Apple Symbols")); #endif - didPopulateStyleFallbacks = true; - } + extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &); + fallbackList = qt_sort_families_by_writing_system(script, fallbackList); - Q_ASSERT(!fallbackLists.isEmpty()); - return fallbackLists[styleLookupKey.arg(styleHint)]; + return fallbackList; } QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 05f6ed641c..45e74b99be 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -92,6 +92,7 @@ protected: private: void populateFromDescriptor(CTFontDescriptorRef font, const QString &familyName = QString()); + static QStringList fallbacksForFamily(const QString &family); mutable QString defaultFontName; diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 0bae45382d..28be7bdc38 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -428,12 +428,14 @@ static QVariant::Type qDecodePSQLType(int t) void QPSQLResultPrivate::deallocatePreparedStmt() { - const QString stmt = QStringLiteral("DEALLOCATE ") + preparedStmtId; - PGresult *result = drv_d_func()->exec(stmt); + if (drv_d_func()) { + const QString stmt = QStringLiteral("DEALLOCATE ") + preparedStmtId; + PGresult *result = drv_d_func()->exec(stmt); - if (PQresultStatus(result) != PGRES_COMMAND_OK) - qWarning("Unable to free statement: %s", PQerrorMessage(drv_d_func()->connection)); - PQclear(result); + if (PQresultStatus(result) != PGRES_COMMAND_OK) + qWarning("Unable to free statement: %s", PQerrorMessage(drv_d_func()->connection)); + PQclear(result); + } preparedStmtId.clear(); } diff --git a/src/plugins/styles/windowsvista/main.cpp b/src/plugins/styles/windowsvista/main.cpp index d5048e45b7..5e7bcf5e6e 100644 --- a/src/plugins/styles/windowsvista/main.cpp +++ b/src/plugins/styles/windowsvista/main.cpp @@ -48,7 +48,7 @@ class QWindowsVistaStylePlugin : public QStylePlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "windowsvistastyle.json") public: - QStyle *create(const QString &key); + QStyle *create(const QString &key) override; }; QStyle *QWindowsVistaStylePlugin::create(const QString &key) @@ -56,7 +56,7 @@ QStyle *QWindowsVistaStylePlugin::create(const QString &key) if (key.compare(QLatin1String("windowsvista"), Qt::CaseInsensitive) == 0) return new QWindowsVistaStyle(); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index feb2bc824b..e213d65946 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -44,7 +44,6 @@ #include <qwindow.h> #include <private/qstyleanimation_p.h> #include <private/qstylehelper_p.h> -#include <private/qapplication_p.h> #include <qpa/qplatformnativeinterface.h> QT_BEGIN_NAMESPACE @@ -91,7 +90,7 @@ bool QWindowsVistaStylePrivate::useVista() Checks and returns the style object */ inline QObject *styleObject(const QStyleOption *option) { - return option ? option->styleObject : 0; + return option ? option->styleObject : nullptr; } /* \internal @@ -116,7 +115,7 @@ static inline QImage createAnimationBuffer(const QStyleOption *option, const QWi Used by animations to clone a styleoption and shift its offset */ QStyleOption *clonedAnimationStyleOption(const QStyleOption*option) { - QStyleOption *styleOption = 0; + QStyleOption *styleOption = nullptr; if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) styleOption = new QStyleOptionSlider(*slider); else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(option)) @@ -297,7 +296,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt int oldState = styleObject->property("_q_stylestate").toInt(); oldRect = styleObject->property("_q_stylerect").toRect(); newRect = option->rect; - styleObject->setProperty("_q_stylestate", (int)option->state); + styleObject->setProperty("_q_stylestate", int(option->state)); styleObject->setProperty("_q_stylerect", option->rect); bool doTransition = oldState && @@ -315,7 +314,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt if (doTransition) { QStyleOption *styleOption = clonedAnimationStyleOption(option); - styleOption->state = (QStyle::State)oldState; + styleOption->state = QStyle::State(oldState); QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject)); QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject); @@ -340,7 +339,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt // The end state of the transition is simply the result we would have painted // if the style was not animated. - styleOption->styleObject = 0; + styleOption->styleObject = nullptr; styleOption->state = option->state; proxy()->drawPrimitive(element, styleOption, &endPainter, widget); @@ -355,7 +354,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt //translate state flags to UXTHEME states : if (element == PE_FrameLineEdit) { - theme = OpenThemeData(0, L"Edit"); + theme = OpenThemeData(nullptr, L"Edit"); partId = EP_EDITBORDER_NOSCROLL; if (oldState & State_MouseOver) @@ -373,7 +372,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt toState = ETS_NORMAL; } else { - theme = OpenThemeData(0, L"Button"); + theme = OpenThemeData(nullptr, L"Button"); if (element == PE_IndicatorRadioButton) partId = BP_RADIOBUTTON; else if (element == PE_IndicatorCheckBox) @@ -389,7 +388,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt if (theme && SUCCEEDED(GetThemeTransitionDuration(theme, partId, fromState, toState, TMT_TRANSITIONDURATIONS, &duration))) { - t->setDuration(duration); + t->setDuration(int(duration)); } t->setStartTime(QTime::currentTime()); @@ -534,7 +533,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt else if (state & State_MouseOver) stateId = EBS_HOT; - XPThemeData theme(0, painter, QWindowsXPStylePrivate::EditTheme, + XPThemeData theme(nullptr, painter, QWindowsXPStylePrivate::EditTheme, partId, stateId, rect); if (!theme.isValid()) { QWindowsStyle::drawPrimitive(element, option, painter, widget); @@ -581,27 +580,26 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt p->drawRect(option->rect.adjusted(0, 0, -1, -1)); p->setPen(oldPen); return; - } else { - int stateId = ETS_NORMAL; - if (!(state & State_Enabled)) - stateId = ETS_DISABLED; - else if (state & State_ReadOnly) - stateId = ETS_READONLY; - else if (state & State_MouseOver) - stateId = ETS_HOT; - else if (state & State_HasFocus) - stateId = ETS_SELECTED; - XPThemeData theme(widget, painter, - QWindowsXPStylePrivate::EditTheme, - EP_EDITBORDER_NOSCROLL, stateId, option->rect); - theme.noContent = true; - painter->save(); - QRegion clipRegion = option->rect; - clipRegion -= option->rect.adjusted(2, 2, -2, -2); - painter->setClipRegion(clipRegion); - d->drawBackground(theme); - painter->restore(); } + int stateId = ETS_NORMAL; + if (!(state & State_Enabled)) + stateId = ETS_DISABLED; + else if (state & State_ReadOnly) + stateId = ETS_READONLY; + else if (state & State_MouseOver) + stateId = ETS_HOT; + else if (state & State_HasFocus) + stateId = ETS_SELECTED; + XPThemeData theme(widget, painter, + QWindowsXPStylePrivate::EditTheme, + EP_EDITBORDER_NOSCROLL, stateId, option->rect); + theme.noContent = true; + painter->save(); + QRegion clipRegion = option->rect; + clipRegion -= option->rect.adjusted(2, 2, -2, -2); + painter->setClipRegion(clipRegion); + d->drawBackground(theme); + painter->restore(); } break; @@ -724,7 +722,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt d->drawBackground(theme); } else { QWindowsXPStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget); - break;; + break; } QPixmapCache::insert(key, pixmap); } @@ -770,7 +768,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_Widget: { #if QT_CONFIG(dialogbuttonbox) - const QDialogButtonBox *buttonBox = 0; + const QDialogButtonBox *buttonBox = nullptr; if (qobject_cast<const QMessageBox *> (widget)) buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox")); @@ -844,7 +842,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption int oldState = styleObject->property("_q_stylestate").toInt(); oldRect = styleObject->property("_q_stylerect").toRect(); newRect = option->rect; - styleObject->setProperty("_q_stylestate", (int)option->state); + styleObject->setProperty("_q_stylestate", int(option->state)); styleObject->setProperty("_q_stylerect", option->rect); bool wasDefault = false; @@ -870,7 +868,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject); QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject)); QStyleOption *styleOption = clonedAnimationStyleOption(option); - styleOption->state = (QStyle::State)oldState; + styleOption->state = QStyle::State(oldState); QImage startImage = createAnimationBuffer(option, widget); QPainter startPainter(&startImage); @@ -892,12 +890,12 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption DWORD duration = 0; - const HTHEME theme = OpenThemeData(0, L"Button"); + const HTHEME theme = OpenThemeData(nullptr, L"Button"); int fromState = buttonStateId(oldState, BP_PUSHBUTTON); int toState = buttonStateId(option->state, BP_PUSHBUTTON); if (GetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK) - t->setDuration(duration); + t->setDuration(int(duration)); else t->setDuration(0); t->setStartTime(QTime::currentTime()); @@ -983,7 +981,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (btn->features & QStyleOptionButton::HasMenu) { int mbiw = 0, mbih = 0; - XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ToolBarTheme, + XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::ToolBarTheme, TP_DROPDOWNBUTTON); if (theme.isValid()) { const QSizeF size = theme.size() * QStyleHelper::dpiScaled(1, option); @@ -992,7 +990,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption mbih = qRound(size.height()); } } - QRect ir = subElementRect(SE_PushButtonContents, option, 0); + QRect ir = subElementRect(SE_PushButtonContents, option, nullptr); QStyleOptionButton newBtn = *btn; newBtn.rect = QStyle::visualRect(option->direction, option->rect, QRect(ir.right() - mbiw - 2, @@ -1137,7 +1135,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText; QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal); - uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; + int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; @@ -1177,7 +1175,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption int checkcol = qRound(qreal(25) * factor); const int gutterWidth = qRound(qreal(3) * factor); { - XPThemeData theme(widget, 0, QWindowsXPStylePrivate::MenuTheme, + XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::MenuTheme, MENU_POPUPCHECKBACKGROUND, MBI_HOT); XPThemeData themeSize = theme; themeSize.partId = MENU_POPUPCHECK; @@ -1394,7 +1392,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget); int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget); const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget); - bool isFloating = dw != 0 && dw->isFloating(); + bool isFloating = dw && dw->isFloating(); QRect r = option->rect.adjusted(0, 2, -1, -3); QRect titleRect = r; @@ -1411,7 +1409,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (isFloating) { titleRect.adjust(0, -fw, 0, 0); - if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) + if (widget && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) titleRect.adjust(titleRect.height() + mw, 0, 0, 0); } else { titleRect.adjust(mw, 0, 0, 0); @@ -1517,8 +1515,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle int oldActiveControls = styleObject->property("_q_stylecontrols").toInt(); QRect oldRect = styleObject->property("_q_stylerect").toRect(); - styleObject->setProperty("_q_stylestate", (int)option->state); - styleObject->setProperty("_q_stylecontrols", (int)option->activeSubControls); + styleObject->setProperty("_q_stylestate", int(option->state)); + styleObject->setProperty("_q_stylecontrols", int(option->activeSubControls)); styleObject->setProperty("_q_stylerect", option->rect); bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) || @@ -1562,8 +1560,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle // Draw transition source if (!anim) { - styleOption->state = (QStyle::State)oldState; - styleOption->activeSubControls = (QStyle::SubControl)oldActiveControls; + styleOption->state = QStyle::State(oldState); + styleOption->activeSubControls = QStyle::SubControl(oldActiveControls); proxy()->drawComplexControl(control, styleOption, &startPainter, widget); } else { anim->paint(&startPainter, option); @@ -1814,7 +1812,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle // That however breaks with QtQuickControls where this results in transparent // spinbox background, so if there's no "widget" passed (QtQuickControls case), // let ftheme.noContent be false, which fixes the spinbox rendering in QQC - ftheme.noContent = (widget != NULL); + ftheme.noContent = (widget != nullptr); d->drawBackground(ftheme); } if (sub & SC_SpinBoxUp) { @@ -1871,7 +1869,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget); int minimumHeight; { - XPThemeData theme(widget, 0, + XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::MenuTheme, MENU_POPUPCHECKBACKGROUND, MBI_HOT); XPThemeData themeSize = theme; @@ -1939,7 +1937,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption case SE_PushButtonContents: if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { MARGINS borderSize; - const HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button"); + const HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : nullptr, L"Button"); if (theme) { int stateId = PBS_NORMAL; if (!(option->state & State_Enabled)) @@ -1954,7 +1952,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); rect = option->rect.adjusted(border, border, -border, -border); - if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) { + if (SUCCEEDED(GetThemeMargins(theme, nullptr, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, nullptr, &borderSize))) { rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight, -borderSize.cxRightWidth, -borderSize.cyBottomHeight); rect = visualRect(option->direction, option->rect, rect); @@ -1972,7 +1970,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption int y = option->rect.y(); int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget); - XPThemeData theme(widget, 0, + XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::HeaderTheme, HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect); @@ -2045,7 +2043,7 @@ static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBa bool isMinimized = tb->titleBarState & Qt::WindowMinimized; bool isMaximized = tb->titleBarState & Qt::WindowMaximized; - const uint flags = tb->titleBarFlags; + const auto flags = tb->titleBarFlags; bool retVal = false; switch (sc) { case QStyle::SC_TitleBarContextHelpButton: @@ -2103,7 +2101,7 @@ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, co if (option) { if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) { ret = true; - XPThemeData themeData(widget, 0, + XPThemeData themeData(widget, nullptr, QWindowsXPStylePrivate::ToolTipTheme, TTP_STANDARD, TTSS_NORMAL, option->rect); mask->region = d->region(themeData); @@ -2112,7 +2110,7 @@ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, co break; case SH_Table_GridLineColor: if (option) - ret = option->palette.color(QPalette::Base).darker(118).rgb(); + ret = int(option->palette.color(QPalette::Base).darker(118).rgb()); else ret = -1; break; @@ -2323,7 +2321,7 @@ void QWindowsVistaStyle::polish(QWidget *widget) //we do not have to care about unpolishing widget->setContentsMargins(3, 0, 4, 0); COLORREF bgRef; - HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP"); + HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : nullptr, L"TOOLTIP"); if (theme && SUCCEEDED(GetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef))) { QColor textColor = QColor::fromRgb(bgRef); QPalette pal; @@ -2463,7 +2461,7 @@ QIcon QWindowsVistaStyle::standardIcon(StandardPixmap standardIcon, switch(standardIcon) { case SP_CommandLink: { - XPThemeData theme(0, 0, + XPThemeData theme(nullptr, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_COMMANDLINKGLYPH, CMDLGS_NORMAL); if (theme.isValid()) { diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h index d66b17e9f8..8fef9f9927 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h @@ -162,7 +162,7 @@ class QWindowsVistaAnimation : public QBlendStyleAnimation public: QWindowsVistaAnimation(Type type, QObject *target) : QBlendStyleAnimation(type, target) { } - virtual bool isUpdateNeeded() const; + bool isUpdateNeeded() const override; void paint(QPainter *painter, const QStyleOption *option); }; diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index e2c5bdc924..bf80138b32 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -117,7 +117,7 @@ static inline QBackingStore *backingStoreForWidget(const QWidget *widget) if (const QWidget *topLevel = widget->nativeParentWidget()) if (QBackingStore *topLevelBackingStore = topLevel->backingStore()) return topLevelBackingStore; - return 0; + return nullptr; } static inline HDC hdcForWidgetBackingStore(const QWidget *widget) @@ -127,7 +127,7 @@ static inline HDC hdcForWidgetBackingStore(const QWidget *widget) if (nativeInterface) return static_cast<HDC>(nativeInterface->nativeResourceForBackingStore(QByteArrayLiteral("getDC"), backingStore)); } - return 0; + return nullptr; } // Theme data helper ------------------------------------------------------------------------------ @@ -148,7 +148,7 @@ bool XPThemeData::isValid() HTHEME XPThemeData::handle() { if (!QWindowsXPStylePrivate::useXP()) - return 0; + return nullptr; if (!htheme) htheme = QWindowsXPStylePrivate::createTheme(theme, QWindowsXPStylePrivate::winId(widget)); @@ -175,10 +175,10 @@ RECT XPThemeData::toRECT(const QRect &qr) HRGN XPThemeData::mask(QWidget *widget) { if (!IsThemeBackgroundPartiallyTransparent(handle(), partId, stateId)) - return 0; + return nullptr; HRGN hrgn; - HDC dc = 0; + HDC dc = nullptr; if (widget) dc = hdcForWidgetBackingStore(widget); RECT nativeRect = toRECT(rect); @@ -188,7 +188,7 @@ HRGN XPThemeData::mask(QWidget *widget) // QWindowsXPStylePrivate ------------------------------------------------------------------------- // Static initializations -HWND QWindowsXPStylePrivate::m_vistaTreeViewHelper = 0; +HWND QWindowsXPStylePrivate::m_vistaTreeViewHelper = nullptr; HTHEME QWindowsXPStylePrivate::m_themes[NThemes]; bool QWindowsXPStylePrivate::use_xp = false; QBasicAtomicInt QWindowsXPStylePrivate::ref = Q_BASIC_ATOMIC_INITIALIZER(-1); // -1 based refcounting @@ -227,7 +227,7 @@ bool QWindowsXPStylePrivate::useXP(bool update) { if (!update) return use_xp; - return use_xp = IsThemeActive() && (IsAppThemed() || !QApplication::instance()); + return use_xp = IsThemeActive() && (IsAppThemed() || !QCoreApplication::instance()); } /* \internal @@ -241,7 +241,7 @@ void QWindowsXPStylePrivate::init(bool force) ref.ref(); useXP(true); - std::fill(m_themes, m_themes + NThemes, HTHEME(0)); + std::fill(m_themes, m_themes + NThemes, nullptr); } /* \internal @@ -253,12 +253,12 @@ void QWindowsXPStylePrivate::cleanup(bool force) if (bufferDC && nullBitmap) SelectObject(bufferDC, nullBitmap); DeleteObject(bufferBitmap); - bufferBitmap = 0; + bufferBitmap = nullptr; } if(bufferDC) DeleteDC(bufferDC); - bufferDC = 0; + bufferDC = nullptr; if (ref.deref() && !force) return; @@ -282,7 +282,7 @@ void QWindowsXPStylePrivate::cleanup(bool force) static inline HWND createTreeViewHelperWindow() { if (QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface()) { - void *hwnd = 0; + void *hwnd = nullptr; void *wndProc = reinterpret_cast<void *>(DefWindowProc); if (QMetaObject::invokeMethod(ni, "createMessageWindow", Qt::DirectConnection, Q_RETURN_ARG(void*, hwnd), @@ -292,7 +292,7 @@ static inline HWND createTreeViewHelperWindow() return reinterpret_cast<HWND>(hwnd); } } - return 0; + return nullptr; } bool QWindowsXPStylePrivate::initVistaTreeViewTheming() @@ -305,7 +305,7 @@ bool QWindowsXPStylePrivate::initVistaTreeViewTheming() qWarning("Unable to create the treeview helper window."); return false; } - if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L"explorer", NULL))) { + if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L"explorer", nullptr))) { qErrnoWarning("SetWindowTheme() failed."); cleanupVistaTreeViewTheming(); return false; @@ -317,7 +317,7 @@ void QWindowsXPStylePrivate::cleanupVistaTreeViewTheming() { if (m_vistaTreeViewHelper) { DestroyWindow(m_vistaTreeViewHelper); - m_vistaTreeViewHelper = 0; + m_vistaTreeViewHelper = nullptr; } } @@ -328,11 +328,12 @@ void QWindowsXPStylePrivate::cleanupVistaTreeViewTheming() */ void QWindowsXPStylePrivate::cleanupHandleMap() { - for (int i = 0; i < NThemes; ++i) - if (m_themes[i]) { - CloseThemeData(m_themes[i]); - m_themes[i] = 0; + for (auto &theme : m_themes) { + if (theme) { + CloseThemeData(theme); + theme = nullptr; } + } QWindowsXPStylePrivate::cleanupVistaTreeViewTheming(); } @@ -340,7 +341,7 @@ HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd) { if (Q_UNLIKELY(theme < 0 || theme >= NThemes || !hwnd)) { qWarning("Invalid parameters #%d, %p", theme, hwnd); - return 0; + return nullptr; } if (!m_themes[theme]) { const wchar_t *name = themeNames[theme]; @@ -427,16 +428,16 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h) if (bufferDC && nullBitmap) SelectObject(bufferDC, nullBitmap); DeleteObject(bufferBitmap); - bufferBitmap = 0; + bufferBitmap = nullptr; } w = qMax(bufferW, w); h = qMax(bufferH, h); if (!bufferDC) { - HDC displayDC = GetDC(0); + HDC displayDC = GetDC(nullptr); bufferDC = CreateCompatibleDC(displayDC); - ReleaseDC(0, displayDC); + ReleaseDC(nullptr, displayDC); } // Define the header @@ -450,22 +451,22 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h) bmi.bmiHeader.biCompression = BI_RGB; // Create the pixmap - bufferPixels = 0; - bufferBitmap = CreateDIBSection(bufferDC, &bmi, DIB_RGB_COLORS, (void **) &bufferPixels, 0, 0); + bufferPixels = nullptr; + bufferBitmap = CreateDIBSection(bufferDC, &bmi, DIB_RGB_COLORS, reinterpret_cast<void **>(&bufferPixels), nullptr, 0); GdiFlush(); - nullBitmap = (HBITMAP)SelectObject(bufferDC, bufferBitmap); + nullBitmap = static_cast<HBITMAP>(SelectObject(bufferDC, bufferBitmap)); if (Q_UNLIKELY(!bufferBitmap)) { qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() failed.", w, h); bufferW = 0; bufferH = 0; - return 0; + return nullptr; } if (Q_UNLIKELY(!bufferPixels)) { qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() did not allocate pixel data.", w, h); bufferW = 0; bufferH = 0; - return 0; + return nullptr; } bufferW = w; bufferH = h; @@ -493,7 +494,7 @@ bool QWindowsXPStylePrivate::isTransparent(XPThemeData &themeData) */ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData) { - HRGN hRgn = 0; + HRGN hRgn = nullptr; const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(themeData.widget); RECT rect = themeData.toRECT(QRect(themeData.rect.topLeft() / factor, themeData.rect.size() / factor)); if (!SUCCEEDED(GetThemeBackgroundRegion(themeData.handle(), bufferHDC(), themeData.partId, @@ -502,12 +503,12 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData) } HRGN dest = CreateRectRgn(0, 0, 0, 0); - const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR; + const bool success = CombineRgn(dest, hRgn, nullptr, RGN_COPY) != ERROR; QRegion region; if (success) { - int numBytes = GetRegionData(dest, 0, 0); + const auto numBytes = GetRegionData(dest, 0, nullptr); if (numBytes == 0) return QRegion(); @@ -551,7 +552,7 @@ bool QWindowsXPStylePrivate::hasAlphaChannel(const QRect &rect) int firstAlpha = -1; for (int y = startY; y < h/2; ++y) { - DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW); + auto buffer = reinterpret_cast<const DWORD *>(bufferPixels) + (y * bufferW); for (int x = startX; x < w; ++x, ++buffer) { int alpha = (*buffer) >> 24; if (firstAlpha == -1) @@ -580,7 +581,7 @@ bool QWindowsXPStylePrivate::fixAlphaChannel(const QRect &rect) bool hasFixedAlphaValue = false; for (int y = startY; y < h; ++y) { - DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW); + auto buffer = reinterpret_cast<DWORD *>(bufferPixels) + (y * bufferW); for (int x = startX; x < w; ++x, ++buffer) { uint pixel = *buffer; int alpha = qAlpha(pixel); @@ -612,7 +613,7 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels) // Flip the alphas, so that 255-alpha pixels are 0, and 0-alpha are 255. for (int y = startY; y < h; ++y) { - DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW); + auto buffer = reinterpret_cast<DWORD *>(bufferPixels) + (y * bufferW); for (int x = startX; x < w; ++x, ++buffer) { if (allPixels) { *buffer |= 0xFF000000; @@ -668,7 +669,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) return true; QPainter *painter = themeData.painter; - Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter"); + Q_ASSERT_X(painter != nullptr, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter"); if (!painter || !painter->isActive()) return false; @@ -706,7 +707,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) } } - const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); + const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : nullptr; const bool result = dc ? drawBackgroundDirectly(dc, themeData, aditionalDevicePixelRatio) : drawBackgroundThruNativeBuffer(themeData, aditionalDevicePixelRatio); @@ -740,7 +741,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa { QPainter *painter = themeData.painter; - const auto deviceTransform = painter->deviceTransform(); + const auto &deviceTransform = painter->deviceTransform(); const QPointF redirectionDelta(deviceTransform.dx(), deviceTransform.dy()); const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect(); @@ -771,7 +772,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa | (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0); const HRESULT result = DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions); - SelectClipRgn(dc, 0); + SelectClipRgn(dc, nullptr); DeleteObject(hrgn); return SUCCEEDED(result); } @@ -1099,9 +1100,7 @@ QWindowsXPStyle::QWindowsXPStyle() /*! Destroys the style. */ -QWindowsXPStyle::~QWindowsXPStyle() -{ -} +QWindowsXPStyle::~QWindowsXPStyle() = default; /*! \reimp */ void QWindowsXPStyle::unpolish(QApplication *app) @@ -1157,7 +1156,7 @@ void QWindowsXPStyle::polish(QWidget *widget) if (!d->hasInitColors) { // Get text color for group box labels COLORREF cref; - XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, 0, 0); + XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, 0, 0); GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref); d->groupBoxTextColor = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref)); GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref); @@ -1270,7 +1269,7 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option, if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { MARGINS borderSize; if (widget) { - XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme); + XPThemeData buttontheme(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme); HTHEME theme = buttontheme.handle(); if (theme) { int stateId; @@ -1288,7 +1287,7 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option, int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); rect = option->rect.adjusted(border, border, -border, -border); - if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) { + if (SUCCEEDED(GetThemeMargins(theme, nullptr, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, nullptr, &borderSize))) { rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight, -borderSize.cxRightWidth, -borderSize.cyBottomHeight); rect = visualRect(option->direction, option->rect, rect); @@ -1468,7 +1467,7 @@ case PE_Frame: return; themeNumber = QWindowsXPStylePrivate::ListViewTheme; partId = LVP_LISTGROUP; - XPThemeData theme(widget, 0, themeNumber, partId, 0); + XPThemeData theme(widget, nullptr, themeNumber, partId); if (!(flags & State_Enabled)) stateId = ETS_DISABLED; @@ -1496,9 +1495,9 @@ case PE_Frame: p->drawRect(QRectF(option->rect).adjusted(0, 0, -topLevelAdjustment, -topLevelAdjustment)); p->setPen(oldPen); return; - } else if (fillType == BT_NONE) { - return; } + if (fillType == BT_NONE) + return; } break; } @@ -1514,7 +1513,8 @@ case PE_Frame: p->drawRect(option->rect.adjusted(0, 0, -1, -1)); p->setPen(oldPen); return; - } else if (qstyleoption_cast<const QStyleOptionFrame *>(option)) { + } + if (qstyleoption_cast<const QStyleOptionFrame *>(option)) { themeNumber = QWindowsXPStylePrivate::EditTheme; partId = EP_EDITTEXT; noContent = true; @@ -1538,7 +1538,7 @@ case PE_Frame: if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) { p->fillRect(panel->rect, panel->palette.brush(QPalette::Base)); } else { - XPThemeData theme(0, p, themeNumber, partId, stateId, rect); + XPThemeData theme(nullptr, p, themeNumber, partId, stateId, rect); if (!theme.isValid()) { QWindowsStyle::drawPrimitive(pe, option, p, widget); return; @@ -1587,9 +1587,9 @@ case PE_Frame: wchar_t themeFileName[maxlength]; wchar_t themeColor[maxlength]; // Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it - if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) { - wchar_t *offset = 0; - if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) { + if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, nullptr, 0) == S_OK) { + wchar_t *offset = nullptr; + if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != nullptr) { offset++; if (!lstrcmp(offset, L"Luna.msstyles") && !lstrcmp(offset, L"Metallic")) { useGradient = false; @@ -1820,7 +1820,7 @@ case PE_Frame: bef_v -= delta; aft_h += delta; aft_v += delta; - XPThemeData theme(0, p, QWindowsXPStylePrivate::XpTreeViewTheme); + XPThemeData theme(nullptr, p, QWindowsXPStylePrivate::XpTreeViewTheme); theme.rect = QRect(bef_h, bef_v, decoration_size, decoration_size); theme.partId = TVP_GLYPH; theme.stateId = flags & QStyle::State_Open ? GLPS_OPENED : GLPS_CLOSED; @@ -1912,7 +1912,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op { themeNumber = QWindowsXPStylePrivate::StatusTheme; partId = SP_GRIPPER; - XPThemeData theme(0, p, themeNumber, partId, 0); + XPThemeData theme(nullptr, p, themeNumber, partId); QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); size.rheight()--; if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) { @@ -1980,7 +1980,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op if (btn->features & QStyleOptionButton::HasMenu) { int mbiw = 0, mbih = 0; - XPThemeData theme(widget, 0, + XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::ToolBarTheme, TP_SPLITBUTTONDROPDOWN); if (theme.isValid()) { @@ -2309,7 +2309,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op if (isFloating) { titleRect.adjust(0, -fw, 0, 0); - if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) + if (widget != nullptr && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) titleRect.adjust(titleRect.height() + mw, 0, 0, 0); } else { titleRect.adjust(mw, 0, 0, 0); @@ -2775,7 +2775,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo break; v = nextInterval; } - if (lines.size() > 0) { + if (!lines.isEmpty()) { p->save(); p->translate(slrect.topLeft()); p->drawLines(lines.constData(), lines.size()); @@ -2923,7 +2923,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo p->save(); p->setClipRect(menuarea); tool.rect = option->rect; - proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, 0); + proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, nullptr); p->restore(); } // Draw arrow @@ -3223,7 +3223,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } } -static inline Qt::Orientation progressBarOrientation(const QStyleOption *option = 0) +static inline Qt::Orientation progressBarOrientation(const QStyleOption *option = nullptr) { if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) return pb->orientation; @@ -3234,27 +3234,27 @@ int QWindowsXPStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, cons { switch (pm) { case QStyle::PM_IndicatorWidth: - return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).width(); + return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).width(); case QStyle::PM_IndicatorHeight: - return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).height(); + return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).height(); case QStyle::PM_ExclusiveIndicatorWidth: - return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).width(); + return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).width(); case QStyle::PM_ExclusiveIndicatorHeight: - return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).height(); + return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).height(); case QStyle::PM_ProgressBarChunkWidth: return progressBarOrientation(option) == Qt::Horizontal - ? XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNK).width() - : XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNKVERT).height(); + ? XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNK).width() + : XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNKVERT).height(); case QStyle::PM_SliderThickness: - return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::TrackBarTheme, TKP_THUMB).height(); + return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::TrackBarTheme, TKP_THUMB).height(); case QStyle::PM_TitleBarHeight: return widget && (widget->windowType() == Qt::Tool) ? GetSystemMetrics(SM_CYSMCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME) : GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME); case QStyle::PM_MdiSubWindowFrameWidth: - return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_FRAMELEFT, FS_ACTIVE).width(); + return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_FRAMELEFT, FS_ACTIVE).width(); case QStyle::PM_DockWidgetFrameWidth: - return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_SMALLFRAMERIGHT, FS_ACTIVE).width(); + return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_SMALLFRAMERIGHT, FS_ACTIVE).width(); default: break; } @@ -3620,7 +3620,7 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt case CT_LineEdit: case CT_ComboBox: { - XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL); + XPThemeData buttontheme(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL); if (buttontheme.isValid()) { const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget); const QMarginsF borderSize = buttontheme.margins() * factor; @@ -3741,11 +3741,11 @@ int QWindowsXPStyle::styleHint(StyleHint hint, const QStyleOption *option, const titleBarRect.setHeight(tbHeight); XPThemeData themeData; if (titlebar->titleBarState & Qt::WindowMinimized) { - themeData = XPThemeData(widget, 0, + themeData = XPThemeData(widget, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_MINCAPTION, CS_ACTIVE, titleBarRect); } else - themeData = XPThemeData(widget, 0, + themeData = XPThemeData(widget, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_CAPTION, CS_ACTIVE, titleBarRect); mask->region = d->region(themeData) + @@ -3774,10 +3774,8 @@ int QWindowsXPStyle::styleHint(StyleHint hint, const QStyleOption *option, const /*! \reimp */ QPalette QWindowsXPStyle::standardPalette() const { - if (QWindowsXPStylePrivate::useXP() && QApplicationPrivate::sys_pal) - return *QApplicationPrivate::sys_pal; - else - return QWindowsStyle::standardPalette(); + return QWindowsXPStylePrivate::useXP() && QApplicationPrivate::sys_pal + ? *QApplicationPrivate::sys_pal : QWindowsStyle::standardPalette(); } /*! @@ -3795,7 +3793,7 @@ QPixmap QWindowsXPStyle::standardPixmap(StandardPixmap standardPixmap, const QSt if (qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { if (widget && widget->isWindow()) { - XPThemeData theme(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); + XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); if (theme.isValid()) { const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); return QIcon(QWindowsStyle::standardPixmap(standardPixmap, option, widget)).pixmap(size); @@ -3826,9 +3824,9 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon, if (qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { if (d->dockFloat.isNull()) { - XPThemeData themeSize(0, 0, QWindowsXPStylePrivate::WindowTheme, + XPThemeData themeSize(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); - XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme, + XPThemeData theme(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_MAXBUTTON, MAXBS_NORMAL); if (theme.isValid()) { const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); @@ -3862,7 +3860,7 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon, if (qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { if (d->dockClose.isNull()) { - XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme, + XPThemeData theme(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); if (theme.isValid()) { const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); @@ -3896,9 +3894,9 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon, if (qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { if (d->dockFloat.isNull()) { - XPThemeData themeSize(0, 0, QWindowsXPStylePrivate::WindowTheme, + XPThemeData themeSize(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); - XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme, + XPThemeData theme(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_RESTOREBUTTON, RBS_NORMAL); if (theme.isValid()) { const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle_p_p.h b/src/plugins/styles/windowsvista/qwindowsxpstyle_p_p.h index 60f9d7e9b7..ad7754e3d4 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle_p_p.h +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle_p_p.h @@ -100,11 +100,11 @@ class QDebug; class XPThemeData { public: - explicit XPThemeData(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, + explicit XPThemeData(const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1, int part = 0, int state = 0, const QRect &r = QRect()) - : widget(w), painter(p), theme(themeIn), htheme(0), partId(part), stateId(state), + : widget(w), painter(p), theme(themeIn), partId(part), stateId(state), mirrorHorizontally(false), mirrorVertically(false), noBorder(false), - noContent(false), rotate(0), rect(r) + noContent(false), rect(r) {} HRGN mask(QWidget *widget); @@ -117,17 +117,17 @@ public: QMarginsF margins(const QRect &rect, int propId = TMT_CONTENTMARGINS); QMarginsF margins(int propId = TMT_CONTENTMARGINS); - static QSizeF themeSize(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, int part = 0, int state = 0); - static QMarginsF themeMargins(const QRect &rect, const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, + static QSizeF themeSize(const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1, int part = 0, int state = 0); + static QMarginsF themeMargins(const QRect &rect, const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1, int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS); - static QMarginsF themeMargins(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, + static QMarginsF themeMargins(const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1, int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS); const QWidget *widget; QPainter *painter; int theme; - HTHEME htheme; + HTHEME htheme = nullptr; int partId; int stateId; @@ -135,18 +135,18 @@ public: uint mirrorVertically : 1; uint noBorder : 1; uint noContent : 1; - uint rotate; + uint rotate = 0; QRect rect; }; struct ThemeMapKey { - int theme; - int partId; - int stateId; - bool noBorder; - bool noContent; + int theme = 0; + int partId = -1; + int stateId = -1; + bool noBorder = false; + bool noContent = false; - ThemeMapKey() : partId(-1), stateId(-1) {} + ThemeMapKey() = default; ThemeMapKey(const XPThemeData &data) : theme(data.theme), partId(data.partId), stateId(data.stateId), noBorder(data.noBorder), noContent(data.noContent) {} @@ -171,7 +171,7 @@ enum AlphaChannelType { }; struct ThemeMapData { - AlphaChannelType alphaType; // Which type of alpha on part & state + AlphaChannelType alphaType = UnknownAlpha; // Which type of alpha on part & state bool dataValid : 1; // Only used to detect if hash value is ok bool partIsTransparent : 1; @@ -217,15 +217,13 @@ public: }; QWindowsXPStylePrivate() - : QWindowsStylePrivate(), hasInitColors(false), bufferDC(0), bufferBitmap(0), nullBitmap(0), - bufferPixels(0), bufferW(0), bufferH(0) { init(); } ~QWindowsXPStylePrivate() { cleanup(); } - static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0); - static int fixedPixelMetric(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0); + static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr); + static int fixedPixelMetric(QStyle::PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr); static HWND winId(const QWidget *widget); @@ -251,10 +249,10 @@ public: bool fixAlphaChannel(const QRect &rect); bool swapAlphaChannel(const QRect &rect, bool allPixels = false); - QRgb groupBoxTextColor; - QRgb groupBoxTextColorDisabled; - QRgb sliderTickColor; - bool hasInitColors; + QRgb groupBoxTextColor = 0; + QRgb groupBoxTextColorDisabled = 0; + QRgb sliderTickColor = 0; + bool hasInitColors = false; static HTHEME createTheme(int theme, HWND hwnd); static QString themeName(int theme); @@ -277,11 +275,12 @@ private: static bool use_xp; QHash<ThemeMapKey, ThemeMapData> alphaCache; - HDC bufferDC; - HBITMAP bufferBitmap; - HBITMAP nullBitmap; - uchar *bufferPixels; - int bufferW, bufferH; + HDC bufferDC = nullptr; + HBITMAP bufferBitmap = nullptr; + HBITMAP nullBitmap = nullptr; + uchar *bufferPixels = nullptr; + int bufferW = 0; + int bufferH = 0; static HWND m_vistaTreeViewHelper; static HTHEME m_themes[NThemes]; @@ -292,7 +291,7 @@ inline QSizeF XPThemeData::size() QSizeF result(0, 0); if (isValid()) { SIZE size; - if (SUCCEEDED(GetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size))) + if (SUCCEEDED(GetThemePartSize(handle(), nullptr, partId, stateId, nullptr, TS_TRUE, &size))) result = QSize(size.cx, size.cy); } return result; @@ -304,7 +303,7 @@ inline QMarginsF XPThemeData::margins(const QRect &qRect, int propId) if (isValid()) { MARGINS margins; RECT rect = XPThemeData::toRECT(qRect); - if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, &rect, &margins))) + if (SUCCEEDED(GetThemeMargins(handle(), nullptr, partId, stateId, propId, &rect, &margins))) result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight); } return result; @@ -315,7 +314,7 @@ inline QMarginsF XPThemeData::margins(int propId) QMarginsF result(0, 0, 0 ,0); if (isValid()) { MARGINS margins; - if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins))) + if (SUCCEEDED(GetThemeMargins(handle(), nullptr, partId, stateId, propId, nullptr, &margins))) result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight); } return result; diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 72c803cb99..8496a2c223 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -120,10 +120,7 @@ enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight }; \internal */ -QWindowsStylePrivate::QWindowsStylePrivate() - : alt_down(false), menuBarTimer(0) -{ -} +QWindowsStylePrivate::QWindowsStylePrivate() = default; qreal QWindowsStylePrivate::appDevicePixelRatio() { @@ -157,7 +154,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) QList<QWidget *> l = widget->findChildren<QWidget *>(); auto ignorable = [](QWidget *w) { return w->isWindow() || !w->isVisible() - || w->style()->styleHint(SH_UnderlineShortcut, 0, w); + || w->style()->styleHint(SH_UnderlineShortcut, nullptr, w); }; l.erase(std::remove_if(l.begin(), l.end(), ignorable), l.end()); // Update states before repainting @@ -242,7 +239,7 @@ void QWindowsStyle::polish(QApplication *app) QCommonStyle::polish(app); QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func()); // We only need the overhead when shortcuts are sometimes hidden - if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app) + if (!proxy()->styleHint(SH_UnderlineShortcut, nullptr) && app) app->installEventFilter(this); const auto &palette = QGuiApplication::palette(); @@ -343,7 +340,6 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm) case QStyle::PM_MenuVMargin: case QStyle::PM_ToolBarItemMargin: return 1; - break; case QStyle::PM_DockWidgetSeparatorExtent: return 4; #if QT_CONFIG(tabbar) @@ -396,8 +392,6 @@ static QScreen *screenOf(const QWidget *w) // and account for secondary screens with differing logical DPI. qreal QWindowsStylePrivate::nativeMetricScaleFactor(const QWidget *widget) { - if (!QHighDpiScaling::isActive()) - return 1; qreal result = qreal(1) / QWindowsStylePrivate::devicePixelRatio(widget); if (QGuiApplicationPrivate::screen_list.size() > 1) { const QScreen *primaryScreen = QGuiApplication::primaryScreen(); @@ -698,17 +692,17 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, x -= 2; if (opt->rect.height() > 4) { qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); } } else { if (opt->rect.width() > 4) { int y = opt->rect.height() / 2 - 4; qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); } } p->restore(); @@ -759,7 +753,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } } else { qDrawWinButton(p, opt->rect, opt->palette, - opt->state & (State_Sunken | State_On), panel ? &fill : 0); + opt->state & (State_Sunken | State_On), panel ? &fill : nullptr); } } else { p->fillRect(opt->rect, fill); @@ -980,7 +974,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, if (opt->state & (State_Raised | State_On | State_Sunken)) { qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On), - panel ? &fill : 0); + panel ? &fill : nullptr); } else { if (panel) p->fillRect(opt->rect, fill); @@ -1005,7 +999,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, #endif // QT_CONFIG(dockwidget) case PE_FrameStatusBarItem: - qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0); + qDrawShadePanel(p, opt->rect, opt->palette, true, 1, nullptr); break; case PE_IndicatorProgressChunk: @@ -1043,7 +1037,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, break; case PE_FrameTabWidget: { - qDrawWinButton(p, opt->rect, opt->palette, false, 0); + qDrawWinButton(p, opt->rect, opt->palette, false, nullptr); break; } default: @@ -1585,6 +1579,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai case QStyleOptionToolBar::Beginning: case QStyleOptionToolBar::OnlyOne: paintBottomBorder = false; + break; default: break; } @@ -1600,6 +1595,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai case QStyleOptionToolBar::OnlyOne: paintRightBorder = false; paintLeftBorder = false; + break; default: break; } diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index e6ea809f11..4f6ffcefc2 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -77,9 +77,9 @@ public: bool hasSeenAlt(const QWidget *widget) const; bool altDown() const { return alt_down; } - bool alt_down; + bool alt_down = false; QList<const QWidget *> seenAlt; - int menuBarTimer; + int menuBarTimer = 0; QColor inactiveCaptionText; QColor activeCaptionColor; diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 3123c42326..ef4325d2ea 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -3389,8 +3389,15 @@ void tst_QUrl::acceptEmptyAuthoritySegments() void tst_QUrl::effectiveTLDs_data() { + // See also: tst_QNetworkCookieJar::setCookiesFromUrl(). + // in tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp QTest::addColumn<QUrl>("domain"); QTest::addColumn<QString>("TLD"); + // TODO: autogenerate test-cases from: + // https://raw.githubusercontent.com/publicsuffix/list/master/tests/test_psl.txt + // checkPublicSuffix(domain, tail) appears in the list if + // either tail is null and domain is public or + // tail is the "registrable" part of domain; i.e. its minimal non-public tail. QTest::newRow("yes0") << QUrl::fromEncoded("http://test.co.uk") << ".co.uk"; QTest::newRow("yes1") << QUrl::fromEncoded("http://test.com") << ".com"; diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 96f3b1c1d7..1ee9105cd2 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -539,10 +539,10 @@ void tst_QFont::defaultFamily_data() QTest::addColumn<QStringList>("acceptableFamilies"); QTest::newRow("serif") << QFont::Serif << (QStringList() << "Times New Roman" << "Times" << "Droid Serif" << getPlatformGenericFont("serif").split(",")); - QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << "Droid Sans Mono" << getPlatformGenericFont("monospace").split(",")); + QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << "Menlo" << "Droid Sans Mono" << getPlatformGenericFont("monospace").split(",")); QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << "Roboto" << "Droid Sans" << getPlatformGenericFont("cursive").split(",")); QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << "Roboto" << "Droid Sans" << getPlatformGenericFont("fantasy").split(",")); - QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << "Segoe UI" << getPlatformGenericFont("sans-serif").split(",")); + QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Helvetica" << "Roboto" << "Droid Sans" << "Segoe UI" << getPlatformGenericFont("sans-serif").split(",")); } void tst_QFont::defaultFamily() diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 1ef2c118b9..0924b1e223 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -166,6 +166,10 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() // 2. anything .ck is an effective TLD ('*.ck'), but 'www.ck' is an exception result.clear(); preset.clear(); + cookie.setDomain(".ck"); + QTest::newRow("effective-tld.ck-denied") << preset << cookie << "http://foo.ck" << result << false; + result.clear(); + preset.clear(); cookie.setDomain(".foo.ck"); result += cookie; QTest::newRow("effective-tld2-accepted2") << preset << cookie << "http://foo.ck" << result << true; diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 1724d3ce8c..3e372b76f5 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -8906,7 +8906,8 @@ void tst_QWidget::translucentWidget() widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size())); #endif const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32); - const QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size()); + QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size()); + expected.setDevicePixelRatio(label.devicePixelRatioF()); if (m_platform == QStringLiteral("winrt")) QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(actual.size(),expected.size()); |