summaryrefslogtreecommitdiffstats
path: root/depends/settings/include/settingsobject.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
commitbb7e8985f6d189de0acac6a1c3033cb16378c1fb (patch)
tree7c2e88c7184a7f5acf5e7a03be5c5f0bf6904113 /depends/settings/include/settingsobject.h
parentd6e4fb29713d6ce55b092c0e22412f6121e7f516 (diff)
downloadMultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.gz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.lz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.xz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.zip
Reformat and (slightly) decruft all the things.
Diffstat (limited to 'depends/settings/include/settingsobject.h')
-rw-r--r--depends/settings/include/settingsobject.h77
1 files changed, 41 insertions, 36 deletions
diff --git a/depends/settings/include/settingsobject.h b/depends/settings/include/settingsobject.h
index e8bf5c83..7a6b3cb6 100644
--- a/depends/settings/include/settingsobject.h
+++ b/depends/settings/include/settingsobject.h
@@ -3,7 +3,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -23,9 +23,10 @@
class Setting;
/*!
- * \brief The SettingsObject handles communicating settings between the application and a settings file.
+ * \brief The SettingsObject handles communicating settings between the application and a
+ *settings file.
* The class keeps a list of Setting objects. Each Setting object represents one
- * of the application's settings. These Setting objects are registered with
+ * of the application's settings. These Setting objects are registered with
* a SettingsObject and can be managed similarly to the way a list works.
*
* \author Andrew Okin
@@ -38,9 +39,10 @@ class LIBSETTINGS_EXPORT SettingsObject : public QObject
Q_OBJECT
public:
explicit SettingsObject(QObject *parent = 0);
-
+
/*!
- * \brief Registers the given setting with this SettingsObject and connects the necessary signals.
+ * \brief Registers the given setting with this SettingsObject and connects the necessary
+ * signals.
* This will fail if there is already a setting with the same ID as
* the one that is being registered.
* \note Registering a setting object causes the SettingsObject to take ownership
@@ -52,36 +54,38 @@ public:
* \return True if successful. False if registry failed.
*/
virtual bool registerSetting(Setting *setting);
-
+
/*!
- * \brief Unregisters the given setting from this SettingsObject and disconnects its signals.
- * \note This does not delete the setting. Furthermore, when the setting is
+ * \brief Unregisters the given setting from this SettingsObject and disconnects its
+ * signals.
+ * \note This does not delete the setting. Furthermore, when the setting is
* unregistered, the SettingsObject drops ownership of the setting. This means
* that if you unregister a setting, its parent is set to null and you become
* responsible for freeing its memory.
* \param setting The setting to unregister.
*/
virtual void unregisterSetting(Setting *setting);
-
-
+
/*!
* \brief Gets the setting with the given ID.
* \param id The ID of the setting to get.
- * \return A pointer to the setting with the given ID.
+ * \return A pointer to the setting with the given ID.
* Returns null if there is no setting with the given ID.
* \sa operator []()
*/
virtual Setting *getSetting(const QString &id) const;
-
+
/*!
* \brief Same as getSetting()
* \param id The ID of the setting to get.
- * \return A pointer to the setting with the given ID.
+ * \return A pointer to the setting with the given ID.
* \sa getSetting()
*/
- inline Setting *operator [](const QString &id) { return getSetting(id); }
-
-
+ inline Setting *operator[](const QString &id)
+ {
+ return getSetting(id);
+ }
+
/*!
* \brief Gets the value of the setting with the given ID.
* \param id The ID of the setting to get.
@@ -89,7 +93,7 @@ public:
* If no setting with the given ID exists, returns an invalid QVariant.
*/
virtual QVariant get(const QString &id) const;
-
+
/*!
* \brief Sets the value of the setting with the given ID.
* If no setting with the given ID exists, returns false and logs to qDebug
@@ -98,87 +102,88 @@ public:
* \return True if successful, false if it failed.
*/
virtual bool set(const QString &id, QVariant value);
-
+
/*!
* \brief Reverts the setting with the given ID to default.
* \param id The ID of the setting to reset.
*/
virtual void reset(const QString &id) const;
-
+
/*!
* \brief Gets a QList with pointers to all of the registered settings.
* The order of the entries in the list is undefined.
* \return A QList with pointers to all registered settings.
*/
virtual QList<Setting *> getSettings();
-
+
/*!
* \brief Checks if this SettingsObject contains a setting with the given ID.
* \param id The ID to check for.
* \return True if the SettingsObject has a setting with the given ID.
*/
virtual bool contains(const QString &id);
-
+
signals:
/*!
* \brief Signal emitted when one of this SettingsObject object's settings changes.
- * This is usually just connected directly to each Setting object's
+ * This is usually just connected directly to each Setting object's
* settingChanged() signals.
* \param setting A reference to the Setting object that changed.
* \param value The Setting object's new value.
*/
void settingChanged(const Setting &setting, QVariant value);
-
+
/*!
* \brief Signal emitted when one of this SettingsObject object's settings resets.
- * This is usually just connected directly to each Setting object's
+ * This is usually just connected directly to each Setting object's
* settingReset() signals.
* \param setting A reference to the Setting object that changed.
*/
void settingReset(const Setting &setting);
-
-protected slots:
+
+protected
+slots:
/*!
* \brief Changes a setting.
- * This slot is usually connected to each Setting object's
+ * This slot is usually connected to each Setting object's
* settingChanged() signal. The signal is emitted, causing this slot
* to update the setting's value in the config file.
* \param setting A reference to the Setting object that changed.
* \param value The setting's new value.
*/
virtual void changeSetting(const Setting &setting, QVariant value) = 0;
-
+
/*!
* \brief Resets a setting.
- * This slot is usually connected to each Setting object's
+ * This slot is usually connected to each Setting object's
* settingReset() signal. The signal is emitted, causing this slot
* to update the setting's value in the config file.
* \param setting A reference to the Setting object that changed.
*/
virtual void resetSetting(const Setting &setting) = 0;
-
+
protected:
/*!
* \brief Connects the necessary signals to the given Setting.
* \param setting The setting to connect.
*/
virtual void connectSignals(const Setting &setting);
-
+
/*!
* \brief Disconnects signals from the given Setting.
* \param setting The setting to disconnect.
*/
virtual void disconnectSignals(const Setting &setting);
-
+
/*!
* \brief Function used by Setting objects to get their values from the SettingsObject.
- * \param setting The
- * \return
+ * \param setting The
+ * \return
*/
virtual QVariant retrieveValue(const Setting &setting) = 0;
-
+
friend class Setting;
-
+
private:
QMap<QString, Setting *> m_settings;
};