#ifndef QTMVVM_SETTINGSSETUPLOADER_P_H #define QTMVVM_SETTINGSSETUPLOADER_P_H #include #include #include #include #include #include #include "qtmvvmcore_global.h" #include "settingssetup.h" namespace QtMvvm { class Q_MVVMCORE_EXPORT SettingsSetupLoader : public QObject, public ISettingsSetupLoader { Q_OBJECT Q_INTERFACES(QtMvvm::ISettingsSetupLoader) public: Q_INVOKABLE SettingsSetupLoader(QObject *parent = nullptr); void changeDefaultIcon(const QUrl &defaultIcon) override; SettingsElements::Setup loadSetup(const QString &filePath, const QString &frontend, const QFileSelector *selector) const final; bool event(QEvent *event) override; private: QUrl _defaultIcon; mutable QCache _cache; //Functions to read the settings XML SettingsElements::Category readCategory(QXmlStreamReader &reader) const; SettingsElements::Category readDefaultCategory(QXmlStreamReader &reader) const; void readCategoryChildren(QXmlStreamReader &reader, SettingsElements::Category &category) const; SettingsElements::Section readSection(QXmlStreamReader &reader) const; SettingsElements::Section readDefaultSection(QXmlStreamReader &reader) const; void readSectionChildren(QXmlStreamReader &reader, SettingsElements::Section §ion) const; SettingsElements::Group readGroup(QXmlStreamReader &reader) const; SettingsElements::Group readDefaultGroup(QXmlStreamReader &reader) const; void readGroupChildren(QXmlStreamReader &reader, SettingsElements::Group &group) const; SettingsElements::Entry readEntry(QXmlStreamReader &reader) const; SettingsElements::Category createDefaultCategory() const; SettingsElements::Section createDefaultSection() const; std::tuple readProperty(QXmlStreamReader &reader) const; QVariant readElement(QXmlStreamReader &reader) const; //Functions to read included files bool readCategoryInclude(QXmlStreamReader &reader, SettingsElements::Category &category) const; bool readSectionInclude(QXmlStreamReader &reader, SettingsElements::Section §ion) const; bool readGroupInclude(QXmlStreamReader &reader, SettingsElements::Group &group) const; bool readEntryInclude(QXmlStreamReader &reader, SettingsElements::Entry &entry) const; bool readInclude(QXmlStreamReader &reader, const std::function &readFn, const QString &typeName) const; //Functions to filter the elements void clearSetup(SettingsElements::Setup &setup, const QString &frontend, const QStringList &selectors) const; void clearCategory(SettingsElements::Category &category, const QString &frontend, const QStringList &selectors) const; void clearSection(SettingsElements::Section §ion, const QString &frontend, const QStringList &selectors) const; void clearGroup(SettingsElements::Group &group, const QString &frontend, const QStringList &selectors) const; template bool isUsable(const T &configElement, const QString &frontend, const QStringList &selectors) const; }; class Q_MVVMCORE_EXPORT SettingsXmlException : public SettingsLoaderException { public: SettingsXmlException(const QXmlStreamReader &reader); SettingsXmlException(QXmlStreamReader &reader, const QByteArray &customError, bool forceOverwrite = false); SettingsXmlException(const QFile &fileError); const char *what() const noexcept override; void raise() const override; QException *clone() const override; protected: SettingsXmlException(const SettingsXmlException * const other); private: const QByteArray _what; }; } #endif // QTMVVM_SETTINGSSETUPLOADER_P_H