FieldDefinition.h header
#include <ew/core/FieldDefinition.h>
Namespace ew::core
FieldDefinition class
class ew::core::FieldDefinition
The definition of one user-defined codex field on a taxonomy category: its stable key, display label, data type, and constraints. The key is fixed at construction and used for serialization and value lookup; everything else is editable. A Category forms its schema from a list of these, and they inherit to descendant categories.
A field is either SELECTABLE – the ordinary kind, a slot each entity fills in for itself – or FIXED, where the category supplies one value that every entity beneath reads and none can change. See isFixed.
Members
ew::core::taxonomy::FieldDefinition::FieldDefinition(QString key, QString label, FieldType type)
Creates a field with stable key, display label, and data type.
const QString & ew::core::taxonomy::FieldDefinition::key() const
The stable identifier used to store and look up this field's values. Immutable.
const QString & ew::core::taxonomy::FieldDefinition::label() const
The human-readable label shown in the UI.
void ew::core::taxonomy::FieldDefinition::setLabel(QString label)
Sets the field's display label.
FieldType ew::core::taxonomy::FieldDefinition::type() const
The field's data type.
void ew::core::taxonomy::FieldDefinition::setType(FieldType type)
Sets the field's data type.
bool ew::core::taxonomy::FieldDefinition::isRequired() const
Whether an entity must supply a value for this field.
void ew::core::taxonomy::FieldDefinition::setRequired(bool isRequired)
Sets whether a value is mandatory. Turning this on clears isFixed – see setFixed.
bool ew::core::taxonomy::FieldDefinition::isFixed() const
Whether the category supplies this field's value itself, and entities below it cannot.
A fixed field is DATA rather than a slot: its value is held once, here on the category, and every entity beneath shows that same value read-only. It is what lets a "Cities" category nested under the kingdom Vaertis state kingdom = Vaertis once, instead of every city storing its own copy of a fact none of them can vary.
void ew::core::taxonomy::FieldDefinition::setFixed(bool isFixed)
Sets whether the category supplies the value. Turning this on clears isRequired.
The two are mutually exclusive, and the exclusion is enforced HERE rather than left to each caller: "the entity must supply a value" and "the entity cannot supply a value" is a contradiction, and a field holding both would make a form that can never be completed.
const QString & ew::core::taxonomy::FieldDefinition::fixedValue() const
The value every entity below this category reads for a fixed field; empty otherwise.
void ew::core::taxonomy::FieldDefinition::setFixedValue(QString fixedValue)
Sets the value a fixed field supplies. Meaningful only while isFixed.
const QStringList & ew::core::taxonomy::FieldDefinition::options() const
The allowed values, used when type() is FieldType::Choice; empty otherwise.
void ew::core::taxonomy::FieldDefinition::setOptions(QStringList options)
Sets the allowed values (for FieldType::Choice).
ew::core::foundation::CategoryId ew::core::taxonomy::FieldDefinition::referenceCategoryId() const
The only category a FieldType::Reference value may point into, with its descendants; null for any object in the project.
An "Affiliation" that offers every document, map and timeline event in the project is not a choice, it is a haystack – the field says what KIND of thing it points at, and the picker should say the same. Null stays the default so a field written before this, or one that genuinely points anywhere, is unaffected.
A restriction constrains what can be PICKED, not what is stored: a value already pointing outside the target category keeps working and keeps showing its name, because a schema change is not a licence to silently drop the writer's data.
void ew::core::taxonomy::FieldDefinition::setReferenceCategoryId(ew::core::foundation::CategoryId referenceCategoryId)
Sets the category a reference value may point into. Meaningful only for FieldType::Reference; a null id lifts the restriction.
const QString & ew::core::taxonomy::FieldDefinition::description() const
Optional help text explaining the field's purpose.
void ew::core::taxonomy::FieldDefinition::setDescription(QString description)
Sets the field's help text.