diff options
author | Zeno Albisser <zeno.albisser@nokia.com> | 2011-03-21 08:26:27 (GMT) |
---|---|---|
committer | Zeno Albisser <zeno.albisser@nokia.com> | 2011-03-21 08:26:27 (GMT) |
commit | 209201b7047c605405a83e9c104f8c81f9195feb (patch) | |
tree | 3e2768430364eaee879a3a134579003e781bc7e4 /src | |
parent | 08d5655d4ac291f97d164c96ecfe0a0d7e4ba654 (diff) | |
download | Qt-209201b7047c605405a83e9c104f8c81f9195feb.zip Qt-209201b7047c605405a83e9c104f8c81f9195feb.tar.gz Qt-209201b7047c605405a83e9c104f8c81f9195feb.tar.bz2 |
replaced weekendStart and weekendEnd with weekdays function
Reviewed-by: Denis Dzyubenko
Task-number: QTBUG-17088
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 37 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.h | 6 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.qdoc | 3 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 1 |
4 files changed, 20 insertions, 27 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 3f250ec..5ac0cf0 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2097,35 +2097,30 @@ QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const /*! \since 4.8 - Returns the first day of the weekend according to the current locale. + Returns a list of days that are considered weekdays according to the current locale. */ -Qt::DayOfWeek QLocale::weekendStart() const +QList<Qt::DayOfWeek> QLocale::weekdays() const { #ifndef QT_NO_SYSTEMLOCALE if (d() == systemPrivate()) { - QVariant res = systemLocale()->query(QSystemLocale::WeekendStart, QVariant()); + QVariant res = systemLocale()->query(QSystemLocale::Weekdays, QVariant()); if (!res.isNull()) - return static_cast<Qt::DayOfWeek>(res.toUInt()); + return static_cast<QList<Qt::DayOfWeek> >(res.value<QList<Qt::DayOfWeek> >()); } #endif - return static_cast<Qt::DayOfWeek>(d()->m_weekend_start); -} - -/*! - \since 4.8 - - Returns the last day of the weekend according to the current locale. -*/ -Qt::DayOfWeek QLocale::weekendEnd() const -{ -#ifndef QT_NO_SYSTEMLOCALE - if (d() == systemPrivate()) { - QVariant res = systemLocale()->query(QSystemLocale::WeekendEnd, QVariant()); - if (!res.isNull()) - return static_cast<Qt::DayOfWeek>(res.toUInt()); + QList<Qt::DayOfWeek> weekdays; + quint16 weekendStart = d()->m_weekend_start; + quint16 weekendEnd = d()->m_weekend_end; + for(int day = Qt::Monday; day <= Qt::Sunday; day++) { + if(weekendEnd > weekendStart) { + if(day < weekendStart || day > weekendEnd) + weekdays << static_cast<Qt::DayOfWeek>(day); + } else { + if(day > weekendEnd && day < weekendStart) + weekdays << static_cast<Qt::DayOfWeek>(day); + } } -#endif - return static_cast<Qt::DayOfWeek>(d()->m_weekend_end); + return weekdays; } /*! diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 4736bfc..71eec47 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -106,8 +106,7 @@ public: AMText, // QString PMText, // QString FirstDayOfWeek, // Qt::DayOfWeek - WeekendStart, // Qt::DayOfWeek - WeekendEnd, // Qt::DayOfWeek + Weekdays, // QList<Qt::DayOfWeek> CurrencySymbol, // QString in: CurrencyToStringArgument CurrencyToString, // QString in: qlonglong, qulonglong or double UILanguages, // QStringList @@ -712,8 +711,7 @@ public: QString standaloneDayName(int, FormatType format = LongFormat) const; Qt::DayOfWeek firstDayOfWeek() const; - Qt::DayOfWeek weekendStart() const; - Qt::DayOfWeek weekendEnd() const; + QList<Qt::DayOfWeek> weekdays() const; QString amText() const; QString pmText() const; diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc index 253edb3..ea5ec33 100644 --- a/src/corelib/tools/qlocale.qdoc +++ b/src/corelib/tools/qlocale.qdoc @@ -762,8 +762,7 @@ \value UILanguages a list of strings representing locale names that could be used for UI translation. \value StringToStandardQuotation a QString containing a quoted version of the string ref stored in the in variant using standard quotes. \value StringToAlternateQuotation a QString containing a quoted version of the string ref stored in the in variant using alternate quotes. - \value WeekendStart a Qt::DayOfWeek enum specifying the first day of the weekend - \value WeekendEnd a Qt::DayOfWeek enum specifying the last day of the weekend + \value Weekdays a QList<Qt::DayOfWeek> specifying the regular weekdays */ /*! diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index ab7fde6..5326a77 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -275,5 +275,6 @@ int repeatCount(const QString &s, int i); QT_END_NAMESPACE Q_DECLARE_METATYPE(QStringRef) +Q_DECLARE_METATYPE(QList<Qt::DayOfWeek>) #endif // QLOCALE_P_H |