Aimsun Next Scripting
22
|
Public Member Functions | |
GKPreferences () | |
~GKPreferences () | |
GKPreferencesGroup * | addNewGroup (GKPreferencesGroup *parent) |
bool | removeGroup (GKPreferencesGroup *group) |
bool | takeGroup (GKPreferencesGroup *group) |
GKPreferencesGroup * | getGroup (const QString &name) const |
GKPreferencesAttribute * | getAttribute (const QString &name) const |
bool | existGroup (const QString &name) const |
bool | existAttribute (const QString &name) const |
This class holds preferences for the model or the application (there are two instances of this class, one in GKModel accessible via the method GKModel::getPreferences and another in GKSystem accessible via GKSystem::getPreferences).
The preference is a collection of attributes and its values (GKPreferencesAttribute) inside a group (GKPreferencesGroup). A preference class can hold several groups and a group can hold either more groups (recursively) and attributes.
Both groups and attributes have a name that must be unique (is up to the developer to ensure that it is) and a external name that will be shown to the user during preferences edition (in the GKPreferencesEditor).
Use the group to keep together related attributes. The GKPreferencesEditor will use these groups to know how to present the information to the user based on the value returned by the method GKPreferencesGroup::getEditorPlace :
The developer can also set its own widget to edit a GKPreferencesGroup (that means all the GKPreferencesAttribute in the group) by-passing the GKPreferencesEditor automatic GUI generation. In order to do so create a GKPreferencesGroupWidget and a GKPreferencesGroupWidgetFactory and register it with the GKPreferences::setGroupWidgetFactory method.
The system has the definition of the preferences that will be used in the application for both the system (common to all the opened models) and the models. It has also the preferences values for the system.
Use the method GKSystem::getPreferencesDefinition to get and edit the preferences definition. You can add then new attributes and their default values. The best place to create this new attributes (and groups) is in the GKPlugin::install method.
This class stores the definition of attributes (which attributes are available and what are their settings) but not their values. Attributes values are stored in instances of GKPreferencesValues. They are accessible using the GKModel::getPreferences (for model preferences) and GKSystem::getPreferences (for system preferences).
An attribute is defined in the system and it is valid for the application and all the models. When the user request the value for an attribute it will ask for it to the model. If the model does not have any value defined (any edition has been done yet) it will return the value stored in the system. If the system doesn't have a value (any edition has been done yet) it will return the default value stored in the attribute.
GKPreferences::GKPreferences | ( | ) |
GKPreferences::~GKPreferences | ( | ) |
GKPreferencesGroup * GKPreferences::addNewGroup | ( | GKPreferencesGroup * | parent | ) |
Creates and adds a new group to the preferences. The new group is returned. If parent is None the group will be added directly to this object. If it is not None the group will be added as a subgroup of "parent".
bool GKPreferences::existAttribute | ( | const QString & | name | ) | const |
It returns true if the attribute named "name" exists. It searches recursively among all the groups and subgroups in the preferences.
bool GKPreferences::existGroup | ( | const QString & | name | ) | const |
It returns true if the group named "name" exists. It searches recursively among all the groups and subgroups in the preferences.
GKPreferencesAttribute * GKPreferences::getAttribute | ( | const QString & | name | ) | const |
It returns the attribute identified by the unique name "name". If no attribute is found None is returned.
It searches recursively among all the groups and subgroups in the preferences.
GKPreferencesGroup * GKPreferences::getGroup | ( | const QString & | name | ) | const |
It returns the group identified by the unique name "name". If no group is found None is returned.
It searches recursively among all the groups and subgroups in the preferences.
bool GKPreferences::removeGroup | ( | GKPreferencesGroup * | group | ) |
It removes a group from the preferences. Any attribute and group inside it will be removed too. The group object is deleted (no use of it can be done after this call).
bool GKPreferences::takeGroup | ( | GKPreferencesGroup * | group | ) |
It removes a group (and any group and attribute inside) from the preferences but no data is deleted. Use this method to move a group from its location inside a group to a new one.