ProjectTemplate.h header

#include <ew/app/ProjectTemplate.h>

Namespace ew::app

ProjectTemplate struct

struct ew::app::ProjectTemplate

The manifest of a project template – a reusable starter project (a genre skeleton such as a novel, a TTRPG campaign, or a screenplay) that a writer can create new projects from or author and share. Stored as a "template.json" file in the template's folder.

Members

QString ew::app::ProjectTemplate::name

The template's display name.

QString ew::app::ProjectTemplate::description

A short description of what the template sets up.

QString ew::app::ProjectTemplate::author

Who authored the template (optional).

QString ew::app::ProjectTemplate::version

The template's version, e.g. "1.0" – so a shared template can be revised and its consumers can tell which revision they have.

QString ew::app::ProjectTemplate::category

The genre/category this template belongs to (e.g. "Novel", "Campaign", "Screenplay"), for grouping in a chooser. Optional.

TemplateEntry struct

struct ew::app::TemplateEntry

A template discovered on disk: its manifest and the absolute path of its folder.

Members

ProjectTemplate ew::app::TemplateEntry::manifest

The template's parsed manifest.

QString ew::app::TemplateEntry::directory

The absolute path of the template's folder.

Functions

bool ew::app::instantiateTemplate(const QString &templateDir, const QString &targetDir)

Instantiates the template folder templateDir into a new project at targetDir by copying the template's files (recursively), excluding the "template.json" manifest so the instance is an ordinary project rather than another template. targetDir is created if needed and must be empty of conflicting files. Returns true on success; false if the template folder does not exist, the target could not be created, or a file could not be copied.

std::vector< TemplateEntry > ew::app::listProjectTemplates(const QString &templatesDir)

Lists the project templates under templatesDir: every immediate subfolder that contains a readable "template.json", sorted by template name (then folder name). Returns an empty list when the directory does not exist or holds no templates.

ProjectTemplate ew::app::templateManifestFromJson(const QByteArray &json)

Parses a "template.json" manifest from json. Missing fields become empty strings; malformed JSON yields a default-constructed template.

QByteArray ew::app::templateManifestToJson(const ProjectTemplate &tmpl)

Serialises tmpl to the JSON bytes of a "template.json" manifest.