Category.h header
#include <ew/core/Category.h>
Namespace ew::core
Category class
class ew::core::Category
One node in the user-defined codex taxonomy: a named category with a stable id, an optional parent, and the fields defined directly on it. Fields inherit to descendant categories – that composition lives in Taxonomy, which owns the tree; a Category only knows its own fields and its parent. Categories are value types.
Members
ew::core::Category::Category(CategoryId id, QString name)
Creates a root category with stable id and display name.
CategoryId ew::core::Category::id() const
The stable identity of this category. Immutable.
const QString & ew::core::Category::name() const
The display name.
void ew::core::Category::setName(QString name)
Sets the display name.
CategoryId ew::core::Category::parentId() const
The parent category's id, or a null id if this is a root category.
void ew::core::Category::setParentId(CategoryId parentId)
Sets the parent category's id; a null id makes this a root category.
bool ew::core::Category::isRoot() const
Returns true if this category has no parent (a root of the taxonomy).
const std::vector< FieldDefinition > & ew::core::Category::fields() const
The fields defined directly on this category, not counting inherited ones.
void ew::core::Category::addField(FieldDefinition field)
Adds field, replacing any existing field that has the same key.
void ew::core::Category::insertField(std::size_t index, FieldDefinition field)
Inserts field at position index (clamped to the current field count), without replacing a same-key field. Callers ensure field's key is not already present; used to restore a removed field at its original position.
bool ew::core::Category::moveField(QStringView key, std::size_t newIndex)
Moves the field with key to position newIndex (clamped to the valid range), shifting the intervening fields. Returns true if the field existed and was moved.
bool ew::core::Category::removeField(QStringView key)
Removes the field with key. Returns true if a field was removed.
const FieldDefinition * ew::core::Category::field(QStringView key) const
Returns the field defined on this category with key, or nullptr if none.