This shows you the differences between two versions of the page.
|
knowhow:configuration [2009/12/31 14:59] Tomas Straupis created |
knowhow:configuration [2010/03/22 09:10] (current) Tomas Straupis Update code syntax |
||
|---|---|---|---|
| Line 3: | Line 3: | ||
| * **toConfiguration** (//toconfiguration.h/cpp//) – main class used for configuration. It contains setters and getters for main configuration options (which are stored in //toConfigurationPrivate// object). | * **toConfiguration** (//toconfiguration.h/cpp//) – main class used for configuration. It contains setters and getters for main configuration options (which are stored in //toConfigurationPrivate// object). | ||
| * **toConfigurationPrivate** (//toconfiguration.h/cpp//) – stores all values of configuration values, has functions to load and save configuration data using //QSettings//. | * **toConfigurationPrivate** (//toconfiguration.h/cpp//) – stores all values of configuration values, has functions to load and save configuration data using //QSettings//. | ||
| - | |||
| ===== Usage ===== | ===== Usage ===== | ||
| Line 12: | Line 11: | ||
| File //toconf.h// contains a number of static (build time specified) settings as C++ #defines. This also includes actual names for configuration items. So if there is a configuration item for say “maximum delay” then actual string used when calling //QSetting// methods will be defined in //toconf.h// in this way: | File //toconf.h// contains a number of static (build time specified) settings as C++ #defines. This also includes actual names for configuration items. So if there is a configuration item for say “maximum delay” then actual string used when calling //QSetting// methods will be defined in //toconf.h// in this way: | ||
| - | ''#define CONF_MAXIMUM_DELAY “maximum delay”.'' | + | <code>#define CONF_MAXIMUM_DELAY “maximum delay”</code> |
| This define will be used in actual calls to //QSetting// methods. This is done in order not to repeat the same string more than once raising a risk of mistyping setting name. This file will also contain defines for default values. For example: | This define will be used in actual calls to //QSetting// methods. This is done in order not to repeat the same string more than once raising a risk of mistyping setting name. This file will also contain defines for default values. For example: | ||
| - | ''#define DEFAULT_MAXIMUM_DELAY 1000'' | + | <code>#define DEFAULT_MAXIMUM_DELAY 1000</code> |
| ===== User interface ===== | ===== User interface ===== | ||
| Line 26: | Line 25: | ||
| * Class **toDatabaseSetting** (todatabasesetting.ui/toglobalsetting.h/cpp) – database access options. As children of these settings, a separate setting set for each database provider (oracle, mysql, postgre etc.) is added. | * Class **toDatabaseSetting** (todatabasesetting.ui/toglobalsetting.h/cpp) – database access options. As children of these settings, a separate setting set for each database provider (oracle, mysql, postgre etc.) is added. | ||
| * Class **toToolSetting** (//totoolsettingui.ui/toglobalsetting.h/cpp//) – settings for all tools defined in TOra. Configuration sets for each tool are added as children of this setting (for a tool to have its own configuration set, it must define method //configurationTab//). | * Class **toToolSetting** (//totoolsettingui.ui/toglobalsetting.h/cpp//) – settings for all tools defined in TOra. Configuration sets for each tool are added as children of this setting (for a tool to have its own configuration set, it must define method //configurationTab//). | ||
| - | |||
| ===== Adding new configuration option ===== | ===== Adding new configuration option ===== | ||
| Line 35: | Line 33: | ||
| * Add statement to save option value in //toConfigurationPrivate::saveConfig()// | * Add statement to save option value in //toConfigurationPrivate::saveConfig()// | ||
| * Add statement to load option value in //toConfigurationPrivate::loadConfig()// | * Add statement to load option value in //toConfigurationPrivate::loadConfig()// | ||
| - | * Add setter and getter methods in **toConfiguration** (//toconfiguration.h//) | + | * Add setter and getter methods in **toConfiguration** (specification in //toconfiguration.h// and code in //toconfiguration.cpp//) |
| * Add logic to load value to preferences dialog as well as save it (in case of Code editor that is done in //toSyntaxSetup::saveSetting// & //toSyntaxSetup::toSyntaxSetup//). | * Add logic to load value to preferences dialog as well as save it (in case of Code editor that is done in //toSyntaxSetup::saveSetting// & //toSyntaxSetup::toSyntaxSetup//). | ||
| + | |||
| + | From now on if you need to use configuration option value you have to include //toconfiguration.h// and call a getter (or setter) method you've just created: | ||
| + | |||
| + | <code>#include "toconfiguration.h" | ||
| + | ... | ||
| + | toConfigurationSingle::Instance().getMyOption();</code> | ||