very crude support for a string default in choices
still a long way to real enums
This commit is contained in:
parent
e95c4b8550
commit
f4d222c9c4
@ -26,15 +26,15 @@
|
||||
<default>test2</default>
|
||||
</entry>
|
||||
<entry name="EnumTest" type="Enum">
|
||||
<default>0</default>
|
||||
<default>Value2</default>
|
||||
<choices>
|
||||
<choice name="PlasmaCore.Types.Floating"/>
|
||||
<choice name="PlasmaCore.Types.Desktop"/>
|
||||
<choice name="PlasmaCore.Types.FullScreen"/>
|
||||
<choice name="PlasmaCore.Types.LeftEdge"/>
|
||||
<choice name="PlasmaCore.Types.RightEdge"/>
|
||||
<choice name="PlasmaCore.Types.TopEdge"/>
|
||||
<choice name="PlasmaCore.Types.BottomEdge"/>
|
||||
<choice name="Value0"/>
|
||||
<choice name="Value1"/>
|
||||
<choice name="Value2"/>
|
||||
<choice name="Value3"/>
|
||||
<choice name="Value4"/>
|
||||
<choice name="Value5"/>
|
||||
<choice name="Value6"/>
|
||||
</choices>
|
||||
</entry>
|
||||
</group>
|
||||
|
@ -223,11 +223,24 @@ void ConfigLoaderHandler::addItem()
|
||||
QDateTime::fromString(m_default), m_key);
|
||||
} else if (m_type == "enum") {
|
||||
m_key = (m_key.isEmpty()) ? m_name : m_key;
|
||||
bool ok;
|
||||
int value = m_default.toUInt(&ok);
|
||||
//if is not an integer, try to find the string value among the registered choices
|
||||
if (!ok) {
|
||||
int i = 0;
|
||||
foreach (const KConfigSkeleton::ItemEnum::Choice &choice, m_enumChoices) {
|
||||
if (choice.name == m_default) {
|
||||
value = i;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
KConfigSkeleton::ItemEnum *enumItem =
|
||||
new KConfigSkeleton::ItemEnum(m_config->currentGroup(),
|
||||
m_key, *d->newInt(),
|
||||
m_enumChoices,
|
||||
m_default.toUInt());
|
||||
value);
|
||||
m_config->addItem(enumItem, m_name);
|
||||
item = enumItem;
|
||||
} else if (m_type == "font") {
|
||||
|
Loading…
Reference in New Issue
Block a user