diff options
Diffstat (limited to 'src/profile.h')
| -rw-r--r-- | src/profile.h | 132 |
1 files changed, 70 insertions, 62 deletions
diff --git a/src/profile.h b/src/profile.h index 457d8015..0adb4d0f 100644 --- a/src/profile.h +++ b/src/profile.h @@ -20,18 +20,17 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #ifndef PROFILE_H #define PROFILE_H - +#include "executableinfo.h" #include "modinfo.h" -#include <iprofile.h> #include <delayedfilewriter.h> -#include "executableinfo.h" +#include <iprofile.h> #include <QByteArray> #include <QDir> +#include <QList> #include <QObject> -#include <QString> #include <QSettings> -#include <QList> +#include <QString> #include <boost/shared_ptr.hpp> @@ -39,8 +38,10 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <tuple> #include <vector> - -namespace MOBase { class IPluginGame; } +namespace MOBase +{ +class IPluginGame; +} /** * @brief represents a profile @@ -51,18 +52,15 @@ class Profile : public QObject, public MOBase::IProfile Q_OBJECT public: - using Ptr = boost::shared_ptr<Profile>; public: - // the minimum and maximum priority achievable by mods // static constexpr int MinimumPriority = 0; static constexpr int MaximumPriority = std::numeric_limits<int>::max(); public: - /** * @brief constructor * @@ -71,25 +69,27 @@ public: * @param name name of the new profile * @param filter save game filter. Defaults to <no filter>. **/ - Profile(const QString &name, MOBase::IPluginGame const *gamePlugin, bool useDefaultSettings); + Profile(const QString& name, MOBase::IPluginGame const* gamePlugin, + bool useDefaultSettings); /** * @brief constructor * - * This constructor is used to open an existing profile though it will also try to repair - * the profile if important files are missing (including the directory itself) so technically, - * invoking this should always produce a working profile + * This constructor is used to open an existing profile though it will also try to + *repair the profile if important files are missing (including the directory itself) + *so technically, invoking this should always produce a working profile * @param directory directory to read the profile from **/ - Profile(const QDir &directory, MOBase::IPluginGame const *gamePlugin); + Profile(const QDir& directory, MOBase::IPluginGame const* gamePlugin); - Profile(const Profile &reference); + Profile(const Profile& reference); ~Profile(); /** - * Determines the default settings for the profile based on the current state of the profile's - * files. This function should remain backwards compatible as much as possible. + * Determines the default settings for the profile based on the current state of the + *profile's files. This function should remain backwards compatible as much as + *possible. **/ void findProfileSettings(void); @@ -103,25 +103,27 @@ public: * @param name of the new profile * @param reference profile to copy from **/ - static Profile *createPtrFrom(const QString &name, const Profile &reference, MOBase::IPluginGame const *gamePlugin); - + static Profile* createPtrFrom(const QString& name, const Profile& reference, + MOBase::IPluginGame const* gamePlugin); static void renameModInAllProfiles(const QString& oldName, const QString& newName); void writeModlist(); - void writeModlistNow(bool onlyIfPending=false); + void writeModlistNow(bool onlyIfPending = false); void cancelModlistWrite(); /** * @brief test if this profile uses archive invalidation * - * @param supported if this is not null, the parameter will be set to false if invalidation is not supported in this profile + * @param supported if this is not null, the parameter will be set to false if + *invalidation is not supported in this profile * @return true if archive invalidation is active - * @note currently, invalidation is not supported if the relevant entry in the ini file does not exist + * @note currently, invalidation is not supported if the relevant entry in the ini + *file does not exist **/ - bool invalidationActive(bool *supported) const; + bool invalidationActive(bool* supported) const; /** * @brief deactivate archive invalidation if it was active @@ -165,7 +167,8 @@ public: /** * @return the path of the plugins file in this profile - * @todo is this required? can the functionality using this function be moved to the Profile-class? + * @todo is this required? can the functionality using this function be moved to the + *Profile-class? **/ QString getPluginsFileName() const; @@ -191,8 +194,8 @@ public: /** * @return the path of the ini file in this profile - * @todo since the game can contain multiple ini files (i.e. skyrim.ini skyrimprefs.ini) - * the concept of this function is somewhat broken + * @todo since the game can contain multiple ini files (i.e. skyrim.ini + *skyrimprefs.ini) the concept of this function is somewhat broken **/ QString getIniFileName() const; @@ -225,7 +228,7 @@ public: * @brief rename profile * @param newName new name of profile */ - void rename(const QString &newName); + void rename(const QString& newName); /** * @brief create the ini file to be used by the game @@ -242,7 +245,8 @@ public: /** * @brief retrieve a list of mods that are enabled in this profile * - * @return list of active mods sorted by priority (ascending). "first" is the mod name, "second" is its path + * @return list of active mods sorted by priority (ascending). "first" is the mod + *name, "second" is its path **/ std::vector<std::tuple<QString, QString, int>> getActiveMods(); @@ -251,7 +255,10 @@ public: * * @return map of indexes by priority **/ - const std::map<int, unsigned int>& getAllIndexesByPriority() { return m_ModIndexByPriority; } + const std::map<int, unsigned int>& getAllIndexesByPriority() + { + return m_ModIndexByPriority; + } /** * retrieve the number of mods for which this object has status information. @@ -278,7 +285,8 @@ public: * @param modsToEnable list of mod indicies to enable * @param modsToDisable list of mod indicies to disable **/ - void setModsEnabled(const QList<unsigned int> &modsToEnable, const QList<unsigned int> &modsToDisable); + void setModsEnabled(const QList<unsigned int>& modsToEnable, + const QList<unsigned int>& modsToDisable); // set the priority of a mod, and the priority of other mods in the range // [old priority, new priority] such that no gaps are possible @@ -311,30 +319,30 @@ public: void dumpModStatus() const; - QVariant setting( - const QString §ion, const QString &name, - const QVariant &fallback={}) const; + QVariant setting(const QString& section, const QString& name, + const QVariant& fallback = {}) const; - void storeSetting( - const QString §ion, const QString &name, const QVariant &value={}); + void storeSetting(const QString& section, const QString& name, + const QVariant& value = {}); - void removeSetting(const QString §ion, const QString &name); + void removeSetting(const QString& section, const QString& name); - QVariantMap settingsByGroup(const QString §ion) const; - void storeSettingsByGroup(const QString §ion, const QVariantMap &values); + QVariantMap settingsByGroup(const QString& section) const; + void storeSettingsByGroup(const QString& section, const QVariantMap& values); - QList<QVariantMap> settingsByArray(const QString &prefix) const; - void storeSettingsByArray(const QString &prefix, const QList<QVariantMap> &values); + QList<QVariantMap> settingsByArray(const QString& prefix) const; + void storeSettingsByArray(const QString& prefix, const QList<QVariantMap>& values); - bool forcedLibrariesEnabled(const QString &executable) const; - void setForcedLibrariesEnabled(const QString &executable, bool enabled); - QList<MOBase::ExecutableForcedLoadSetting> determineForcedLibraries(const QString &executable) const; - void storeForcedLibraries(const QString &executable, const QList<MOBase::ExecutableForcedLoadSetting> &values); - void removeForcedLibraries(const QString &executable); + bool forcedLibrariesEnabled(const QString& executable) const; + void setForcedLibrariesEnabled(const QString& executable, bool enabled); + QList<MOBase::ExecutableForcedLoadSetting> + determineForcedLibraries(const QString& executable) const; + void storeForcedLibraries(const QString& executable, + const QList<MOBase::ExecutableForcedLoadSetting>& values); + void removeForcedLibraries(const QString& executable); void debugDump() const; - Profile& operator=(const Profile& reference) = delete; signals: @@ -355,40 +363,42 @@ signals: protected slots: - // should only be called by DelayedFileWriter, use writeModlist() and writeModlistNow() instead + // should only be called by DelayedFileWriter, use writeModlist() and + // writeModlistNow() instead void doWriteModlist(); private: - - class ModStatus { + class ModStatus + { friend class Profile; + public: ModStatus() : m_Enabled(false), m_Priority(-1) {} + private: bool m_Enabled; int m_Priority; }; private: - void updateIndices(); - void copyFilesTo(QString &target) const; + void copyFilesTo(QString& target) const; - std::vector<std::wstring> splitDZString(const wchar_t *buffer) const; - void mergeTweak(const QString &tweakName, const QString &tweakedIni) const; - void mergeTweaks(ModInfo::Ptr modInfo, const QString &tweakedIni) const; + std::vector<std::wstring> splitDZString(const wchar_t* buffer) const; + void mergeTweak(const QString& tweakName, const QString& tweakedIni) const; + void mergeTweaks(ModInfo::Ptr modInfo, const QString& tweakedIni) const; void touchFile(QString fileName); - static void renameModInList(QFile &modList, const QString &oldName, const QString &newName); + static void renameModInList(QFile& modList, const QString& oldName, + const QString& newName); private: - QDir m_Directory; - QSettings *m_Settings; + QSettings* m_Settings; - const MOBase::IPluginGame *m_GamePlugin; + const MOBase::IPluginGame* m_GamePlugin; std::vector<ModStatus> m_ModStatus; std::map<int, unsigned int> m_ModIndexByPriority; @@ -399,8 +409,6 @@ private: mutable QByteArray m_LastModlistHash; MOBase::DelayedFileWriter m_ModListWriter; - }; - -#endif // PROFILE_H +#endif // PROFILE_H |
