Documents > BPS V2 C++ API
BpsSettings Class Reference

Query and edit settings. More...

#include <bpssettings.h>

List of all members.

Public Types

enum  Scope {
  NoScope = 0x00000000,
  LocalUserScope = 0x00000001,
  LocalInstallScope = 0x00000002,
  LocalSystemScope = 0x00000004,
  CentralUserScope = 0x00000010,
  CentralSystemScope = 0x00000020,
  LocalScopes = LocalUserScope | LocalInstallScope | LocalSystemScope,
  CentralScopes = CentralUserScope | CentralSystemScope,
  AllScopes = LocalScopes | CentralScopes
}
 Scope under which the settings are located. More...

Public Member Functions

QStringList allGroups (Scopes aSearchedScopes=(Scopes) AllScopes) const
 Find all groups within the currently opened path.
QStringList allKeys (Scopes aSearchedScopes=(Scopes) AllScopes) const
 Find all keys within the currently opened path.
 BpsSettings (BpsDatastore *aDatastore, Scope aScope=BpsSettings::LocalUserScope, QObject *aParent=0)
 Constructor for the BpsSettings objects.
 BpsSettings (Scope aScope=BpsSettings::LocalUserScope, QObject *aParent=0)
 Constructor for the BpsSettings objects.
void close ()
 Close the latest opened path.
void closeAll ()
 Close all currently opened paths.
QVariant findValue (const QString &aKey, const QVariant &aDefValue=QVariant(), Scopes aSearchedScopes=(Scopes) AllScopes) const
 Find a value within the currently opened path.
bool groupExists (const QString &aGroup) const
 Check if the group exists in the current scope.
QStringList groups () const
 Query a list of all existing groups within the currently opened path.
Scope groupScope (const QString &aName, Scopes aSearchedScopes=(Scopes) AllScopes) const
 Find the first scope of a group within the currently opened path.
bool keyExists (const QString &aKey) const
 Check if the key exists in the current scope.
QStringList keys () const
 Query a list of all existing keys in the currently opened group.
void open (const QString &aPath)
 Open a new path.
void removeGroup (const QString &aName)
 Remove a group from the currently opened path.
void removeKey (const QString &aKey)
 Remove a key.
QString root () const
 Get the current root.
Scope scope () const
void setRoot (const QString &aRoot)
 Set a new root.
void setScope (Scope aScope)
 Change the current scope.
void setValue (const QString &aKey, const QVariant &aValue)
 Set a value within the currently opened path.
void setValueMap (const QVariantMap &aMap)
 Removes any previously existing keys from the currently opened path and scope, and adds the values in the given map instead.
QVariant value (const QString &aKey, const QVariant &aDefValue=QVariant()) const
 Get a value within the currently opened path.
QVariantMap valueMap (Scopes aSearchedScopes=(Scopes) AllScopes) const
 Find all keys and values within the currently opened path.

Detailed Description

Query and edit settings.


Member Enumeration Documentation

Scope under which the settings are located.

The term "local machine" refers to the user workstation in fat client environments, however in terminal server environments it is the terminal server (citrix for example).

Enumerator:
NoScope 

No valid scope.

Used for example as result by groupScope().

LocalUserScope 

Settings of the current operating system user on the local machine.

On windows this is in the registry under HKCU/Software/IBK Software AG/BPS2

LocalInstallScope 

Settings of the software installation on the locale machine.

On windows this is the file bps.conf in the same directory as the executed program. For example when the currently executed program is located in C:\Programs\IBK Software AG\BPS2\bin, the settings are in file C:\Programs\IBK Software AG\BPS2\bin\bps.conf

LocalSystemScope 

Settings valid for all users on the local machine.

On windows this is in the registry under HKLM/Software/IBK Software AG/BPS2

CentralUserScope 

Central settings for the current bps user.

The settings are located in the database table t_usersettings.

CentralSystemScope 

Central settings for all bps users.

The settings are located in the database table t_settings.

LocalScopes 

All local scopes.

Use only for parameters of type Scopes.

CentralScopes 

All central scopes.

Use only for parameters of type Scopes.

AllScopes 

All scopes.

Use only for parameters of type Scopes.


Constructor & Destructor Documentation

BpsSettings::BpsSettings ( BpsDatastore aDatastore,
Scope  aScope = BpsSettings::LocalUserScope,
QObject *  aParent = 0 
)

Constructor for the BpsSettings objects.

Use this constructor when directly accessing central settings, or the settings chain shall be searched up to CentralSystemScope by findValue().

Parameters:
[in]aDatastoreThe opened database connection.
[in]aScopeThe scope to operate on.
[in]aParentPointer to parent object.
BpsSettings::BpsSettings ( Scope  aScope = BpsSettings::LocalUserScope,
QObject *  aParent = 0 
)

Constructor for the BpsSettings objects.

Use this constructor when accessing local setting only.

Parameters:
[in]aScopeThe scope to operate on.
[in]aParentPointer to parent object.

Member Function Documentation

QStringList BpsSettings::allGroups ( Scopes  aSearchedScopes = (Scopes) AllScopes) const

Find all groups within the currently opened path.

Search begins at the current scope and goes up to CentralSystemScope. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope. Group names found at multiple scopes are merged into one entry.

Parameters:
[in]aSearchedScopesMask of scopes that shall be included in the search.
Returns:
A list of the found group names.
QStringList BpsSettings::allKeys ( Scopes  aSearchedScopes = (Scopes) AllScopes) const

Find all keys within the currently opened path.

Search begins at the current scope and goes up to CentralSystemScope. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope. Key names found at multiple scopes are merged into one entry.

Parameters:
[in]aSearchedScopesMask of scopes that shall be included in the search.
Returns:
A list of the found key names.
void BpsSettings::closeAll ( )

Close all currently opened paths.

The current location is set back to the root.

QVariant BpsSettings::findValue ( const QString &  aKey,
const QVariant &  aDefValue = QVariant(),
Scopes  aSearchedScopes = (Scopes) AllScopes 
) const

Find a value within the currently opened path.

If the value is not found in the current scope, the scope chain is searched up to CentralSystemScope for such a value. When still not found, the default will be returned. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope.

Parameters:
[in]aKeyThe key of the value.
[in]aDefValueDefault value to return in case the key does not exist.
[in]aSearchedScopesMask of scopes that shall be included in the search.
Returns:
The keys value, or the provided default value in case the key does not exist.
bool BpsSettings::groupExists ( const QString &  aGroup) const

Check if the group exists in the current scope.

The group name compare is done case-insensitive, so the method is equivalent to groups().contains(aGroup, Qt::CaseInsensitive).

Parameters:
[in]aGroupThe group to check.
Returns:
True if the group exists, false if not.
QStringList BpsSettings::groups ( ) const

Query a list of all existing groups within the currently opened path.

Returns:
All child groups at the currently opened path.
Scope BpsSettings::groupScope ( const QString &  aName,
Scopes  aSearchedScopes = (Scopes) AllScopes 
) const

Find the first scope of a group within the currently opened path.

Search begins at the current scope and goes up to CentralSystemScope. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope.

Parameters:
[in]aSearchedScopesMask of scopes that shall be included in the search.
[in]aNameThe name of the group. Name compare is case-insensitive.
Returns:
Scope of the first group found, or NoScope if no such group found.
bool BpsSettings::keyExists ( const QString &  aKey) const

Check if the key exists in the current scope.

The key name compare is done case-insensitive, so the method is equivalent to keys().contains(aKey, Qt::CaseInsensitive).

Parameters:
[in]aKeyThe key to check.
Returns:
True if the key exists, false if not.
QStringList BpsSettings::keys ( ) const

Query a list of all existing keys in the currently opened group.

Returns:
All keys within the currently opened path.
void BpsSettings::open ( const QString &  aPath)

Open a new path.

Parameters:
[in]aPathThe path to open, relative to the currently opened path.
void BpsSettings::removeGroup ( const QString &  aName)

Remove a group from the currently opened path.

In case no group of the given name exists, nothing happens.

Parameters:
[in]aNameThe name of the group. Name compare is case-insensitive.
void BpsSettings::removeKey ( const QString &  aKey)

Remove a key.

Parameters:
[in]aKeyName of the key to remove. Key names are case insensitive.
QString BpsSettings::root ( ) const

Get the current root.

The root is prepended to all paths. Initially the root is empty.

Returns:
The current root.
Scope BpsSettings::scope ( ) const
Returns:
The current scope.
void BpsSettings::setRoot ( const QString &  aRoot)

Set a new root.

The root is prepended to all paths. Initially the root is empty.

Parameters:
[in]aRootThe new root to set.
void BpsSettings::setScope ( Scope  aScope)

Change the current scope.

Parameters:
[in]aScopeThe new scope to be set.
void BpsSettings::setValue ( const QString &  aKey,
const QVariant &  aValue 
)

Set a value within the currently opened path.

Parameters:
[in]aKeyThe key for the value.
[in]aValueThe value to save under this key.
void BpsSettings::setValueMap ( const QVariantMap &  aMap)

Removes any previously existing keys from the currently opened path and scope, and adds the values in the given map instead.

Parameters:
[in]aMapThe map of key/value pairs to set.
QVariant BpsSettings::value ( const QString &  aKey,
const QVariant &  aDefValue = QVariant() 
) const

Get a value within the currently opened path.

Parameters:
[in]aKeyThe key of the value.
[in]aDefValueDefault value to return in case the key does not exist.
Returns:
The keys value, or the provided default value in case the key does not exist.
QVariantMap BpsSettings::valueMap ( Scopes  aSearchedScopes = (Scopes) AllScopes) const

Find all keys and values within the currently opened path.

The scope chain is searched up to CentralSystemScope for values. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope. This map contains basically all tha key/value pairs addressed by allKeys().

Parameters:
[in]aSearchedScopesMask of scopes that shall be included in the search.
Returns:
A map of all key/value pairs in the currently opened path.

The documentation for this class was generated from the following file: