File indexing completed on 2025-01-19 04:25:15

0001 /*
0002  * Replacement fot QT Bindings that were removed from QT5
0003  * Copyright (C) 2020  Pedro de Carvalho Gomes <pedrogomes81@gmail.com>
0004  *
0005  * This program is free software: you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation, either version 3 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #ifndef CORELOCALE_H
0020 #define CORELOCALE_H
0021 
0022 #include "QtBinding.h"
0023 
0024 #include <QObject>
0025 #include <QLocale>
0026 
0027 class QJSEngine;
0028 
0029 namespace QtBindings
0030 {
0031     namespace Core
0032     {
0033         class Locale : public QObject, public QLocale, public QtBindings::Base<Locale>
0034         {
0035         Q_OBJECT
0036         public:
0037             Q_INVOKABLE Locale();
0038             Q_INVOKABLE Locale(const QString &name);
0039             Q_INVOKABLE Locale(Language language, Country country = AnyCountry);
0040             Q_INVOKABLE Locale(Language language, Script script, Country country);
0041             Q_INVOKABLE Locale(const QLocale &other);
0042             Q_INVOKABLE Locale(const Locale &other);
0043             Q_INVOKABLE static QLocale c();
0044             Q_INVOKABLE static QString countryToString(Country country);
0045             Q_INVOKABLE static QString languageToString(Language language);
0046             Q_INVOKABLE static QString scriptToString(Script script);
0047             Q_INVOKABLE static void setDefault(const QLocale &locale);
0048             Q_INVOKABLE static Locale system();
0049             Locale &operator=(const Locale& other);
0050         public slots:
0051             QString amText() const;
0052             QString bcp47Name() const;
0053             Country country() const;
0054             QString createSeparatedList(const QStringList &strl) const;
0055             QString currencySymbol(CurrencySymbolFormat format = CurrencySymbol) const;
0056             QString dateFormat(FormatType format = LongFormat) const;
0057             QString dateTimeFormat(FormatType format = LongFormat) const;
0058             QString dayName(int day, FormatType format = LongFormat) const;
0059             QChar decimalPoint() const;
0060             QChar exponential() const;
0061             Qt::DayOfWeek firstDayOfWeek() const;
0062             QChar groupSeparator() const;
0063             Language language() const;
0064             MeasurementSystem measurementSystem() const;
0065             QString monthName(int month, FormatType format = LongFormat) const;
0066             QString name() const;
0067             QString nativeCountryName() const;
0068             QString nativeLanguageName() const;
0069             QChar negativeSign() const;
0070             NumberOptions numberOptions() const;
0071             QChar percent() const;
0072             QString pmText() const;
0073             QChar positiveSign() const;
0074             QString quoteString(const QStringRef &str, QuotationStyle style = StandardQuotation) const;
0075             QString quoteString(const QString &str, QuotationStyle style = StandardQuotation) const;
0076             Script script() const;
0077             void setNumberOptions(NumberOptions options);
0078             QString standaloneDayName(int day, FormatType format = LongFormat) const;
0079             QString standaloneMonthName(int month, FormatType format = LongFormat) const;
0080             void swap(QLocale &other);
0081             Qt::LayoutDirection textDirection() const;
0082             QString timeFormat(FormatType format = LongFormat) const;
0083             QString toCurrencyString(double value, const QString &symbol, int precision) const;
0084             QString toCurrencyString(double value, const QString &symbol = QString()) const;
0085             QString toCurrencyString(float i, const QString &symbol, int precision) const;
0086             QString toCurrencyString(float i, const QString &symbol = QString()) const;
0087             QString toCurrencyString(int value, const QString &symbol = QString()) const;
0088             QString toCurrencyString(qlonglong value, const QString &symbol = QString()) const;
0089             QString toCurrencyString(qulonglong value, const QString &symbol = QString()) const;
0090             QString toCurrencyString(short value, const QString &symbol = QString()) const;
0091             QString toCurrencyString(uint value, const QString &symbol = QString()) const;
0092             QString toCurrencyString(ushort value, const QString &symbol = QString()) const;
0093             QDate toDate(const QString &string, const QString &format) const;
0094             QDate toDate(const QString &string, FormatType format = LongFormat) const;
0095             QDateTime toDateTime(const QString &string, const QString &format) const;
0096             QDateTime toDateTime(const QString &string, FormatType format = LongFormat) const;
0097             double toDouble(const QStringRef &s, bool *ok = Q_NULLPTR) const;
0098             double toDouble(const QString &s, bool *ok = Q_NULLPTR) const;
0099             float toFloat(const QStringRef &s, bool *ok = Q_NULLPTR) const;
0100             float toFloat(const QString &s, bool *ok = Q_NULLPTR) const;
0101             int toInt(const QStringRef &s, bool *ok = Q_NULLPTR) const;
0102             int toInt(const QString &s, bool *ok = Q_NULLPTR) const;
0103             qlonglong toLongLong(const QStringRef &s, bool *ok = Q_NULLPTR) const;
0104             qlonglong toLongLong(const QString &s, bool *ok = Q_NULLPTR) const;
0105             QString toLower(const QString &str) const;
0106             short toShort(const QStringRef &s, bool *ok = Q_NULLPTR) const;
0107             short toShort(const QString &s, bool *ok = Q_NULLPTR) const;
0108             QString toString(const QDate &date, const QString &formatStr) const;
0109             QString toString(const QDate &date, FormatType format = LongFormat) const;
0110             QString toString(const QDateTime &dateTime, const QString &format) const;
0111             QString toString(const QDateTime &dateTime, FormatType format = LongFormat) const;
0112             QString toString(const QTime &time, const QString &formatStr) const;
0113             QString toString(const QTime &time, FormatType format = LongFormat) const;
0114             QString toString(double i, char f = 'g', int prec = 6) const;
0115             QString toString(float i, char f = 'g', int prec = 6) const;
0116             QString toString(int i) const;
0117             QString toString(qlonglong i) const;
0118             QString toString(qulonglong i) const;
0119             QString toString(short i) const;
0120             QString toString(uint i) const;
0121             QString toString(ushort i) const;
0122             QTime toTime(const QString &string, const QString &format) const;
0123             QTime toTime(const QString &string, FormatType format = LongFormat) const;
0124             uint toUInt(const QStringRef &s, bool *ok = Q_NULLPTR) const;
0125             uint toUInt(const QString &s, bool *ok = Q_NULLPTR) const;
0126             qulonglong toULongLong(const QStringRef &s, bool *ok = Q_NULLPTR) const;
0127             qulonglong toULongLong(const QString &s, bool *ok = Q_NULLPTR) const;
0128             QString toUpper(const QString &str) const;
0129             ushort toUShort(const QStringRef &s, bool *ok = Q_NULLPTR) const;
0130             ushort toUShort(const QString &s, bool *ok = Q_NULLPTR) const;
0131             QStringList uiLanguages() const;
0132             QList<Qt::DayOfWeek> weekdays() const;
0133             QChar zeroDigit() const;
0134             QList<Country> countriesForLanguage(Language lang);
0135             QList<QLocale> matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Country country);
0136         };
0137     }
0138 }
0139 Q_DECLARE_METATYPE(QtBindings::Core::Locale)
0140 #endif //CORELOCALE_H