12struct SelectionIdsSnapshot {
17 QString transactionId;
23 return {selection.selectedActorId(), selection.selectedPropertyId(),
24 selection.selectedContractId(), selection.selectedStatementId(),
25 selection.selectedTransactionId(), selection.selectedAnalysisId(),
26 selection.selectedAnnualId()};
30 const SelectionIdsSnapshot& before) {
31 if (selection.selectedActorId() != before.actorId)
32 emit selection.selectedActorIdChanged();
33 if (selection.selectedPropertyId() != before.propertyId)
34 emit selection.selectedPropertyIdChanged();
35 if (selection.selectedContractId() != before.contractId)
36 emit selection.selectedContractIdChanged();
37 if (selection.selectedStatementId() != before.statementId)
38 emit selection.selectedStatementIdChanged();
39 if (selection.selectedTransactionId() != before.transactionId)
40 emit selection.selectedTransactionIdChanged();
41 if (selection.selectedAnalysisId() != before.analysisId)
42 emit selection.selectedAnalysisIdChanged();
43 if (selection.selectedAnnualId() != before.annualId)
44 emit selection.selectedAnnualIdChanged();
47bool updateSelectedId(QString& targetId,
const QString& newId) {
48 const QString normalized = newId.trimmed();
49 if (targetId == normalized) {
52 targetId = normalized;
61 : QObject(parent), store_(store), selectors_(selectors) {
63 &WorkspaceSelection::refreshSelections);
67 return selectedActorId_;
70 return selectedPropertyId_;
73 return selectedContractId_;
76 return selectedStatementId_;
79 return selectedTransactionId_;
82 return selectedAnalysisId_;
85 return selectedAnnualId_;
89 if (updateSelectedId(selectedActorId_,
id)) {
96 if (updateSelectedId(selectedPropertyId_,
id)) {
103 if (updateSelectedId(selectedContractId_,
id)) {
104 validateSelections();
110 if (updateSelectedId(selectedStatementId_,
id)) {
111 validateSelections();
117 if (updateSelectedId(selectedAnalysisId_,
id)) {
118 validateSelections();
124 if (updateSelectedId(selectedAnnualId_,
id)) {
125 validateSelections();
148 const auto before = captureSelectionIds(*
this);
149 selectedStatementId_ = statementId.trimmed();
150 selectedTransactionId_ =
id.trimmed();
151 validateSelections();
152 emitSelectionChanges(*
this, before);
163void WorkspaceSelection::validateSelections() {
164 if (!selectedActorId_.isEmpty() && !selectors_.
hasActorId(selectedActorId_)) {
165 selectedActorId_.clear();
167 if (!selectedPropertyId_.isEmpty() &&
169 selectedPropertyId_.clear();
171 if (!selectedContractId_.isEmpty() &&
172 !selectors_.hasContractId(selectedContractId_)) {
173 selectedContractId_.clear();
175 if (!selectedStatementId_.isEmpty() &&
176 !selectors_.hasStatementId(selectedStatementId_)) {
177 selectedStatementId_.clear();
178 selectedTransactionId_.clear();
180 if (!selectedTransactionId_.isEmpty() &&
181 !selectors_.hasTransactionId(selectedTransactionId_)) {
182 selectedTransactionId_.clear();
184 if (!selectedAnalysisId_.isEmpty() &&
185 !selectors_.hasAnalysisId(selectedAnalysisId_)) {
186 selectedAnalysisId_.clear();
188 if (!selectedAnnualId_.isEmpty() &&
189 !selectors_.hasAnnualId(selectedAnnualId_)) {
190 selectedAnnualId_.clear();
198void WorkspaceSelection::refreshSelections() {
199 const auto before = captureSelectionIds(*
this);
200 validateSelections();
201 emitSelectionChanges(*
this, before);
Declares the workspace selection state synchronized with the store.
Tracks the currently selected workspace entities.
void selectedActorIdChanged()
Emitted when the selected actor id changed.
void selectActor(const QString &id)
Selects an actor.
WorkspaceSelection(WorkspaceStore &store, WorkspaceSelectors &selectors, QObject *parent=nullptr)
Creates the selection state for the supplied workspace roles.
void selectedAnalysisIdChanged()
Emitted when the selected analysis id changed.
QString selectedAnnualId() const
Returns the selected annual id.
void setSelectedPropertyId(const QString &id)
Selects a property id.
QString selectedTransactionId() const
Returns the selected transaction id.
void selectTransaction(const QString &statementId, const QString &id)
Selects a statement and transaction.
void selectStatement(const QString &id)
Selects a statement.
void selectedStatementIdChanged()
Emitted when the selected statement id changed.
void selectedContractIdChanged()
Emitted when the selected contract id changed.
void selectedAnnualIdChanged()
Emitted when the selected annual id changed.
void setSelectedAnnualId(const QString &id)
Selects an annual id.
void loadFromState()
Refreshes selection objects after the underlying store reloaded.
QString selectedStatementId() const
Returns the selected statement id.
void setSelectedStatementId(const QString &id)
Selects a statement id.
void setSelectedAnalysisId(const QString &id)
Selects an analysis id.
QString selectedPropertyId() const
Returns the selected property id.
void selectedPropertyIdChanged()
Emitted when the selected property id changed.
QString selectedActorId() const
Returns the selected actor id.
QString selectedAnalysisId() const
Returns the selected analysis id.
void setSelectedContractId(const QString &id)
Selects a contract id.
void selectContract(const QString &id)
Selects a contract.
void selectAnalysis(const QString &id)
Selects an analysis.
QString selectedContractId() const
Returns the selected contract id.
void selectProperty(const QString &id)
Selects a property.
void setSelectedActorId(const QString &id)
Selects an actor id.
void selectAnnual(const QString &id)
Selects an annual.
Projects workspace store data into QML-facing read models.
bool hasActorId(const QString &id) const
Checks whether an actor id exists.
bool hasPropertyId(const QString &id) const
Checks whether a property id exists.
Owns the current UI-side workspace snapshot and revision lifecycle.
void dataRevisionChanged()