App/Gui: improve expression binding of PropertyEnumeration
The enumeration items are exposed through sub path '.Enum'. When 'ShowAll' is enabled in property view, this sub path is exposed as a sub property item named 'Enum', and can be either manually edited or bound with an expression.
This commit is contained in:
@@ -82,11 +82,9 @@ Enumeration::~Enumeration()
|
||||
void Enumeration::tearDown(void)
|
||||
{
|
||||
// Ugly...
|
||||
char **plEnums = (char **)_EnumArray;
|
||||
|
||||
// Delete C Strings first
|
||||
while (*plEnums != NULL) {
|
||||
free(*(plEnums++));
|
||||
for(char **plEnums = (char **)_EnumArray; *plEnums != NULL; ++plEnums) {
|
||||
// Delete C Strings first
|
||||
free(*plEnums);
|
||||
}
|
||||
|
||||
delete [] _EnumArray;
|
||||
@@ -98,6 +96,9 @@ void Enumeration::tearDown(void)
|
||||
|
||||
void Enumeration::setEnums(const char **plEnums)
|
||||
{
|
||||
if(plEnums == _EnumArray)
|
||||
return;
|
||||
|
||||
std::string oldValue;
|
||||
bool preserve = (isValid() && plEnums != NULL);
|
||||
if (preserve) {
|
||||
@@ -118,7 +119,11 @@ void Enumeration::setEnums(const char **plEnums)
|
||||
findMaxVal();
|
||||
|
||||
// set _index
|
||||
_index = 0;
|
||||
if (_index < 0)
|
||||
_index = 0;
|
||||
else if (_index > _maxVal)
|
||||
_index = _maxVal;
|
||||
|
||||
if (preserve) {
|
||||
setValue(oldValue);
|
||||
}
|
||||
@@ -311,6 +316,10 @@ Enumeration & Enumeration::operator=(const Enumeration &other)
|
||||
|
||||
bool Enumeration::operator==(const Enumeration &other) const
|
||||
{
|
||||
if(_index != other._index)
|
||||
return false;
|
||||
if (getCStr() == other.getCStr())
|
||||
return true;
|
||||
if (getCStr() == NULL || other.getCStr() == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user