PyANGKernel.GKPreferencesAttribute¶
- class GKPreferencesAttribute¶
A value for an attribute in the preferences.
Details
This class contains information of an attribute used in the preferences like type of the data that contains (integer, boolean, string, double, enum) and information about any possible data conversion (Aimsun stores all the data in the metric system thus is possible that a conversion is needed to show the data in the current unit system set by the user. In order to make an automatic translation between unit systems an attribute need to know which kind of data holds: speed, acceleration, distance or weight).
An attribute has a name that must be unique (is up to the developer to ensure this) and an external name. The name identifies the attribute among all the other attributes in the system. The external name is used to present the attribute to the user in the GKPreferencesEditor.
Attributes of type Object (GKPreferencesAttribute::eObject) are only editable at model level and requires the spefification of the type of these objects (
setObjectType).An attribute can be editable (the default) and will appear in the preferences dialog or not (it will no appear in the preefernces dialog). A non editable attribute can be seem as an internal preference.
In the following example an attribute is created that holds a speed as a double:
attr = new GKPreferencesAttribute(); attr->setName( "GKSection::DefaultSpeed" ); attr->setExternalName( QObject::tr("Default Speed") ); attr->setType( GKPreferencesAttribute::eDouble ); attr->setConversion( GK::eSpeed ); attr->setDefault( "50" ); group->addAttribute( attr );
And another example, this type a enum:
attr = new GKPreferencesAttribute(); attr->setName( "GKModel::Language" ); attr->setExternalName( QObject::tr("Language") ); attr->setType( GKPreferencesAttribute::eEnum ); attr->setEnumString( 0, QObject::tr("Spanish") ); attr->setEnumString( 1, QObject::tr("English") ); attr->setEnumString( 2, QObject::tr("German") ); attr->setEnumString( 3, QObject::tr("French") ); attr->setDefault( "1" ); group->addAttribute( attr );
See also
GKPreferencesGKPreferencesValuesGKPreferencesGroupGKPreferencesEditorSynopsis¶
Methods¶
def
__init__()def
getConversion()def
getDefault()def
getEnumString()def
getEnumStrings()def
getFileFilter()def
getLimits()def
getName()def
getObjectType()def
getTooltip()def
getType()def
isEditable()def
isPathType()def
setConversion()def
setDefault()def
setEditable()def
setEnumString()def
setFileFilter()def
setLimits()def
setName()def
setObjectType()def
setToolTip()def
setType()
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
- class GKPreferencesAttributeType¶
- __init__()¶
- addDisableCondition(attr, value)¶
- Parameters:
attr –
GKPreferencesAttributevalue – str
- emptyEnumStrings()¶
Empties the enum strings vector
- getConversion()¶
- Return type:
Get the possible conversion needed by this type.
Returns the default value of this attribute.
- getDisableConditions()¶
- Return type:
.list of std.pairGKPreferencesAttribute,QString
Get the string associated with an integer value when the data type is enum.
- getEnumStrings()¶
- Return type:
.list of QString
Get the all the strings associated with an integer values when the data type is enum.
Get the external name of this object.
If the attribute is a file returns the file filter for the browser file dialog. No other check is done using this filter.
- getLimits()¶
- Return type:
.std.pairdouble,double
Gets, for numerical values, the minimum and the maximum (included) allowed values. If no limit exists then both values will be 0.0
Get the name of this object.
When the attribute is an object, the object type
Gets the tooltip for the object.
- getType()¶
- Return type:
Get the data type that this attribute holds.
Returns true if the attribute can be edited in the preferences dialog, if not it will not appear on it.
Returns true if the type is a path (eFileIn, eFileOut or eFolder).
- setConversion(type)¶
- Parameters:
type –
Conversion
Set the possible conversion needed by this type specifiying which kind of data holds.
- setDefault(avalue)¶
- Parameters:
avalue – str
Set the default value for this attribute. Call this method after calling
setTypesincesetTypemethod sets default values.- setEditable(value)¶
- Parameters:
value – bool
Set this object as editable or not. See
isEditableSee also
- setEnumString(value, string)¶
- Parameters:
value – int
string – str
Set a string associated with an integer value when the data type is enum.
- setExternalName(aname)¶
- Parameters:
aname – str
Set the external name of this object. This name will be used to label this attribute when it is presented to the user.
- setFileFilter(afilter)¶
- Parameters:
afilter – str
If the attribute is a file sets the file filter for the browser file dialog. No other check is done using this filter.
- setLimits(minValue, maxValue)¶
- Parameters:
minValue – float
maxValue – float
For numerical values the minimum and the maximum (included) allowed values. If no limit exists then set both values to 0.0
- setName(aname)¶
- Parameters:
aname – str
Set the name for this object. Must be unique. Is it resposibility of the developer to ensure that it is unique.
- setObjectType(objectType)¶
- Parameters:
objectType – str
When the attribute is an object, the object type
- setToolTip(atooltip)¶
- Parameters:
atooltip – str
Sets the tooltip for the object.
- setType(type)¶
- Parameters:
type –
GKPreferencesAttributeType
Set the data type that this attribute holds. It also sets a default value based on the type: - numeric: 0 - string: empty string