Classes

  • 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.

Usage

TOra uses Qt's QSettings class to store and retrieve all settings. ToConfiguration::setQSettignsEnv() sets organisation name, domain and application name for QCoreApplication which is later used in determining actual filename storing configuration on linux (or branch in registry for redmond) (see Qt QSettings documentation for more details). Values for these parameters are defined in toconf.h.

Class toConfigurationPrivate contains method loadConfig which is getting values from configuration storage. Note that calls to getter methods contain default values for configuration items.

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”

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

User interface

Base for user interface for preferences (edit→preferences) is topreferences.ui, but it only describes base of preferences dialog without any actual preferences. Actual preferences are added dynamically (in class toPreferences) and are defined in topreferences.h/cpp. Following settings (representing one item of choice in setting list and one corresponding set of options) are added:

  • Class toGlobalSetting (toglobalsetting.h/cpp/ui) - global TOra settings.
  • Class toSyntaxSetup (tosyntaxsetup.h/cpp/ui) – configuration for PLSQLEditor tool.
  • 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).

Adding new configuration option

In order to add a new configuration option you will have to:

  • Add a variable to hold option value in class toConfigurationPrivate (toconfiguration.cpp).
  • Define configuration option string value (used when saving option value) in toconf.h
  • Add statement to save option value in toConfigurationPrivate::saveConfig()
  • Add statement to load option value in toConfigurationPrivate::loadConfig()
  • 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).

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:

#include "toconfiguration.h"
...
toConfigurationSingle::Instance().getMyOption();

 
knowhow/configuration.txt · Last modified: 2010/03/22 16:10 by Tomas Straupis
Recent changes RSS feed Privacy Policy Support This Project