Commit 1de4a162 authored by Clement CHAVANCE's avatar Clement CHAVANCE

Cleaned code an added doc for files in src/Configuration

parent 8fe48ee2
......@@ -564,7 +564,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = ..
INPUT = ../src/Configuration/
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......
......@@ -25,14 +25,49 @@
#include <QString>
/**
* \class ProjectSettingsDefault
*
* \brief Static class for loading default parameters
* for the project
*/
class ProjectSettingsDefault
{
public:
/**
* \brief load all the project defaults parameters
* \param part the settings part in wich the default values will
* be loaded
*/
static void load( const QString& part );
private:
/**
* \brief will load the project Audio related values.
* \param part the settings part in wich the audio default
* values will be loaded
*/
static void loadAudioDefaults( const QString& part );
/**
* \brief will load the project Video related values.
* \param part the settings part in wich the audio default
* values will be loaded
*/
static void loadVideoDefaults( const QString& part );
/**
* \brief will load the Project global values.
* \param part the settings part in wich the project default
* values will be loaded
*/
static void loadProjectDefaults( const QString& part );
private:
......
......@@ -39,8 +39,3 @@ const QVariant& SettingValue::get() const
{
return m_val;
}
QVariant& SettingValue::get()
{
return m_val;
}
......@@ -26,18 +26,42 @@
#include <QObject>
#include <QVariant>
/**
* 'class SettingValue
*
* \brief represent a setting value
*
*/
class SettingValue : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( SettingValue );
public:
SettingValue( const QVariant& val );
/**
* \brief setter for the m_val member
* \param val the value wich will be affected to m_val
*/
void set( const QVariant& val );
/**
* \brief getter for the m_val member
*/
const QVariant& get() const;
QVariant& get();
private:
/**
* \brief the QVariant containingthe value of the settings
*/
QVariant m_val;
signals:
/**
* \brief This signal is emmited while the m_val
* member have been modified
*/
void changed( const QVariant& );
};
......
......@@ -35,13 +35,37 @@ class QDomDocument;
class QDomElement;
class QString;
/**
* \struct SettingsPart
* \brief Represent a part of the Settings.
*
* This is used to group different settings, and to be able to easily
* save or load just a part of all the settings used by the application.
*/
struct SettingsPart
{
typedef QHash<QString, SettingValue*> ConfigPair;
SettingsPart() {}
/**
* \brief the HashList containing the settings
*/
ConfigPair m_data;
/**
* \brief The ReadWriteLock used for when we need to read / write the settingsPart.
*/
QReadWriteLock m_lock;
/**
* \brief This flag is used when the SettingsPart is
* a readOnly Part.
*/
bool m_rdOnly;
private:
......@@ -49,6 +73,10 @@ struct SettingsPart
SettingsPart& operator =( const SettingsPart& );
};
/**
* \class SettingsManager
* \brief Will manage everything related to the settings.
*/
class SettingsManager : public QObject, public QSingleton<SettingsManager>
{
......@@ -57,28 +85,143 @@ class SettingsManager : public QObject, public QSingleton<SettingsManager>
friend class QSingleton<SettingsManager>;
public:
// void setValues( const QString& part, SettingsPart::ConfigPair );
/**
* \brief Set a value to an existing or a new SettingValue
*
* If the SettingsPart part does not exist, it will be created
* \sa commit()
* \param part the part in wich the value will be set
* \param key the key of the setting
* \param value the value of the setting
*/
void setValue( const QString& part, const QString& key, const QVariant& value );
/**
* \brief get a settings value for a given name
*
* if the settings is not in part, return the default value
* for this setting
* \param part the part where the settings is stored
* \param key the setting's name
* \return the settingPart named part
* \warning if part does not exist, return a NULL pointer
*/
const SettingValue* getValue( const QString& part, const QString& key ) const;
/**
* \brief getter for a settingsPart
* \param part the name of the part we wish to get
* \return The settingsPart named part
* \warning returns a NULL pointer if the SettingsPart part does not exist
*/
const SettingsPart* getConfigPart( const QString& part ) const;
/**
* \brief save a settingPart into a DomDocument
*
* This will only save one part, to save all the preferences, you have to call
* this method with all the name of the existing SettingsPart
* \param part The part to save
* \param xmlfile The QDomDocument used to create new QDomElements
* \param root The root Element of the xml file in wich the project will be saved.
*/
void saveSettings( const QString& part, QDomDocument& xmlfile, QDomElement& root );
/**
* \brief load a Settings part from a QDomElement
*
* after all settings contained in the donElement have been loaded, this method will emit the
* settingsLoaded() signal
* \param part the Settings part to Load. The settings part must exist in order to be loaded
* \param settings the QDomElement containing the settingPart to load.
*/
void loadSettings( const QString& part, const QDomElement& settings );
/**
* \brief add a new SettingsPart
* \param name the name of the SettingPart that need to be created
*
* The SettingsPart is not created if name is already used by another
* SettingsPart
*/
void addNewSettingsPart( const QString& name );
/**
* \brief commit all change made into the settingManager
*
* This will commit all the settings modified with the SetValue method
* that have been stored in a temporary Hashlist to the settingManager HashList.
* It allow us to discard all the modified settings that have been modified. like when the user
* press the cancel button wile configuring the project settings via the project wizard
* \sa flush()
*/
void commit();
/**
* \brief clean the temporary value stored in the SettingsManager
*
* this method allow the user to cancel all the modifications made to the settingsManager
* between two calls of the commit method.
* this method is also called at the end of the commit method
*/
void flush();
/**
* \brief Will load the default value of the application and the project settings
*
* the defaults are only loaded once
*/
static void loadDefaultsSettings();
/**
* \brief Return the only available instance of the settingsManager
*/
static SettingsManager* getInstance();
private:
SettingsManager( QObject* parent = 0 );
~SettingsManager();
/**
* \brief the HashList containing the SettingsPart available
*/
QHash<QString, SettingsPart*> m_data;
/**
* \brief the temporary HashList containing the SettingsPart that have been modified between two commits
*/
QHash<QString, SettingsPart*> m_tempData;
/**
* \brief The ReadWriteLock used for when we need to read / write the settingsPart haslist.
*/
mutable QReadWriteLock m_globalLock;
/**
* \brief this boolean is used to check if the defaults dettings have already been loaded
*/
static bool m_defaultLoaded;
signals:
/**
* \brief This signal is emmited when the settings have been loaded from a domDocument
*/
void settingsLoaded();
};
......
......@@ -25,16 +25,61 @@
#include <QString>
/**
* \class VLMCSettingsDefault
*
* \brief Static class for loading default parameters
* for the application
*/
class VLMCSettingsDefault
{
public:
/**
* \brief load all the application defaults parameters
* \param part the settings part in wich the default values will
* be loaded
*/
static void load( const QString& part );
/**
* \brief will load the values for the shortcuts settings.
*
* This method will create a new part in the settings Manager
* called keyboard_shortcut
* \sa loadKeyboardShortcutDefaults( const QString& part )
*/
static void loadKeyboardShortcutDefaults();
private:
/**
* \brief will load the values for the application global values.
* \param part the settings part in wich the global default
* values will be loaded
*/
static void loadVLMCDefaults( const QString& part );
/**
* \brief will load the values for the language settings.
* \param part the settings part in wich the language
* default values will be loaded
*/
static void loadlanguageDefaults( const QString& part );
/**
* \brief will load the values for the shortcuts settings.
* \param part the settings part in wich the language
* default values will be loaded
*/
static void loadKeyboardShortcutDefaults( const QString& part );
private:
VLMCSettingsDefault();
~VLMCSettingsDefault();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment