anpstudio 0.1.0
ANP Studio — Analytic Network Process desktop application
Loading...
Searching...
No Matches
Signals | Public Member Functions | List of all members
Document Class Reference

Owns the root anpcpp::AnpNetwork, undo stack, file path, and dirty flag. More...

#include <document.hpp>

Inherits QObject.

Signals

void modelChanged ()
 Emitted when the model structure or data changes.
 
void dirtyChanged (bool dirty)
 Emitted when the dirty flag changes.
 
void pathChanged (const QString &path)
 Emitted when the file path changes.
 
void viewNetworkChanged ()
 Emitted when the active network view changes (subnet navigation).
 
void selectionChanged (const QString &cluster, const QString &node)
 Emitted when soft selection changes.
 
void resultsFreshnessChanged ()
 Emitted when calc freshness changes.
 

Public Member Functions

 Document (QObject *parent=nullptr)
 
anpcpp::AnpNetwork & network ()
 
const anpcpp::AnpNetwork & network () const
 Const overload of network.
 
anpcpp::AnpNetwork & root ()
 
const anpcpp::AnpNetwork & root () const
 Const overload of root.
 
QUndoStack * undoStack ()
 
QString path () const
 
bool isDirty () const
 
void setDirty (bool dirty)
 Sets the dirty flag and emits dirtyChanged when it changes.
 
void newNetwork (bool create_alts=true)
 Replaces the model with a new empty network.
 
bool loadFromFile (const QString &path, QString *error=nullptr)
 Loads a network from JSON file.
 
bool saveToFile (const QString &path, QString *error=nullptr)
 Saves the root network to JSON.
 
void pushSubnet (const QString &nodeName)
 Descends into a node's subnetwork for editing.
 
void popSubnet ()
 Returns to the parent network in the subnet stack.
 
void popToRoot ()
 Clears the subnet stack back to the root network.
 
void popToDepth (int depth)
 Pops the subnet stack to depth frames (1 = root only).
 
int subnetDepth () const
 
QStringList breadcrumb () const
 
void notifyChanged ()
 Marks the document dirty and emits modelChanged.
 
QString selectedCluster () const
 
QString selectedNode () const
 
void setSelection (const QString &cluster, const QString &node)
 Soft-persists structure selection across stages.
 
bool hasResults () const
 
bool resultsStale () const
 
void markResultsCurrent ()
 Marks results current after a successful Calculate.
 
void invalidateResults ()
 Marks results stale (or clears hasResults if never calculated).
 

Detailed Description

Owns the root anpcpp::AnpNetwork, undo stack, file path, and dirty flag.

Subnet navigation maintains a stack of AnpNetwork* frames pointing into nodes' owned subnetworks.

Constructor & Destructor Documentation

◆ Document()

Document::Document ( QObject *  parent = nullptr)
explicit
Parameters
parentOptional Qt parent object.

Member Function Documentation

◆ breadcrumb()

QStringList Document::breadcrumb ( ) const
Returns
Breadcrumb trail of host node names for the current view.

◆ hasResults()

bool Document::hasResults ( ) const
inline
Returns
True if Calculate has produced a results snapshot.

◆ isDirty()

bool Document::isDirty ( ) const
inline
Returns
True if there are unsaved changes.

◆ loadFromFile()

bool Document::loadFromFile ( const QString &  path,
QString *  error = nullptr 
)

Loads a network from JSON file.

Parameters
pathFile to read.
errorOptional error message output.
Returns
False on failure.

◆ network()

anpcpp::AnpNetwork & Document::network ( )
Returns
The network currently being edited (may be a subnetwork).

◆ path()

QString Document::path ( ) const
inline
Returns
Current file path (empty if unsaved).

◆ popToDepth()

void Document::popToDepth ( int  depth)

Pops the subnet stack to depth frames (1 = root only).

Parameters
depthTarget stack size; values < 1 are treated as 1.

◆ resultsStale()

bool Document::resultsStale ( ) const
inline
Returns
True if the model changed since the last successful Calculate.

◆ root()

anpcpp::AnpNetwork & Document::root ( )
Returns
The root (top-level) network.

◆ saveToFile()

bool Document::saveToFile ( const QString &  path,
QString *  error = nullptr 
)

Saves the root network to JSON.

Parameters
pathOutput path.
errorOptional error message output.
Returns
False on failure.

◆ selectedCluster()

QString Document::selectedCluster ( ) const
inline
Returns
Selected cluster name (may be empty).

◆ selectedNode()

QString Document::selectedNode ( ) const
inline
Returns
Selected node name (may be empty).

◆ setSelection()

void Document::setSelection ( const QString &  cluster,
const QString &  node 
)

Soft-persists structure selection across stages.

Parameters
clusterSelected cluster (empty if node-only).
nodeSelected node (empty if cluster-only).

◆ subnetDepth()

int Document::subnetDepth ( ) const
Returns
Number of subnet frames above root (0 at root).

◆ undoStack()

QUndoStack * Document::undoStack ( )
inline
Returns
Undo/redo command stack for model edits.

The documentation for this class was generated from the following file: