Document.h header
#include <ew/core/Document.h>
Namespace ew::core
Document class
class ew::core::Document
A written document in the project – prose, a screenplay, or a note (its kind). It carries a title and a body stored as Markdown (with defined extensions), which is diff-friendly in version control (DESIGN.md section 6.3). The kind is an axis layered on the one Document type and selects editing/formatting behaviour.
Members
ew::core::Document::Document(ContentId id, DocumentKind kind, QString title)
Creates a document of kind with identity id and title (empty body).
DocumentKind ew::core::Document::kind() const
The document kind (prose/screenplay/note).
void ew::core::Document::setKind(DocumentKind kind)
Sets the document kind (prose/screenplay/note).
const QString & ew::core::Document::title() const
The document title (shown in the manuscript tree and headers).
void ew::core::Document::setTitle(QString title)
Sets the document title.
const QString & ew::core::Document::body() const
The document body, stored as Markdown.
void ew::core::Document::setBody(QString body)
Sets the document body (stored as Markdown).
BodyFormat ew::core::Document::bodyFormat() const
The storage format of the body (Markdown by default; Html for a legacy body not yet losslessly migrated). Persisted so the loader knows whether a body still needs a migration attempt. New documents are Markdown.
void ew::core::Document::setBodyFormat(BodyFormat format)
Sets the storage format of the body.
const QString & ew::core::Document::synopsis() const
A short synopsis of the document, shown on corkboard index cards and in the outline. Empty by default.
void ew::core::Document::setSynopsis(QString synopsis)
Sets the document's synopsis.
const QString & ew::core::Document::status() const
A user-defined workflow status (e.g. "Draft", "Revised", "Final"), shown in the outline and on the corkboard. Empty by default.
void ew::core::Document::setStatus(QString status)
Sets the document's workflow status.
const QString & ew::core::Document::pointOfView() const
The point-of-view character this document is told from (a free-form name, usually a codex character). Empty means unassigned. Drives the point-of-view balance analytics.
void ew::core::Document::setPointOfView(QString pointOfView)
Sets the point-of-view character this document is told from.
int ew::core::Document::tensionLevel() const
The dramatic tension of this scene on a 0-10 scale, where 0 means unrated. Drives the tension-curve analytics. Values are clamped into the 0-10 range.
void ew::core::Document::setTensionLevel(int tensionLevel)
Sets the scene's dramatic tension level (clamped to 0-10; 0 means unrated).
std::optional< qint64 > ew::core::Document::sceneInstant() const
When this scene is set in story time (minutes since the epoch), if known. Lets a timeline be auto-generated from dated scenes.
void ew::core::Document::setSceneInstant(std::optional< qint64 > sceneInstant)
Sets when this scene is set in story time (minutes since the epoch).
int ew::core::Document::wordCountTarget() const
The word-count target (writing goal) for this document; 0 means no target. Progress is the body's word count measured against it.
void ew::core::Document::setWordCountTarget(int wordCountTarget)
Sets the word-count target (0 means no target).
ContentId ew::core::Document::parentId() const
The parent document in the manuscript tree; a null id means a top-level document.
void ew::core::Document::setParentId(ContentId parentId)
Sets the parent document in the manuscript tree (a null id means top-level).
int ew::core::Document::sortIndex() const
The position of this document among its siblings in the manuscript tree. Lower values come first; documents are ordered by this, then title, then id. New documents are appended after their existing siblings.
void ew::core::Document::setSortIndex(int sortIndex)
Sets this document's position among its siblings (lower comes first).
const std::vector< ContentId > & ew::core::Document::sourceIds() const
The bibliographic sources this document cites – the ids of the Source objects backing its claims. Recorded when a citation is inserted, so a document's support is tracked structurally (not just as citation text). A document that cites nothing has an empty list.
void ew::core::Document::setSourceIds(std::vector< ContentId > sourceIds)
Sets the bibliographic sources this document cites.
const QString & ew::core::Document::revisionBaseline() const
The screenplay body as of the last marked revision – the baseline a revised draft is diffed against so changed lines can be flagged (see ew::app::revisedElements). Empty means no revision has been marked; only meaningful for a Screenplay document.
void ew::core::Document::setRevisionBaseline(QString revisionBaseline)
Sets the screenplay body as of the last marked revision (the revision baseline).
const std::vector< DocumentVersion > & ew::core::Document::versions() const
The saved version snapshots of this document, oldest first (see DocumentVersion). Empty until the writer takes their first snapshot.
void ew::core::Document::setVersions(std::vector< DocumentVersion > versions)
Sets this document's saved version snapshots.
const std::vector< DocumentVariant > & ew::core::Document::variants() const
The alternate ("what-if") drafts held in parallel with the live body (see DocumentVariant) – every variant except the active one, which is the live body(). Empty until the writer creates a second variant.
void ew::core::Document::setVariants(std::vector< DocumentVariant > variants)
Sets the alternate ("what-if") drafts held in parallel with the live body.
const QString & ew::core::Document::activeVariantName() const
The name of the active variant – the one whose content is the live body(). Empty means the document has never used variants (a single unnamed draft); it is set once a second variant is created and the drafts are named.
void ew::core::Document::setActiveVariantName(QString activeVariantName)
Sets the name of the active variant (whose content is the live body).
const std::vector< Footnote > & ew::core::Document::footnotes() const
The footnote and endnote definitions for this document (see Footnote), each keyed by the id its inline [^id] reference carries. Order is not significant – the displayed numbering is derived from where the references appear in the body. Empty until the writer adds a note.
void ew::core::Document::setFootnotes(std::vector< Footnote > footnotes)
Sets this document's footnote and endnote definitions.
DocumentVariant struct
struct ew::core::DocumentVariant
One alternate ("what-if") version of a document's body, kept in parallel with the others so the writer can try a different take on a scene and swap between them without losing any – distinct from the linear history of DocumentVersion snapshots. A document's live body is its active variant; the rest are held as these named alternatives.
Members
QString ew::core::DocumentVariant::name
The writer's name for this alternate draft (e.g. "Darker ending").
QString ew::core::DocumentVariant::body
This draft's body content, as Markdown.
DocumentVersion struct
struct ew::core::DocumentVersion
A saved snapshot of a document's body under a user-given label – a "version" the writer can compare the current draft against or restore to (like a manuscript snapshot). A snapshot is immutable once taken; a document keeps as many as the writer likes ("First draft", "Before the rewrite", ...). The creation time is supplied by the caller so the core stays deterministic.
Members
QString ew::core::DocumentVersion::label
The writer's name for this snapshot.
QString ew::core::DocumentVersion::body
The document body captured when the snapshot was taken.
QDateTime ew::core::DocumentVersion::createdAt
When the snapshot was taken (UTC).
Footnote struct
struct ew::core::Footnote
A footnote or endnote definition: the note text keyed by a stable id. The reference lives inline in the body as a [^id] marker (in appearance order, which drives the displayed numbering); this struct carries the note's content, separated from the prose so it can be authored and edited on its own. Whether it renders at the foot of its section (a footnote) or is collected at the end of the document (an endnote) is chosen per note via endnote; the two form independent numbered sequences. Definitions with no matching [^id] reference in the body are unreferenced (orphans).
Members
QString ew::core::Footnote::id
The stable identifier tying this definition to its inline [^id] reference(s) in the body.
QString ew::core::Footnote::text
The note's content, as Markdown.
bool ew::core::Footnote::endnote = false
Whether this note is an endnote (collected at the document's end) rather than a footnote (rendered at the foot of its section). Footnotes and endnotes number independently.
bool ew::core::Footnote::operator==(const Footnote &other) const =default
Value equality over all fields, so a footnote list can be compared to detect a no-op edit.