17#include "anpcpp/network.hpp"
33 QVector<ResearcherCell> cells;
74 explicit Document(QObject* parent =
nullptr);
77 [[nodiscard]] anpcpp::AnpNetwork& network();
78 [[nodiscard]]
const anpcpp::AnpNetwork& network()
const;
79 [[nodiscard]] anpcpp::AnpNetwork& root();
80 [[nodiscard]]
const anpcpp::AnpNetwork& root()
const;
81 [[nodiscard]] anpcpp::AnpNetwork* parentNetwork();
82 [[nodiscard]]
const anpcpp::AnpNetwork* parentNetwork()
const;
84 [[nodiscard]] QUndoStack* undoStack() {
return &undo_; }
86 [[nodiscard]] QString path()
const {
return path_; }
87 [[nodiscard]]
bool isDirty()
const {
return dirty_; }
88 void setDirty(
bool dirty);
90 void newNetwork(
bool create_alts =
true);
91 bool loadFromFile(
const QString& path, QString* error =
nullptr);
92 bool saveToFile(
const QString& path, QString* error =
nullptr);
97 return researcherNotebooks_;
101 return researcherActiveIndex_;
115 return linkedGoogleForms_;
124 void pushSubnet(
const QString& nodeName);
127 void popToDepth(
int depth);
128 [[nodiscard]]
int subnetDepth()
const;
129 [[nodiscard]] QStringList breadcrumb()
const;
130 [[nodiscard]] QStringList networkPathOptions()
const;
131 [[nodiscard]] QString currentNetworkPath()
const;
132 bool navigateToNetworkPath(
const QString& path);
141 void notifyChanged();
142 void flushModelChanged();
144 void setSuppressLayoutPersist(
bool suppress) {
145 suppressLayoutPersist_ = suppress;
147 [[nodiscard]]
bool suppressLayoutPersist()
const {
148 return suppressLayoutPersist_;
151 [[nodiscard]] QString selectedCluster()
const {
return selectedCluster_; }
152 [[nodiscard]] QString selectedNode()
const {
return selectedNode_; }
153 void setSelection(
const QString& cluster,
const QString& node);
155 [[nodiscard]]
bool hasResults()
const {
return hasResults_; }
156 [[nodiscard]]
bool resultsStale()
const {
157 return hasResults_ && resultsStale_;
159 void markResultsCurrent();
160 void invalidateResults();
166 return !root().participants().empty();
169 [[nodiscard]]
const std::vector<anpcpp::JudgmentParticipant>&
participants()
171 return root().participants();
176 return root().judgment_groups();
180 return root().judgment_session();
194 const QString& email = {});
200 const QStringList& memberIds);
241 void dirtyChanged(
bool dirty);
242 void pathChanged(
const QString& path);
243 void viewNetworkChanged();
244 void selectionChanged(
const QString& cluster,
const QString& node);
245 void resultsFreshnessChanged();
257 anpcpp::AnpNetwork* net =
nullptr;
261 void replaceRoot(std::unique_ptr<anpcpp::AnpNetwork> net);
262 void clearSelectionIfInvalid();
263 void queueModelChanged();
264 void emitViewSwitch();
266 struct ResearcherSessionData {
267 QVector<ResearcherNotebook> notebooks;
271 [[nodiscard]]
static ResearcherSessionData parseResearcherSession(
272 const QByteArray& fileBytes);
273 [[nodiscard]]
static QVector<LinkedGoogleForm> parseLinkedGoogleForms(
274 const QByteArray& fileBytes);
275 [[nodiscard]] QByteArray buildFileBytes()
const;
276 [[nodiscard]]
bool researcherSessionIsTrivial()
const;
278 std::unique_ptr<anpcpp::AnpNetwork> root_;
279 std::vector<Frame> stack_;
283 bool suppressLayoutPersist_ =
false;
284 bool modelChangedQueued_ =
false;
285 QString selectedCluster_;
286 QString selectedNode_;
287 bool hasResults_ =
false;
288 bool resultsStale_ =
false;
289 QVector<ResearcherNotebook> researcherNotebooks_;
290 int researcherActiveIndex_ = 0;
291 QVector<LinkedGoogleForm> linkedGoogleForms_;
Owns the root anpcpp::AnpNetwork, undo stack, file path, and dirty flag.
Definition document.hpp:71
void rebuildEffectiveJudgments()
Rebuilds effective judgments from the root network downward.
const LinkedGoogleForm * latestLinkedGoogleForm() const
const std::vector< anpcpp::JudgmentParticipant > & participants() const
Definition document.hpp:169
void removeLinkedGoogleForm(const QString &formId)
Removes by form id.
bool judgmentReadOnly() const
anpcpp::AnpNetwork * networkAtPath(const QString &path) const
Returns the network at a breadcrumb path without changing the view.
void addLinkedGoogleForm(const LinkedGoogleForm &form)
Appends a linked form and marks dirty.
void sessionChanged()
Emitted when the judgment session scope or roster changes.
void removeParticipant(const QString &id)
Removes a participant and their judgment tables.
void applyNetworkJson(const QByteArray &bytes)
Replaces the root network from snapshotNetworkJson bytes.
void clearResearcherSession()
Clears Researcher notebooks without emitting session changed.
const QVector< ResearcherNotebook > & researcherNotebooks() const
Definition document.hpp:96
anpcpp::JudgmentGroup & setJudgmentGroup(const QString &id, const QString &name, const QStringList &memberIds)
Adds or updates a named group of participant ids.
void setJudgmentSession(const anpcpp::JudgmentSession &session)
Sets the session scope, rebuilds effective judgments on the root network, and marks the document dirt...
anpcpp::JudgmentSession judgmentSession() const
Definition document.hpp:179
void researcherSessionChanged()
Emitted when the Researcher session is replaced (load / new).
const std::vector< anpcpp::JudgmentGroup > & judgmentGroups() const
Definition document.hpp:174
void setResearcherSession(QVector< ResearcherNotebook > notebooks, int activeIndex)
Replaces the Researcher session (does not emit session changed).
void removeJudgmentGroup(const QString &id)
Removes a named group.
int researcherActiveIndex() const
Definition document.hpp:100
anpcpp::JudgmentParticipant & addParticipant(const QString &id, const QString &name, const QString &email={})
Adds (or renames, if id already exists) a participant.
void linkedFormsChanged()
Emitted when the linked Google Forms list changes.
const QVector< LinkedGoogleForm > & linkedGoogleForms() const
Definition document.hpp:114
QByteArray snapshotNetworkJson() const
Serializes the root ANP network only (no researcher / google_forms).
QString activeParticipantId() const
bool hasParticipants() const
Definition document.hpp:165
One Researcher notebook cell persisted with the Studio document.
Definition document.hpp:22
One named Researcher notebook (independent cell history).
Definition document.hpp:31