CascadeRename.h header

#include <ew/app/content/CascadeRename.h>

Namespace ew::app::content

RenameHit struct

struct ew::app::content::RenameHit

One place a cascading rename would rewrite text.

Members

ew::core::foundation::ContentId ew::app::content::RenameHit::objectId

The object holding this place, or a null id for a project registry (a plot thread), which holds prose without being a content object.

A hit a caller cannot identify is a hit it cannot make a decision about: the MCP tool has to say which of these places it left alone because the object was locked, and it can only ask that question of an object it can find.

QString ew::app::content::RenameHit::objectTitle

The object's title/name, as the writer would recognise it.

QString ew::app::content::RenameHit::kind

The object's type token ("entity", "document", ...).

QString ew::app::content::RenameHit::place

Where inside the object – "name", "body", "synopsis", "point_of_view", "field \"Faith And Devotion\"", "description", "comment", "alias".

int ew::app::content::RenameHit::occurrences = 0

How many occurrences that place holds.

RenamePlan struct

struct ew::app::content::RenamePlan

What a cascading rename would do, without doing it.

Members

std::vector<RenameHit> ew::app::content::RenamePlan::hits

Every place that would change, in a stable order.

int ew::app::content::RenamePlan::totalOccurrences = 0

The total number of occurrences across every place.

Types

using ew::app::content::RenameFilter = std::function<bool(const ew::core::content::ContentObject& object)>

Which objects a cascading rename may look at and rewrite. An EMPTY filter means every object, which is what a rename driven by the person who owns the project means.

The MCP tools pass the AI policy gate through here rather than filtering a finished plan, because the SURVEY is as sensitive as the rename: it names each object and says how many times that object mentions the name. An object the assistant may not read must never be planned, not merely left unrewritten.

Functions

std::unique_ptr< ew::core::undo::Command > ew::app::content::buildCascadingRenameCommand(ew::core::project::Project &project, const QString &oldName, const QString &newName, const RenameFilter &mayTouch={})

One undoable command that applies planCascadingRename's rewrite, replacing oldName with newName everywhere it occurs. Null when nothing would change, so a caller can say "nothing to rename" rather than push an empty command that still marks the project modified.

The whole cascade is a single CompositeCommand: one Ctrl+Z puts every touched place back, however many objects it reached.

RenamePlan ew::app::content::planCascadingRename(const ew::core::project::Project &project, const QString &oldName, const RenameFilter &mayTouch={})

Every place oldName occurs across project – object names and aliases, document bodies, synopses, points of view and statuses, entity field values and state-over-time values, task and timeline-event descriptions, comment text, and plot-thread names and descriptions.

This is the dry run, and it matters as much as the rename: a writer renaming a character wants to see the blast radius before committing, because the places a name hides in are exactly the ones they will not think to check. Renaming by hand took repeated sweeps and still left occurrences behind, each time somewhere different.

Matching is whole-word and case-sensitive: renaming "Marda" must not touch "Mardana", and a case-insensitive rewrite would silently restyle prose it was not asked to. mayTouch narrows which objects are considered; an empty filter considers all of them.