/**
 * This file is generated by dconfig2cpp.
 * Command line arguments: ./dconfig2cpp -p ./dde-control-center/toolGenerate/dconfig2cpp ./dde-control-center/misc/configs/common/org.deepin.region-format.json
 * Generation time: 2025-01-14T10:54:58
 * JSON file version: 1.0
 * 
 * WARNING: DO NOT MODIFY THIS FILE MANUALLY.
 * If you need to change the content, please modify the dconfig2cpp tool.
 */

#ifndef ORG_DEEPIN_REGION-FORMAT_H
#define ORG_DEEPIN_REGION-FORMAT_H

#include <QThread>
#include <QVariant>
#include <QDebug>
#include <QAtomicPointer>
#include <QAtomicInteger>
#include <DConfig>

class org_deepin_region-format : public QObject {
    Q_OBJECT

    Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged)
    Q_PROPERTY(QString currencyFormat READ currencyFormat WRITE setCurrencyFormat NOTIFY currencyFormatChanged)
    Q_PROPERTY(double firstDayOfWeek READ firstDayOfWeek WRITE setFirstDayOfWeek NOTIFY firstDayOfWeekChanged)
    Q_PROPERTY(QString languageRegion READ languageRegion WRITE setLanguageRegion NOTIFY languageRegionChanged)
    Q_PROPERTY(QString localeName READ localeName WRITE setLocaleName NOTIFY localeNameChanged)
    Q_PROPERTY(QString longDateFormat READ longDateFormat WRITE setLongDateFormat NOTIFY longDateFormatChanged)
    Q_PROPERTY(QString longTimeFormat READ longTimeFormat WRITE setLongTimeFormat NOTIFY longTimeFormatChanged)
    Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat NOTIFY numberFormatChanged)
    Q_PROPERTY(QString paperFormat READ paperFormat WRITE setPaperFormat NOTIFY paperFormatChanged)
    Q_PROPERTY(QString shortDateFormat READ shortDateFormat WRITE setShortDateFormat NOTIFY shortDateFormatChanged)
    Q_PROPERTY(QString shortTimeFormat READ shortTimeFormat WRITE setShortTimeFormat NOTIFY shortTimeFormatChanged)
public:
    explicit org_deepin_region-format(QThread *thread, const QString &appId, const QString &name, const QString &subpath, QObject *parent = nullptr)
        : QObject(parent) {

        if (!thread->isRunning()) {
            qWarning() << QStringLiteral("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);
        QMetaObject::invokeMethod(worker, [=]() {
            auto config = DTK_CORE_NAMESPACE::DConfig::create(appId, name, subpath, nullptr);
            if (!config) {
                qWarning() << QStringLiteral("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initialize(config);
            worker->deleteLater();
        });
    }
    explicit org_deepin_region-format(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId, const QString &name, const QString &subpath, QObject *parent = nullptr)
        : QObject(parent) {

        if (!thread->isRunning()) {
            qWarning() << QStringLiteral("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);
        QMetaObject::invokeMethod(worker, [=]() {
            auto config = DTK_CORE_NAMESPACE::DConfig::create(backend, appId, name, subpath, nullptr);
            if (!config) {
                qWarning() << QStringLiteral("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initialize(config);
            worker->deleteLater();
        });
    }
    explicit org_deepin_region-format(QThread *thread, const QString &name, const QString &subpath, QObject *parent = nullptr)
        : QObject(parent) {

        if (!thread->isRunning()) {
            qWarning() << QStringLiteral("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);
        QMetaObject::invokeMethod(worker, [=]() {
            auto config = DTK_CORE_NAMESPACE::DConfig::create(name, subpath, nullptr);
            if (!config) {
                qWarning() << QStringLiteral("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initialize(config);
            worker->deleteLater();
        });
    }
    explicit org_deepin_region-format(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &subpath, QObject *parent = nullptr)
        : QObject(parent) {

        if (!thread->isRunning()) {
            qWarning() << QStringLiteral("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);
        QMetaObject::invokeMethod(worker, [=]() {
            auto config = DTK_CORE_NAMESPACE::DConfig::create(backend, name, subpath, nullptr);
            if (!config) {
                qWarning() << QStringLiteral("Failed to create DConfig instance.");
                worker->deleteLater();
                return;
            }
            config->moveToThread(QThread::currentThread());
            initialize(config);
            worker->deleteLater();
        });
    }
    ~org_deepin_region-format() {
        if (m_config.loadRelaxed()) {
            m_config.loadRelaxed()->deleteLater();
        }
    }

    QString country() const {
        return p_country;
    }
    void setCountry(const QString &value) {
        auto oldValue = p_country;
        p_country = value;
        markPropertySet(0);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("country"), value);
            });
        }
        if (p_country != oldValue) {
            Q_EMIT countryChanged();
        }
    }
    QString currencyFormat() const {
        return p_currencyFormat;
    }
    void setCurrencyFormat(const QString &value) {
        auto oldValue = p_currencyFormat;
        p_currencyFormat = value;
        markPropertySet(1);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("currencyFormat"), value);
            });
        }
        if (p_currencyFormat != oldValue) {
            Q_EMIT currencyFormatChanged();
        }
    }
    double firstDayOfWeek() const {
        return p_firstDayOfWeek;
    }
    void setFirstDayOfWeek(const double &value) {
        auto oldValue = p_firstDayOfWeek;
        p_firstDayOfWeek = value;
        markPropertySet(2);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("firstDayOfWeek"), value);
            });
        }
        if (p_firstDayOfWeek != oldValue) {
            Q_EMIT firstDayOfWeekChanged();
        }
    }
    QString languageRegion() const {
        return p_languageRegion;
    }
    void setLanguageRegion(const QString &value) {
        auto oldValue = p_languageRegion;
        p_languageRegion = value;
        markPropertySet(3);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("languageRegion"), value);
            });
        }
        if (p_languageRegion != oldValue) {
            Q_EMIT languageRegionChanged();
        }
    }
    QString localeName() const {
        return p_localeName;
    }
    void setLocaleName(const QString &value) {
        auto oldValue = p_localeName;
        p_localeName = value;
        markPropertySet(4);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("localeName"), value);
            });
        }
        if (p_localeName != oldValue) {
            Q_EMIT localeNameChanged();
        }
    }
    QString longDateFormat() const {
        return p_longDateFormat;
    }
    void setLongDateFormat(const QString &value) {
        auto oldValue = p_longDateFormat;
        p_longDateFormat = value;
        markPropertySet(5);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("longDateFormat"), value);
            });
        }
        if (p_longDateFormat != oldValue) {
            Q_EMIT longDateFormatChanged();
        }
    }
    QString longTimeFormat() const {
        return p_longTimeFormat;
    }
    void setLongTimeFormat(const QString &value) {
        auto oldValue = p_longTimeFormat;
        p_longTimeFormat = value;
        markPropertySet(6);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("longTimeFormat"), value);
            });
        }
        if (p_longTimeFormat != oldValue) {
            Q_EMIT longTimeFormatChanged();
        }
    }
    QString numberFormat() const {
        return p_numberFormat;
    }
    void setNumberFormat(const QString &value) {
        auto oldValue = p_numberFormat;
        p_numberFormat = value;
        markPropertySet(7);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("numberFormat"), value);
            });
        }
        if (p_numberFormat != oldValue) {
            Q_EMIT numberFormatChanged();
        }
    }
    QString paperFormat() const {
        return p_paperFormat;
    }
    void setPaperFormat(const QString &value) {
        auto oldValue = p_paperFormat;
        p_paperFormat = value;
        markPropertySet(8);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("paperFormat"), value);
            });
        }
        if (p_paperFormat != oldValue) {
            Q_EMIT paperFormatChanged();
        }
    }
    QString shortDateFormat() const {
        return p_shortDateFormat;
    }
    void setShortDateFormat(const QString &value) {
        auto oldValue = p_shortDateFormat;
        p_shortDateFormat = value;
        markPropertySet(9);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("shortDateFormat"), value);
            });
        }
        if (p_shortDateFormat != oldValue) {
            Q_EMIT shortDateFormatChanged();
        }
    }
    QString shortTimeFormat() const {
        return p_shortTimeFormat;
    }
    void setShortTimeFormat(const QString &value) {
        auto oldValue = p_shortTimeFormat;
        p_shortTimeFormat = value;
        markPropertySet(10);
        if (auto config = m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [this, value]() {
                m_config.loadRelaxed()->setValue(QStringLiteral("shortTimeFormat"), value);
            });
        }
        if (p_shortTimeFormat != oldValue) {
            Q_EMIT shortTimeFormatChanged();
        }
    }
Q_SIGNALS:
    void countryChanged();
    void currencyFormatChanged();
    void firstDayOfWeekChanged();
    void languageRegionChanged();
    void localeNameChanged();
    void longDateFormatChanged();
    void longTimeFormatChanged();
    void numberFormatChanged();
    void paperFormatChanged();
    void shortDateFormatChanged();
    void shortTimeFormatChanged();
private:
    void initialize(DTK_CORE_NAMESPACE::DConfig *config) {
        Q_ASSERT(!m_config.loadRelaxed());
        m_config.storeRelaxed(config);
        if (testPropertySet(0)) {
            config->setValue(QStringLiteral("country"), QVariant::fromValue(p_country));
        } else {
            updateValue(QStringLiteral("country"), QVariant::fromValue(p_country));
        }
        if (testPropertySet(1)) {
            config->setValue(QStringLiteral("currencyFormat"), QVariant::fromValue(p_currencyFormat));
        } else {
            updateValue(QStringLiteral("currencyFormat"), QVariant::fromValue(p_currencyFormat));
        }
        if (testPropertySet(2)) {
            config->setValue(QStringLiteral("firstDayOfWeek"), QVariant::fromValue(p_firstDayOfWeek));
        } else {
            updateValue(QStringLiteral("firstDayOfWeek"), QVariant::fromValue(p_firstDayOfWeek));
        }
        if (testPropertySet(3)) {
            config->setValue(QStringLiteral("languageRegion"), QVariant::fromValue(p_languageRegion));
        } else {
            updateValue(QStringLiteral("languageRegion"), QVariant::fromValue(p_languageRegion));
        }
        if (testPropertySet(4)) {
            config->setValue(QStringLiteral("localeName"), QVariant::fromValue(p_localeName));
        } else {
            updateValue(QStringLiteral("localeName"), QVariant::fromValue(p_localeName));
        }
        if (testPropertySet(5)) {
            config->setValue(QStringLiteral("longDateFormat"), QVariant::fromValue(p_longDateFormat));
        } else {
            updateValue(QStringLiteral("longDateFormat"), QVariant::fromValue(p_longDateFormat));
        }
        if (testPropertySet(6)) {
            config->setValue(QStringLiteral("longTimeFormat"), QVariant::fromValue(p_longTimeFormat));
        } else {
            updateValue(QStringLiteral("longTimeFormat"), QVariant::fromValue(p_longTimeFormat));
        }
        if (testPropertySet(7)) {
            config->setValue(QStringLiteral("numberFormat"), QVariant::fromValue(p_numberFormat));
        } else {
            updateValue(QStringLiteral("numberFormat"), QVariant::fromValue(p_numberFormat));
        }
        if (testPropertySet(8)) {
            config->setValue(QStringLiteral("paperFormat"), QVariant::fromValue(p_paperFormat));
        } else {
            updateValue(QStringLiteral("paperFormat"), QVariant::fromValue(p_paperFormat));
        }
        if (testPropertySet(9)) {
            config->setValue(QStringLiteral("shortDateFormat"), QVariant::fromValue(p_shortDateFormat));
        } else {
            updateValue(QStringLiteral("shortDateFormat"), QVariant::fromValue(p_shortDateFormat));
        }
        if (testPropertySet(10)) {
            config->setValue(QStringLiteral("shortTimeFormat"), QVariant::fromValue(p_shortTimeFormat));
        } else {
            updateValue(QStringLiteral("shortTimeFormat"), QVariant::fromValue(p_shortTimeFormat));
        }

        connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) {
            updateValue(key);
        }, Qt::DirectConnection);
    }
    void updateValue(const QString &key, const QVariant &fallback = QVariant()) {
        Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread());
        const QVariant &value = m_config.loadRelaxed()->value(key, fallback);
        if (key == QStringLiteral("country")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_country != newValue) {
                    p_country = newValue;
                    Q_EMIT countryChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("currencyFormat")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_currencyFormat != newValue) {
                    p_currencyFormat = newValue;
                    Q_EMIT currencyFormatChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("firstDayOfWeek")) {
            auto newValue = qvariant_cast<double>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_firstDayOfWeek != newValue) {
                    p_firstDayOfWeek = newValue;
                    Q_EMIT firstDayOfWeekChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("languageRegion")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_languageRegion != newValue) {
                    p_languageRegion = newValue;
                    Q_EMIT languageRegionChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("localeName")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_localeName != newValue) {
                    p_localeName = newValue;
                    Q_EMIT localeNameChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("longDateFormat")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_longDateFormat != newValue) {
                    p_longDateFormat = newValue;
                    Q_EMIT longDateFormatChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("longTimeFormat")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_longTimeFormat != newValue) {
                    p_longTimeFormat = newValue;
                    Q_EMIT longTimeFormatChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("numberFormat")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_numberFormat != newValue) {
                    p_numberFormat = newValue;
                    Q_EMIT numberFormatChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("paperFormat")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_paperFormat != newValue) {
                    p_paperFormat = newValue;
                    Q_EMIT paperFormatChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("shortDateFormat")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_shortDateFormat != newValue) {
                    p_shortDateFormat = newValue;
                    Q_EMIT shortDateFormatChanged();
                }
            });
            return;
        }
        if (key == QStringLiteral("shortTimeFormat")) {
            auto newValue = qvariant_cast<QString>(value);
            QMetaObject::invokeMethod(this, [this, newValue]() {
                if (p_shortTimeFormat != newValue) {
                    p_shortTimeFormat = newValue;
                    Q_EMIT shortTimeFormatChanged();
                }
            });
            return;
        }
    }
    inline void markPropertySet(const int index) {
        if (index < 32) {
            m_propertySetStatus0.fetchAndOrOrdered(1 << (index - 0));
            return;
        }
        Q_UNREACHABLE();
    }
    inline bool testPropertySet(const int index) const {
        if (index < 32) {
            return (m_propertySetStatus0.loadRelaxed() & (1 << (index - 0)));
        }
        Q_UNREACHABLE();
    }
    QAtomicPointer<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr;
    QString p_country { QStringLiteral("") };
    QString p_currencyFormat { QStringLiteral("") };
    double p_firstDayOfWeek { 0 };
    QString p_languageRegion { QStringLiteral("") };
    QString p_localeName { QStringLiteral("") };
    QString p_longDateFormat { QStringLiteral("") };
    QString p_longTimeFormat { QStringLiteral("") };
    QString p_numberFormat { QStringLiteral("") };
    QString p_paperFormat { QStringLiteral("") };
    QString p_shortDateFormat { QStringLiteral("") };
    QString p_shortTimeFormat { QStringLiteral("") };
    QAtomicInteger<quint32> m_propertySetStatus0 = 0;
};

#endif // ORG_DEEPIN_REGION-FORMAT_H
