summaryrefslogtreecommitdiff
path: root/src/profile.h
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@gmail.com>2018-02-23 01:45:58 +0100
committerSandro Jäckel <sandro.jaeckel@gmail.com>2018-02-23 01:45:58 +0100
commitea6292168a6acd4c263913f0ccd7dd64daf4f5cf (patch)
tree312024abbd7c3c100274f3a8031d49096480b654 /src/profile.h
parent5e5c9c07291f6b09623d31c92b1fb61c4ede576e (diff)
Revert "Applied clang-format on source"
This reverts commit 5e5c9c07291f6b09623d31c92b1fb61c4ede576e.
Diffstat (limited to 'src/profile.h')
-rw-r--r--src/profile.h487
1 files changed, 247 insertions, 240 deletions
diff --git a/src/profile.h b/src/profile.h
index c1cd3e9f..1fcad046 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -20,15 +20,16 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#ifndef PROFILE_H
#define PROFILE_H
+
#include "modinfo.h"
-#include <delayedfilewriter.h>
#include <iprofile.h>
+#include <delayedfilewriter.h>
#include <QByteArray>
#include <QDir>
#include <QObject>
-#include <QSettings>
#include <QString>
+#include <QSettings>
#include <boost/shared_ptr.hpp>
@@ -36,316 +37,322 @@ 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
**/
-class Profile : public QObject, public MOBase::IProfile {
+class Profile : public QObject, public MOBase::IProfile
+{
- Q_OBJECT
+ Q_OBJECT
public:
- typedef boost::shared_ptr<Profile> Ptr;
+
+ typedef boost::shared_ptr<Profile> Ptr;
public:
- /**
- * @brief constructor
- *
- * This constructor is used to create a new profile so it is to be assumed a profile
- * by this name does not yet exist
- * @param name name of the new profile
- * @param filter save game filter. Defaults to &lt;no filter&gt;.
- **/
- 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
- * @param directory directory to read the profile from
- **/
- Profile(const QDir& directory, MOBase::IPluginGame const* gamePlugin);
+ /**
+ * @brief constructor
+ *
+ * This constructor is used to create a new profile so it is to be assumed a profile
+ * by this name does not yet exist
+ * @param name name of the new profile
+ * @param filter save game filter. Defaults to &lt;no filter&gt;.
+ **/
+ Profile(const QString &name, MOBase::IPluginGame const *gamePlugin, bool useDefaultSettings);
- Profile(const Profile& reference);
+ /**
+ * @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
+ * @param directory directory to read the profile from
+ **/
+ Profile(const QDir &directory, MOBase::IPluginGame const *gamePlugin);
- ~Profile();
+ Profile(const Profile &reference);
- /**
- * @return true if this profile (still) exists on disc
- */
- bool exists() const;
+ ~Profile();
- /**
- * @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);
+ /**
+ * @return true if this profile (still) exists on disc
+ */
+ bool exists() const;
- static void renameModInAllProfiles(const QString& oldName, const QString& newName);
+ /**
+ * @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);
- void writeModlist();
- void writeModlistNow(bool onlyIfPending = false);
+ static void renameModInAllProfiles(const QString& oldName, const QString& newName);
- void cancelModlistWrite();
+ void writeModlist();
- /**
- * @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
- * @return true if archive invalidation is active
- * @note currently, invalidation is not supported if the relevant entry in the ini file does not exist
- **/
- bool invalidationActive(bool* supported) const;
+ void writeModlistNow(bool onlyIfPending=false);
- /**
- * @brief deactivate archive invalidation if it was active
- **/
- void deactivateInvalidation();
+ void cancelModlistWrite();
- /**
- * @brief activate archive invalidation
- **/
- void activateInvalidation();
+ /**
+ * @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
+ * @return true if archive invalidation is active
+ * @note currently, invalidation is not supported if the relevant entry in the ini file does not exist
+ **/
+ bool invalidationActive(bool *supported) const;
- /**
- * @return true if this profile uses local save games
- */
- virtual bool localSavesEnabled() const override;
+ /**
+ * @brief deactivate archive invalidation if it was active
+ **/
+ void deactivateInvalidation();
- /**
- * @brief enables or disables the use of local save games for this profile
- * when disabling the user will be asked if he wants to remove the save games
- * in the profile
- * @param enable if true, local saves are enabled, otherewise they are disabled
- */
- bool enableLocalSaves(bool enable);
+ /**
+ * @brief activate archive invalidation
+ **/
+ void activateInvalidation();
- /**
- * @return true if this profile uses local ini files
- */
- virtual bool localSettingsEnabled() const override;
+ /**
+ * @return true if this profile uses local save games
+ */
+ virtual bool localSavesEnabled() const override;
- /**
- * @brief enables or disables the use of local ini files for this profile
- * disabling this does not delete existing ini files but the global ones will be used
- * @param enable
- */
- bool enableLocalSettings(bool enable);
+ /**
+ * @brief enables or disables the use of local save games for this profile
+ * when disabling the user will be asked if he wants to remove the save games
+ * in the profile
+ * @param enable if true, local saves are enabled, otherewise they are disabled
+ */
+ bool enableLocalSaves(bool enable);
- /**
- * @return name of the profile (this is identical to its directory name)
- **/
- virtual QString name() const override { return m_Directory.dirName(); }
+ /**
+ * @return true if this profile uses local ini files
+ */
+ virtual bool localSettingsEnabled() const override;
- /**
- * @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?
- **/
- QString getPluginsFileName() const;
+ /**
+ * @brief enables or disables the use of local ini files for this profile
+ * disabling this does not delete existing ini files but the global ones will be used
+ * @param enable
+ */
+ bool enableLocalSettings(bool enable);
- /**
- * @return the path of the loadorder file in this profile
- **/
- QString getLoadOrderFileName() const;
+ /**
+ * @return name of the profile (this is identical to its directory name)
+ **/
+ virtual QString name() const override { return m_Directory.dirName(); }
- /**
- * @return the path of the file containing locked mod indices
- */
- QString getLockedOrderFileName() const;
+ /**
+ * @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?
+ **/
+ QString getPluginsFileName() const;
- /**
- * @return the path of the modlist file in this profile
- */
- QString getModlistFileName() const;
+ /**
+ * @return the path of the loadorder file in this profile
+ **/
+ QString getLoadOrderFileName() const;
- /**
- * @return path of the archives file in this profile
- */
- QString getArchivesFileName() const;
+ /**
+ * @return the path of the file containing locked mod indices
+ */
+ QString getLockedOrderFileName() const;
- /**
- * @return the path of the delete file in this profile
- * @note the deleter file lists plugins that should be hidden from the game and other tools
- **/
- QString getDeleterFileName() const;
+ /**
+ * @return the path of the modlist file in this profile
+ */
+ QString getModlistFileName() const;
- /**
- * @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
- **/
- QString getIniFileName() const;
+ /**
+ * @return path of the archives file in this profile
+ */
+ QString getArchivesFileName() const;
- /**
- * @return the path of the tweak ini in this profile
- */
- QString getProfileTweaks() const;
+ /**
+ * @return the path of the delete file in this profile
+ * @note the deleter file lists plugins that should be hidden from the game and other tools
+ **/
+ QString getDeleterFileName() const;
- /**
- * @return path to this profile
- **/
- virtual QString absolutePath() const override;
+ /**
+ * @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
+ **/
+ QString getIniFileName() const;
- /**
- * @return path to this profile's save games
- **/
- QString savePath() const;
+ /**
+ * @return the path of the tweak ini in this profile
+ */
+ QString getProfileTweaks() const;
- /**
- * @brief rename profile
- * @param newName new name of profile
- */
- void rename(const QString& newName);
+ /**
+ * @return path to this profile
+ **/
+ virtual QString absolutePath() const override;
- /**
- * @brief create the ini file to be used by the game
- *
- * the tweaked ini file constructed by this file is a merger
- * of the game-ini of this profile with ini tweaks applied */
- void createTweakedIniFile();
+ /**
+ * @return path to this profile's save games
+ **/
+ QString savePath() const;
- /**
- * @brief re-read the modlist.txt and update the mod status from it
- **/
- void refreshModStatus();
+ /**
+ * @brief rename profile
+ * @param newName new name of profile
+ */
+ void rename(const QString &newName);
- /**
- * @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
- **/
- std::vector<std::tuple<QString, QString, int>> getActiveMods();
+ /**
+ * @brief create the ini file to be used by the game
+ *
+ * the tweaked ini file constructed by this file is a merger
+ * of the game-ini of this profile with ini tweaks applied */
+ void createTweakedIniFile();
- /**
- * retrieve the number of mods for which this object has status information.
- * This is usually the same as ModInfo::getNumMods() except between
- * calls to ModInfo::updateFromDisc() and the Profile::refreshModStatus()
- *
- * @return number of mods for which the profile has status information
- **/
- size_t numMods() const { return m_ModStatus.size(); }
+ /**
+ * @brief re-read the modlist.txt and update the mod status from it
+ **/
+ void refreshModStatus();
- /**
- * @return the number of mods that can be enabled and where the priority can be modified
- */
- unsigned int numRegularMods() const { return m_NumRegularMods; }
+ /**
+ * @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
+ **/
+ std::vector<std::tuple<QString, QString, int> > getActiveMods();
- /**
- * @brief retrieve the mod index based on the priority
- *
- * @param priority priority to look up
- * @return the index of the mod
- * @throw std::exception an exception is thrown if there is no mod with the specified priority
- **/
- unsigned int modIndexByPriority(unsigned int priority) const;
+ /**
+ * retrieve the number of mods for which this object has status information.
+ * This is usually the same as ModInfo::getNumMods() except between
+ * calls to ModInfo::updateFromDisc() and the Profile::refreshModStatus()
+ *
+ * @return number of mods for which the profile has status information
+ **/
+ size_t numMods() const { return m_ModStatus.size(); }
- /**
- * @brief enable or disable a mod
- *
- * @param index index of the mod to enable/disable
- * @param enabled true if the mod is to be enabled, false if it is to be disabled
- **/
- void setModEnabled(unsigned int index, bool enabled);
+ /**
+ * @return the number of mods that can be enabled and where the priority can be modified
+ */
+ unsigned int numRegularMods() const { return m_NumRegularMods; }
- /**
- * change the priority of a mod. Of course this also changes the priority of other mods.
- * The priority of the mods in the range ]old, new priority] are shifted so that no gaps
- * are possible.
- *
- * @param index index of the mod to change
- * @param newPriority the new priority value
- *
- * @todo what happens if the new priority is outside the range?
- **/
- void setModPriority(unsigned int index, int& newPriority);
+ /**
+ * @brief retrieve the mod index based on the priority
+ *
+ * @param priority priority to look up
+ * @return the index of the mod
+ * @throw std::exception an exception is thrown if there is no mod with the specified priority
+ **/
+ unsigned int modIndexByPriority(unsigned int priority) const;
- /**
- * @brief determine if a mod is enabled
- *
- * @param index index of the mod to look up
- * @return true if the mod is enabled, false otherwise
- **/
- bool modEnabled(unsigned int index) const;
+ /**
+ * @brief enable or disable a mod
+ *
+ * @param index index of the mod to enable/disable
+ * @param enabled true if the mod is to be enabled, false if it is to be disabled
+ **/
+ void setModEnabled(unsigned int index, bool enabled);
- /**
- * @brief query the priority of a mod
- *
- * @param index index of the mod to look up
- * @return priority of the specified mod
- **/
- int getModPriority(unsigned int index) const;
+ /**
+ * change the priority of a mod. Of course this also changes the priority of other mods.
+ * The priority of the mods in the range ]old, new priority] are shifted so that no gaps
+ * are possible.
+ *
+ * @param index index of the mod to change
+ * @param newPriority the new priority value
+ *
+ * @todo what happens if the new priority is outside the range?
+ **/
+ void setModPriority(unsigned int index, int &newPriority);
- void dumpModStatus() const;
+ /**
+ * @brief determine if a mod is enabled
+ *
+ * @param index index of the mod to look up
+ * @return true if the mod is enabled, false otherwise
+ **/
+ bool modEnabled(unsigned int index) const;
- QVariant setting(const QString& section, const QString& name, const QVariant& fallback = QVariant());
+ /**
+ * @brief query the priority of a mod
+ *
+ * @param index index of the mod to look up
+ * @return priority of the specified mod
+ **/
+ int getModPriority(unsigned int index) const;
- void storeSetting(const QString& section, const QString& name, const QVariant& value);
- void removeSetting(const QString& section, const QString& name);
+ void dumpModStatus() const;
+
+ QVariant setting(const QString &section, const QString &name,
+ const QVariant &fallback = QVariant());
+
+ void storeSetting(const QString &section, const QString &name,
+ const QVariant &value);
+ void removeSetting(const QString &section, const QString &name);
signals:
- /**
- * @brief emitted whenever the status (enabled/disabled) of a mod changed
- *
- * @param index index of the mod that changed
- **/
- void modStatusChanged(unsigned int index);
+ /**
+ * @brief emitted whenever the status (enabled/disabled) of a mod changed
+ *
+ * @param index index of the mod that changed
+ **/
+ void modStatusChanged(unsigned int index);
public slots:
- // should only be called by DelayedFileWriter, use writeModlist() and writeModlistNow() instead
- void doWriteModlist();
+ // should only be called by DelayedFileWriter, use writeModlist() and writeModlistNow() instead
+ void doWriteModlist();
private:
- class ModStatus {
- friend class Profile;
-
- public:
- ModStatus() : m_Overwrite(false), m_Enabled(false), m_Priority(-1) {}
- private:
- bool m_Overwrite;
- bool m_Enabled;
- int m_Priority;
- };
+ class ModStatus {
+ friend class Profile;
+ public:
+ ModStatus() : m_Overwrite(false), m_Enabled(false), m_Priority(-1) {}
+ private:
+ bool m_Overwrite;
+ bool m_Enabled;
+ int m_Priority;
+ };
private:
- Profile& operator=(const Profile& reference); // not implemented
+ Profile& operator=(const Profile &reference); // not implemented
- void initTimer();
+ void initTimer();
- void updateIndices();
+ 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;
- void touchFile(QString fileName);
- void finishChangeStatus() 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);
+ void finishChangeStatus() const;
- 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;
+ QDir m_Directory;
- const MOBase::IPluginGame* m_GamePlugin;
+ QSettings *m_Settings;
- mutable QByteArray m_LastModlistHash;
- std::vector<ModStatus> m_ModStatus;
- std::vector<unsigned int> m_ModIndexByPriority;
- unsigned int m_NumRegularMods;
+ const MOBase::IPluginGame *m_GamePlugin;
+
+ mutable QByteArray m_LastModlistHash;
+ std::vector<ModStatus> m_ModStatus;
+ std::vector<unsigned int> m_ModIndexByPriority;
+ unsigned int m_NumRegularMods;
+
+ MOBase::DelayedFileWriter m_ModListWriter;
- MOBase::DelayedFileWriter m_ModListWriter;
};
+
#endif // PROFILE_H