QtCraft API C++ classes QML types Handbook

QcNamedList Class

template <typename Definition> class QcNamedList

Definitions of one kind in registration order, found by their name: registering a name again replaces the earlier definition in its place, so a later pack overrides an earlier one. Definition is the type of the definitions. More...

Header: #include <common/content/registry/QcNamedList.h>

Public Functions

const Definition *find(const QString &name) const
std::optional<qsizetype> indexOf(const QString &name) const
const QList<Definition> &items() const
void remove(const QString &name)
void set(Definition definition)
void truncate(qsizetype count)
void update(qsizetype index, Change &&change)
void updateAll(const Change &change)

Detailed Description

Member Function Documentation

const Definition *QcNamedList::find(const QString &name) const

Returns the definition name, or null if there is none.

std::optional<qsizetype> QcNamedList::indexOf(const QString &name) const

Returns the position of the definition name in items(); none if there is none.

const QList<Definition> &QcNamedList::items() const

Returns the definitions in registration order.

void QcNamedList::remove(const QString &name)

Removes the definition name; the later ones move up.

void QcNamedList::set(Definition definition)

Replaces the definition with the same name as definition, or appends it.

void QcNamedList::truncate(qsizetype count)

Keeps the first count definitions and forgets the later ones.

template <typename Change> void QcNamedList::update(qsizetype index, Change &&change)

Changes the definition at index by calling change with it (change(Definition &)). The name finds the definition, so it stays: a change of it is undone with a warning.

template <typename Change> void QcNamedList::updateAll(const Change &change)

Calls update() with change for every definition in order.