CascadeRename.h header

#include <ew/app/CascadeRename.h>

Namespace ew::app

RenameHit struct

struct ew::app::RenameHit

One place a cascading rename would rewrite text.

Members

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::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.

Functions

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

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)

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.