PyANGKernel.GKPreferences

class GKPreferences

Preferences for the model or the application.

Details

This class holds preferences for the model or the application (there are two instances of this class, one in GKModel accessible via the method getPreferences and another in GKSystem accessible via 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 getEditorPlace : - List: groups will appear in a list view. If the group has a parent it will appear as a sub item of it. - Box: the group will appear in a group box ( QGroupBox ). - Tab: the group will appear in a tab folder. Note that all the groups that are at the same level must be in a tab too.

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 setGroupWidgetFactory method.

<h2>Preferences Definition</h2>

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

<h2>Attribute Values Definition</h2>

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 getPreferences (for model preferences) and 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.

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

__init__()
addGroup(group[, parent=None])
Parameters:

It adds a new group to the preferences. If parent is NULL the group will be added directly to this object. If it is not NULL the group will be added as a subgroup of “parent”.

If the group was already in the list (searching by name) it will not be added.

The pointer to the group is adopted.

addNewGroup(parent)
Parameters:

parentGKPreferencesGroup

Return type:

GKPreferencesGroup

Creates and adds a new group to the preferences. The new group is returned. If parent is NULL the group will be added directly to this object. If it is not NULL the group will be added as a subgroup of “parent”.

clear()

It deletes all the groups and attributes.

existAttribute(name)
Parameters:

name – str

Return type:

bool

It returns true if the attribute named “name” exists. It searches recursively among all the groups and subgroups in the preferences.

existGroup(name)
Parameters:

name – str

Return type:

bool

It returns true if the group named “name” exists. It searches recursively among all the groups and subgroups in the preferences.

getAttribute(name)
Parameters:

name – str

Return type:

GKPreferencesAttribute

It returns the attribute identified by the unique name “name”. If no attribute is found NULL is returned.

It searches recursively among all the groups and subgroups in the preferences.

getGroup(name)
Parameters:

name – str

Return type:

GKPreferencesGroup

It returns the group identified by the unique name “name”. If no group is found NULL is returned.

It searches recursively among all the groups and subgroups in the preferences.

getGroups()
Return type:

.list of GKPreferencesGroup

It gets all the groups in the preferences.

removeGroup(group)
Parameters:

groupGKPreferencesGroup

Return type:

bool

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

sort()

Sort the groups in the preferences (if any) by priority (from low to high priority). A lower number means that will be presented first.

Sub groups will be sorted too.

See also

sort

takeGroup(group)
Parameters:

groupGKPreferencesGroup

Return type:

bool

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.