15#include "anpcpp/network.hpp"
32 [[nodiscard]] anpcpp::AnpNetwork&
network();
34 [[nodiscard]]
const anpcpp::AnpNetwork&
network()
const;
36 [[nodiscard]] anpcpp::AnpNetwork&
root();
38 [[nodiscard]]
const anpcpp::AnpNetwork&
root()
const;
41 [[nodiscard]] QUndoStack*
undoStack() {
return &undo_; }
44 [[nodiscard]] QString
path()
const {
return path_; }
46 [[nodiscard]]
bool isDirty()
const {
return dirty_; }
89 [[nodiscard]] QString
selectedNode()
const {
return selectedNode_; }
98 [[nodiscard]]
bool hasResults()
const {
return hasResults_; }
101 return hasResults_ && resultsStale_;
124 anpcpp::AnpNetwork* net =
nullptr;
128 void replaceRoot(std::unique_ptr<anpcpp::AnpNetwork> net);
129 void clearSelectionIfInvalid();
131 std::unique_ptr<anpcpp::AnpNetwork> root_;
132 std::vector<Frame> stack_;
136 QString selectedCluster_;
137 QString selectedNode_;
138 bool hasResults_ =
false;
139 bool resultsStale_ =
false;
Owns the root anpcpp::AnpNetwork, undo stack, file path, and dirty flag.
Definition document.hpp:23
void setSelection(const QString &cluster, const QString &node)
Soft-persists structure selection across stages.
bool loadFromFile(const QString &path, QString *error=nullptr)
Loads a network from JSON file.
const anpcpp::AnpNetwork & root() const
Const overload of root.
void viewNetworkChanged()
Emitted when the active network view changes (subnet navigation).
void popToRoot()
Clears the subnet stack back to the root network.
void invalidateResults()
Marks results stale (or clears hasResults if never calculated).
void selectionChanged(const QString &cluster, const QString &node)
Emitted when soft selection changes.
void dirtyChanged(bool dirty)
Emitted when the dirty flag changes.
anpcpp::AnpNetwork & root()
bool saveToFile(const QString &path, QString *error=nullptr)
Saves the root network to JSON.
QUndoStack * undoStack()
Definition document.hpp:41
QString path() const
Definition document.hpp:44
void pushSubnet(const QString &nodeName)
Descends into a node's subnetwork for editing.
const anpcpp::AnpNetwork & network() const
Const overload of network.
void modelChanged()
Emitted when the model structure or data changes.
QString selectedCluster() const
Definition document.hpp:87
bool hasResults() const
Definition document.hpp:98
void setDirty(bool dirty)
Sets the dirty flag and emits dirtyChanged when it changes.
void popToDepth(int depth)
Pops the subnet stack to depth frames (1 = root only).
QString selectedNode() const
Definition document.hpp:89
void pathChanged(const QString &path)
Emitted when the file path changes.
void popSubnet()
Returns to the parent network in the subnet stack.
anpcpp::AnpNetwork & network()
void notifyChanged()
Marks the document dirty and emits modelChanged.
void resultsFreshnessChanged()
Emitted when calc freshness changes.
QStringList breadcrumb() const
void newNetwork(bool create_alts=true)
Replaces the model with a new empty network.
bool isDirty() const
Definition document.hpp:46
Document(QObject *parent=nullptr)
bool resultsStale() const
Definition document.hpp:100
void markResultsCurrent()
Marks results current after a successful Calculate.