DocumentTreeModel.h header
#include <ew/app/DocumentTreeModel.h>
Namespace ew::app
DocumentTreeModel class
class ew::app::DocumentTreeModel
A read-only tree model exposing a project's documents as a manuscript tree to a QTreeView. Each row is a document; its children are the documents whose parent is it (in the project's stable id order). Top-level documents (a null parent) are the roots. The model does not own the project – call refresh() after documents change.
Members
enum Column { TitleColumn, StatusColumn, WordsColumn, SynopsisColumn, ColumnCount }
The model's columns. Column 0 is the manuscript tree itself (titles); the others are metadata shown by the outline view. The document navigator hides all but the title column.
ew::app::DocumentTreeModel::DocumentTreeModel(QObject *parent=nullptr)
Constructs an empty document tree model with parent parent.
void ew::app::DocumentTreeModel::setProject(const ew::core::Project *project)
Points the model at project (not owned; may be null) and resets it.
void ew::app::DocumentTreeModel::refresh()
Re-reads the project and resets the model (call after documents change).
void ew::app::DocumentTreeModel::setActiveAudience(QString audience)
Sets the audience to view the manuscript as, and resets. When non-empty, documents not visible to audience (and their subtrees) are hidden – a "view as this reader" lens. An empty audience is the author's view: everything shows.
QModelIndex ew::app::DocumentTreeModel::indexFor(ew::core::ContentId id) const
The index of the document id anywhere in the tree, or an invalid index if it is not present (used to select or reveal a document).
QModelIndex ew::app::DocumentTreeModel::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::DocumentTreeModel::parent(const QModelIndex &child) const override
Returns the parent index of child (QAbstractItemModel).
int ew::app::DocumentTreeModel::rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of child rows under parent (QAbstractItemModel).
int ew::app::DocumentTreeModel::columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the column count under parent (QAbstractItemModel).
QVariant ew::app::DocumentTreeModel::data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the manuscript tree's data for index and role (QAbstractItemModel).
QVariant ew::app::DocumentTreeModel::headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the header label for section and role (QAbstractItemModel).
Qt::ItemFlags ew::app::DocumentTreeModel::flags(const QModelIndex &index) const override
Returns the drag-and-drop-enabled item flags for index (QAbstractItemModel).
Qt::DropActions ew::app::DocumentTreeModel::supportedDropActions() const override
Returns the drop actions supported (move) (QAbstractItemModel).
QStringList ew::app::DocumentTreeModel::mimeTypes() const override
Returns the MIME types used when dragging documents (QAbstractItemModel).
QMimeData * ew::app::DocumentTreeModel::mimeData(const QModelIndexList &indexes) const override
Returns the drag payload for the documents at indexes (QAbstractItemModel).
bool ew::app::DocumentTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Applies a drop of data at row, column under parent by emitting moveRequested() (QAbstractItemModel).
static ew::core::ContentId ew::app::DocumentTreeModel::documentIdAt(const QModelIndex &index)
The id of the document at index, or a null id if the index is invalid.
void ew::app::DocumentTreeModel::moveRequested(ew::core::ContentId documentId, ew::core::ContentId newParentId, int row)
Emitted when a drag-and-drop gesture asks to move documentId so it becomes a child of newParentId (a null id means the top level) at visual position row (or -1 to append). The owner performs the undoable move and refreshes the model.