CodexTreeModel.h header
#include <ew/app/CodexTreeModel.h>
Namespace ew::app
CodexTreeModel class
class ew::app::CodexTreeModel
A tree model of the whole codex: each category is a node, with its sub-categories and then its entities nested beneath it, so categories and their members read as one navigable tree instead of a separate list. Uncategorized entities appear at the top level. Read-only over the project; call refresh() after the taxonomy or entities change.
Members
ew::app::entity::CodexTreeModel::CodexTreeModel(QObject *parent=nullptr)
Constructs an empty codex tree model with parent parent.
ew::app::entity::CodexTreeModel::~CodexTreeModel() override
Destroys the model.
ew::app::entity::CodexTreeModel::CodexTreeModel(const CodexTreeModel &)=delete
Not copyable.
ew::app::entity::CodexTreeModel::CodexTreeModel(CodexTreeModel &&)=delete
Not movable.
CodexTreeModel & ew::app::entity::CodexTreeModel::operator=(const CodexTreeModel &)=delete
Not copyable.
CodexTreeModel & ew::app::entity::CodexTreeModel::operator=(CodexTreeModel &&)=delete
Not movable.
void ew::app::entity::CodexTreeModel::setProject(const ew::core::project::Project *project)
Points the model at project (not owned; may be null) and rebuilds it.
void ew::app::entity::CodexTreeModel::refresh()
Re-reads the taxonomy and entities and rebuilds the tree.
void ew::app::entity::CodexTreeModel::setActiveAudience(QString audience)
Sets the audience to view the codex as, and rebuilds. When non-empty, entities not visible to audience (see ContentObject::isVisibleTo) are hidden – a "view as this reader" lens. An empty audience is the author's view: everything shows.
QModelIndex ew::app::entity::CodexTreeModel::indexForCategory(ew::core::foundation::CategoryId id) const
The index of the category id anywhere in the tree, or an invalid index.
QModelIndex ew::app::entity::CodexTreeModel::indexForEntity(ew::core::foundation::ContentId id) const
The index of the entity id anywhere in the tree, or an invalid index.
QModelIndex ew::app::entity::CodexTreeModel::index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the child at row, column under parent (QAbstractItemModel).
QModelIndex ew::app::entity::CodexTreeModel::parent(const QModelIndex &child) const override
Returns the parent index of child (QAbstractItemModel).
int ew::app::entity::CodexTreeModel::rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of child rows under parent (QAbstractItemModel).
int ew::app::entity::CodexTreeModel::columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the column count under parent (QAbstractItemModel).
QVariant ew::app::entity::CodexTreeModel::data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the codex tree's data for index and role (QAbstractItemModel).
Qt::ItemFlags ew::app::entity::CodexTreeModel::flags(const QModelIndex &index) const override
Returns what can be done with the item at index, adding drag and drop (QAbstractItemModel).
QStringList ew::app::entity::CodexTreeModel::mimeTypes() const override
Returns the one mime type the codex tree drags (QAbstractItemModel).
QMimeData * ew::app::entity::CodexTreeModel::mimeData(const QModelIndexList &indexes) const override
Packs the dragged node's kind and id (QAbstractItemModel).
bool ew::app::entity::CodexTreeModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
Whether dropping data onto parent would be a legal move (QAbstractItemModel).
bool ew::app::entity::CodexTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Asks for the drop to be performed; see moveRequested (QAbstractItemModel).
Qt::DropActions ew::app::entity::CodexTreeModel::supportedDropActions() const override
Returns the drop actions the codex tree supports (QAbstractItemModel).
static ew::core::foundation::CategoryId ew::app::entity::CodexTreeModel::categoryIdAt(const QModelIndex &index)
The category id at index if it is a category node, else a null id.
static ew::core::foundation::ContentId ew::app::entity::CodexTreeModel::entityIdAt(const QModelIndex &index)
The entity id at index if it is an entity node, else a null id.
void ew::app::entity::CodexTreeModel::moveRequested(ew::core::foundation::ContentId entity, ew::core::foundation::CategoryId category, ew::core::foundation::CategoryId parentCategory, ew::core::foundation::ContentId parentEntity)
A node was dropped: move entity (when set) or category into parentCategory, or into parentEntity when that is set instead. Both parents null means the top level.
The model REPORTS the drop rather than performing it. It is a read-only view over the project by design – every change to the codex goes through the command stack so it can be undone – and a model that quietly edited the taxonomy would be the one path that could not.
void ew::app::entity::CodexTreeModel::orderRequested(const std::vector< CodexOrderEntry > &order)
A node was dropped BETWEEN two of its siblings: give the container this order, 1..N.
The whole container is reported, not just the node that moved, because a half-numbered list orders the placed nodes and leaves the rest to the default rule – which is not the arrangement the writer just made on screen. Empty when nothing moved.