Qt Editor: Add EmptyName option for def property to rename the "nil" entry

qteditor
Sven Eberhardt 2016-07-22 00:28:01 -04:00
parent f4ea3359d0
commit 14d01cd5cd
3 changed files with 5 additions and 3 deletions

View File

@ -1099,6 +1099,9 @@ bool C4PropertyDelegateEnum::Paint(QPainter *painter, const QStyleOptionViewItem
C4PropertyDelegateDef::C4PropertyDelegateDef(const C4PropertyDelegateFactory *factory, C4PropList *props)
: C4PropertyDelegateEnum(factory, props)
{
// nil is always an option
C4String *empty_name = props ? props->GetPropertyStr(P_EmptyName) : nullptr;
AddConstOption(empty_name ? empty_name : ::Strings.RegString("nil"), C4VNull);
// Collect sorted definitions
C4String *filter_property = props ? props->GetPropertyStr(P_Filter) : nullptr;
if (filter_property)
@ -1109,8 +1112,6 @@ C4PropertyDelegateDef::C4PropertyDelegateDef(const C4PropertyDelegateFactory *fa
return strcmp(a->GetName(), b->GetName()) < 0;
});
// Add them
ReserveOptions(defs.size() + 1);
AddConstOption(::Strings.RegString("nil"), C4VNull); // nil is always an option
for (C4Def *def : defs)
{
C4RefCntPointer<C4String> option_name = ::Strings.RegString(FormatString("%s (%s)", def->id.ToString(), def->GetName()));
@ -1119,7 +1120,6 @@ C4PropertyDelegateDef::C4PropertyDelegateDef(const C4PropertyDelegateFactory *fa
}
else
{
AddConstOption(::Strings.RegString("nil"), C4VNull); // nil is always an option
// Without filter copy tree from definition list model
C4ConsoleQtDefinitionListModel *def_list_model = factory->GetDefinitionListModel();
// Recursively add all defs from model

View File

@ -284,6 +284,7 @@ C4StringTable::C4StringTable()
P[P_Command] = "Command";
P[P_Select] = "Select";
P[P_DescendPath] = "DescendPath";
P[P_EmptyName] = "EmptyName";
P[DFA_WALK] = "WALK";
P[DFA_FLIGHT] = "FLIGHT";
P[DFA_KNEEL] = "KNEEL";

View File

@ -508,6 +508,7 @@ enum C4PropertyName
P_Command,
P_Select,
P_DescendPath,
P_EmptyName,
// Default Action Procedures
DFA_WALK,
DFA_FLIGHT,