UniversalIndentGUI 1.2.0
Public Slots | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes
UiGuiSettings Class Reference

Handles the settings of the program. Reads them on startup and saves them on exit. Is a singleton class and can only be accessed via getInstance(). More...

#include <UiGuiSettings.h>

Inheritance diagram for UiGuiSettings:
Inheritance graph
[legend]

List of all members.

Public Slots

void setValueByName (const QString &settingName, const QVariant &value)
 Sets the setting defined by settingName to value.
void unregisterObjectProperty (QObject *obj)
 The with a certain property registered obj gets unregistered.
void unregisterObjectSlot (QObject *obj, const QString &slotName="", const QString &settingName="")
 If obj, slotName and settingName are given, that certain connection is unregistered. If only obj is given, all to this object registered slot-setting connections are unregistered.

Public Member Functions

QStringList getAvailableTranslations ()
 Returns a list of the mnemonics of the available translations.
QVariant getValueByName (QString settingName)
 Returns the value of the by settingsName defined setting as QVariant.
bool registerObjectProperty (QObject *obj, const QString &propertyName, const QString &settingName)
 Register the by propertyName defined property of obj to be connected to the setting defined by settingName.
bool registerObjectPropertyRecursive (QObject *obj)
 Searches the child QObjects of obj for a property name and setting name definition within their custom properties and registers this property name to that setting name if both were found.
bool registerObjectSlot (QObject *obj, const QString &slotName, const QString &settingName)
 Registers a slot form the obj by its slotName to be invoked, if the by settingName defined setting changes.
bool setObjectPropertyToSettingValue (QObject *obj, const QString &propertyName, const QString &settingName)
 Assigns the by settingName defined setting value to the by propertyName defined property of obj.
bool setObjectPropertyToSettingValueRecursive (QObject *obj)
 Searches the child QObjects of obj for a property name and setting name definition within their custom properties and sets each property to settings value.
bool setSettingToObjectPropertyValue (QObject *obj, const QString &propertyName, const QString &settingName)
 Assigns the by propertyName defined property's value of obj to the by settingName defined setting.
bool setSettingToObjectPropertyValueRecursive (QObject *obj)
 Searches the child QObjects of obj for a property name and setting name definition within their custom properties and sets each setting to the property value.
 ~UiGuiSettings ()
 The destructor saves the settings to a file.

Static Public Member Functions

static QSharedPointer
< UiGuiSettings
getInstance ()
 Returns the instance of the settings class. If no instance exists, ONE will be created.

Protected Member Functions

bool checkCustomPropertiesAndCallFunction (QObject *obj, bool(UiGuiSettings::*callBackFunc)(QObject *obj, const QString &propertyName, const QString &settingName))
 Iterates over all objs child QObjects and checks whether they have the custom properties "connectedPropertyName" and "connectedSettingName" set. If both are set, it invokes the callBackFunc with both.
bool initSettings ()
 Loads the settings for the main application.
bool invokeMethodWithValue (QObject *obj, QMetaMethod mMethod, QVariant value)

Private Slots

void handleObjectPropertyChange ()
 This private slot gets invoked whenever a registered objects property changes and distributes the new value to all other to the same settingName registered objects.

Private Member Functions

void readAvailableTranslations ()
 Scans the translations directory for available translation files and stores them in the QList _availableTranslations.
 UiGuiSettings ()
 The constructor for the settings.

Private Attributes

QStringList _availableTranslations
 Stores the mnemonics of the available translations.
QString _indenterDirctoryStr
QSettings * _qsettings
 The settings file.
QMap< QObject *, QStringList > _registeredObjectProperties
 Maps an QObject to a string list containing the property name and the associated setting name.
QMultiMap< QObject *, QStringList > _registeredObjectSlots
 Maps QObjects to a string list containing the method name and the associated setting name.

Static Private Attributes

static QWeakPointer
< UiGuiSettings
_instance

Detailed Description

Handles the settings of the program. Reads them on startup and saves them on exit. Is a singleton class and can only be accessed via getInstance().

Definition at line 31 of file UiGuiSettings.h.


Constructor & Destructor Documentation

UiGuiSettings::UiGuiSettings ( ) [private]

The constructor for the settings.

Definition at line 51 of file UiGuiSettings.cpp.

References _indenterDirctoryStr, _qsettings, SettingsPaths::getGlobalFilesPath(), SettingsPaths::getSettingsPath(), initSettings(), and readAvailableTranslations().

Referenced by getInstance().

Here is the call graph for this function:

Here is the caller graph for this function:

UiGuiSettings::~UiGuiSettings ( )

The destructor saves the settings to a file.

Definition at line 79 of file UiGuiSettings.cpp.

References _availableTranslations, and _qsettings.


Member Function Documentation

bool UiGuiSettings::checkCustomPropertiesAndCallFunction ( QObject obj,
bool(UiGuiSettings::*)(QObject *obj, const QString &propertyName, const QString &settingName)  callBackFunc 
) [protected]

Iterates over all objs child QObjects and checks whether they have the custom properties "connectedPropertyName" and "connectedSettingName" set. If both are set, it invokes the callBackFunc with both.

Definition at line 363 of file UiGuiSettings.cpp.

Referenced by registerObjectPropertyRecursive(), setObjectPropertyToSettingValueRecursive(), and setSettingToObjectPropertyValueRecursive().

Here is the caller graph for this function:

QStringList UiGuiSettings::getAvailableTranslations ( )

Returns a list of the mnemonics of the available translations.

Definition at line 119 of file UiGuiSettings.cpp.

References _availableTranslations.

QSharedPointer< UiGuiSettings > UiGuiSettings::getInstance ( ) [static]

Returns the instance of the settings class. If no instance exists, ONE will be created.

Definition at line 64 of file UiGuiSettings.cpp.

References _instance, and UiGuiSettings().

Referenced by IndentHandler::IndentHandler(), and MainWindow::MainWindow().

Here is the call graph for this function:

Here is the caller graph for this function:

QVariant UiGuiSettings::getValueByName ( QString  settingName)

Returns the value of the by settingsName defined setting as QVariant.

If the named setting does not exist, 0 is being returned.

Definition at line 129 of file UiGuiSettings.cpp.

References _qsettings.

void UiGuiSettings::handleObjectPropertyChange ( ) [private, slot]

This private slot gets invoked whenever a registered objects property changes and distributes the new value to all other to the same settingName registered objects.

Definition at line 474 of file UiGuiSettings.cpp.

References _registeredObjectProperties, and setValueByName().

Referenced by registerObjectProperty(), and unregisterObjectProperty().

Here is the call graph for this function:

Here is the caller graph for this function:

bool UiGuiSettings::initSettings ( ) [protected]

Loads the settings for the main application.

Settings are for example last selected indenter, last loaded source code file and so on.

Definition at line 139 of file UiGuiSettings.cpp.

References _availableTranslations, _indenterDirctoryStr, and _qsettings.

Referenced by UiGuiSettings().

Here is the caller graph for this function:

bool UiGuiSettings::invokeMethodWithValue ( QObject obj,
QMetaMethod  mMethod,
QVariant  value 
) [protected]

Definition at line 572 of file UiGuiSettings.cpp.

Referenced by setValueByName().

Here is the caller graph for this function:

void UiGuiSettings::readAvailableTranslations ( ) [private]

Scans the translations directory for available translation files and stores them in the QList _availableTranslations.

Definition at line 93 of file UiGuiSettings.cpp.

References _availableTranslations, and SettingsPaths::getGlobalFilesPath().

Referenced by UiGuiSettings().

Here is the call graph for this function:

Here is the caller graph for this function:

bool UiGuiSettings::registerObjectProperty ( QObject obj,
const QString &  propertyName,
const QString &  settingName 
)

Register the by propertyName defined property of obj to be connected to the setting defined by settingName.

The propertyName must be one of those that are listed in the Qt "Properties" documentation section of a Qt Object. All further needed info is retrieved via the obj's MetaObject, like the to the property bound signal.

Definition at line 200 of file UiGuiSettings.cpp.

References _qsettings, _registeredObjectProperties, handleObjectPropertyChange(), and unregisterObjectProperty().

Referenced by registerObjectPropertyRecursive().

Here is the call graph for this function:

Here is the caller graph for this function:

bool UiGuiSettings::registerObjectPropertyRecursive ( QObject obj)

Searches the child QObjects of obj for a property name and setting name definition within their custom properties and registers this property name to that setting name if both were found.

The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and "connectedSettingName" is the name of a setting here within UiGuiSettings. If the mentioned setting name doesn't exist, it will be created.

Returns true, if all found property and setting definitions could be successfully registered. Returns false, if any of those registrations fails.

Definition at line 260 of file UiGuiSettings.cpp.

References checkCustomPropertiesAndCallFunction(), and registerObjectProperty().

Here is the call graph for this function:

bool UiGuiSettings::registerObjectSlot ( QObject obj,
const QString &  slotName,
const QString &  settingName 
)

Registers a slot form the obj by its slotName to be invoked, if the by settingName defined setting changes.

The registered slot may have no parameters or exactly one. If it accepts one parameter, whenever the setting settingName changes the slot gets tried to be invoked with the settings value as parameter. This only works, if the slot parameter is of the same type as the setting.

Definition at line 416 of file UiGuiSettings.cpp.

References _registeredObjectSlots, and unregisterObjectSlot().

Here is the call graph for this function:

bool UiGuiSettings::setObjectPropertyToSettingValue ( QObject obj,
const QString &  propertyName,
const QString &  settingName 
)

Assigns the by settingName defined setting value to the by propertyName defined property of obj.

Returns true, if the value could be assigned, otherwise returns false, which is the case if settingName doesn't exist within the settings or if the mentioned propertyName wasn't found for the obj.

Definition at line 271 of file UiGuiSettings.cpp.

References _qsettings.

Referenced by setObjectPropertyToSettingValueRecursive().

Here is the caller graph for this function:

bool UiGuiSettings::setObjectPropertyToSettingValueRecursive ( QObject obj)

Searches the child QObjects of obj for a property name and setting name definition within their custom properties and sets each property to settings value.

The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and "connectedSettingName" is the name of a setting here within UiGuiSettings.

Returns true, if all found property and setting definitions could be successfully registered. Returns false, if any of those registrations fails.

Definition at line 309 of file UiGuiSettings.cpp.

References checkCustomPropertiesAndCallFunction(), and setObjectPropertyToSettingValue().

Here is the call graph for this function:

bool UiGuiSettings::setSettingToObjectPropertyValue ( QObject obj,
const QString &  propertyName,
const QString &  settingName 
)

Assigns the by propertyName defined property's value of obj to the by settingName defined setting.

If the settingName didn't exist yet, it will be created.

Returns true, if the value could be assigned, otherwise returns false, which is the case if the mentioned propertyName wasn't found for the obj.

Definition at line 322 of file UiGuiSettings.cpp.

References setValueByName().

Referenced by setSettingToObjectPropertyValueRecursive().

Here is the call graph for this function:

Here is the caller graph for this function:

bool UiGuiSettings::setSettingToObjectPropertyValueRecursive ( QObject obj)

Searches the child QObjects of obj for a property name and setting name definition within their custom properties and sets each setting to the property value.

The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and "connectedSettingName" is the name of a setting here within UiGuiSettings. If the settingName didn't exist yet, it will be created.

Returns true, if all found property and setting definitions could be successfully registered. Returns false, if any of those registrations fails.

Definition at line 353 of file UiGuiSettings.cpp.

References checkCustomPropertiesAndCallFunction(), and setSettingToObjectPropertyValue().

Here is the call graph for this function:

void UiGuiSettings::setValueByName ( const QString &  settingName,
const QVariant &  value 
) [slot]

Sets the setting defined by settingName to value.

When setting a changed value, all to this settingName registered objects get the changed value set too. If the settingName didn't exist yet, it will be created.

Definition at line 496 of file UiGuiSettings.cpp.

References _qsettings, _registeredObjectProperties, _registeredObjectSlots, and invokeMethodWithValue().

Referenced by handleObjectPropertyChange(), and setSettingToObjectPropertyValue().

Here is the call graph for this function:

Here is the caller graph for this function:

void UiGuiSettings::unregisterObjectProperty ( QObject obj) [slot]

The with a certain property registered obj gets unregistered.

Definition at line 385 of file UiGuiSettings.cpp.

References _registeredObjectProperties, and handleObjectPropertyChange().

Referenced by registerObjectProperty().

Here is the call graph for this function:

Here is the caller graph for this function:

void UiGuiSettings::unregisterObjectSlot ( QObject obj,
const QString &  slotName = "",
const QString &  settingName = "" 
) [slot]

If obj, slotName and settingName are given, that certain connection is unregistered. If only obj is given, all to this object registered slot-setting connections are unregistered.

Definition at line 456 of file UiGuiSettings.cpp.

References _registeredObjectSlots.

Referenced by registerObjectSlot().

Here is the caller graph for this function:


Member Data Documentation

Stores the mnemonics of the available translations.

Definition at line 69 of file UiGuiSettings.h.

Referenced by getAvailableTranslations(), initSettings(), readAvailableTranslations(), and ~UiGuiSettings().

Definition at line 80 of file UiGuiSettings.h.

Referenced by initSettings(), and UiGuiSettings().

QWeakPointer< UiGuiSettings > UiGuiSettings::_instance [static, private]

Definition at line 36 of file UiGuiSettings.h.

Referenced by getInstance().

QSettings* UiGuiSettings::_qsettings [private]
QMap<QObject*, QStringList> UiGuiSettings::_registeredObjectProperties [private]

Maps an QObject to a string list containing the property name and the associated setting name.

Definition at line 75 of file UiGuiSettings.h.

Referenced by handleObjectPropertyChange(), registerObjectProperty(), setValueByName(), and unregisterObjectProperty().

QMultiMap<QObject*, QStringList> UiGuiSettings::_registeredObjectSlots [private]

Maps QObjects to a string list containing the method name and the associated setting name.

Definition at line 78 of file UiGuiSettings.h.

Referenced by registerObjectSlot(), setValueByName(), and unregisterObjectSlot().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines