ObjectAudiences.h header

#include <ew/app/ObjectAudiences.h>

Namespace ew::app

AudienceResolution struct

struct ew::app::AudienceResolution

What resolveAudienceNames worked out.

Members

std::set<QString> ew::app::content::AudienceResolution::ids

The ids to store on content – one per requested name, existing or newly created.

std::vector<ew::core::content::Audience> ew::app::content::AudienceResolution::registryToApply

The registry to apply, including anything newly created. Empty when nothing was created and the caller therefore needs no registry command.

QStringList ew::app::content::AudienceResolution::created

The names that had to be created, for reporting back to whoever asked.

Enumerations

enum class AudienceSweep { UnrestrictedOnly, Everything }

Which existing objects a bulk visibility change should touch.

Functions

std::unique_ptr< ew::core::undo::Command > ew::app::content::buildApplyAudienceToAllCommand(ew::core::project::Project &project, const std::set< QString > &audiences, AudienceSweep sweep)

Builds one undoable command that sets audiences as the visible-audience set of the objects in project selected by sweep – the retroactive half of Project::defaultAudiences, which governs only newly created objects.

This exists because per-object visibility is subtractive: an unrestricted object is visible to EVERY audience, so an export for a readership includes everything nobody has restricted. In a project of hundreds of objects that makes "only these few things are for readers" unreachable by hand. Sweeping a default across everything inverts the model – content is then PROMOTED to a readership instead of hidden from one.

The result is a single CompositeCommand, so the whole sweep is one undo step rather than hundreds (and one entry in the change log). Returns null when the sweep would change nothing, so a caller can report "nothing to do" instead of pushing an empty command that still marks the project modified and clears the redo stack.

int ew::app::content::countAudienceSweepTargets(const ew::core::project::Project &project, const std::set< QString > &audiences, AudienceSweep sweep)

How many objects buildApplyAudienceToAllCommand would change, for a confirmation prompt that states the scale before the writer commits to it.

int ew::app::content::countObjectsRestrictedTo(const ew::core::project::Project &project, const QString &audience)

How many objects in project are restricted to audience – that is, carry it in their visible-audience set.

This exists to make removing an audience an informed decision rather than a silent one. Visibility is subtractive, so an object restricted to an audience that has left the registry is visible to NOBODY: the "view as" list is built from the registry, so no selectable audience matches it any more, and it disappears from every audience view and every filtered export. The content is still on disk and re-adding an audience of the same name brings it back, but nothing says so at the moment of removal.

Deliberately a count rather than a repair. Clearing the audience from those objects would leave them unrestricted, and an unrestricted object is visible to EVERYONE – so "helpfully" tidying up after a removed "GM" audience would publish the GM notes. The safe move is to state the number and let the writer decide.

AudienceResolution ew::app::content::resolveAudienceNames(const ew::core::project::Project &project, const std::set< QString > &names)

Maps writer-facing audience names onto project's registry, inventing an audience for any name the project does not already hold.

Callers that accept audiences as human input – the MCP set_visibility tool, the folder-conversion pipeline – work in names, while content stores ids. This is the one place that crossing happens, so the two callers cannot drift into resolving it differently.

Matching is case-INSENSITIVE: a writer who types "gm" when the project has "GM" means the one that exists, and silently creating a second audience differing only in case would produce two readerships that look identical in the list and hide content from each other.