QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
AddDiagramCommand Class Reference

The AddDiagramCommand class Undo/redo support for adding a new folio (diagram) to a project. Takes ownership of the (already constructed, not yet inserted) diagram: redo() inserts it into the project, undo() detaches it again without destroying it. The diagram is only actually destroyed when this command itself is destroyed while the diagram is detached (i.e. while undone). More...

#include <adddiagramcommand.h>

Inherits QUndoCommand.

Collaboration diagram for AddDiagramCommand:
Collaboration graph

Public Member Functions

 AddDiagramCommand (QETProject *project, Diagram *diagram, int pos=-1, QUndoCommand *parent=nullptr)
 AddDiagramCommand::AddDiagramCommand.
 ~AddDiagramCommand () override
 AddDiagramCommand::~AddDiagramCommand Destroy the diagram only if it is currently detached from the project (i.e. this add was undone) – otherwise the project owns it and will destroy it itself.
void undo () override
void redo () override

Private Attributes

QPointer< QETProjectm_project
Diagramm_diagram
int m_position
bool m_owns_diagram = true
 true while the diagram is detached from the project (not currently in its diagram list)

Detailed Description

The AddDiagramCommand class Undo/redo support for adding a new folio (diagram) to a project. Takes ownership of the (already constructed, not yet inserted) diagram: redo() inserts it into the project, undo() detaches it again without destroying it. The diagram is only actually destroyed when this command itself is destroyed while the diagram is detached (i.e. while undone).

Constructor & Destructor Documentation

◆ AddDiagramCommand()

AddDiagramCommand::AddDiagramCommand ( QETProject * project,
Diagram * diagram,
int pos = -1,
QUndoCommand * parent = nullptr )

AddDiagramCommand::AddDiagramCommand.

Parameters
project: project the diagram is added to
diagram: the already constructed diagram to add (not yet part of any project's diagram list)
pos: position to insert the diagram at, -1 to append at the end
parent

◆ ~AddDiagramCommand()

AddDiagramCommand::~AddDiagramCommand ( )
override

AddDiagramCommand::~AddDiagramCommand Destroy the diagram only if it is currently detached from the project (i.e. this add was undone) – otherwise the project owns it and will destroy it itself.

Member Function Documentation

◆ redo()

void AddDiagramCommand::redo ( )
override

◆ undo()

void AddDiagramCommand::undo ( )
override

Member Data Documentation

◆ m_diagram

Diagram* AddDiagramCommand::m_diagram
private

◆ m_owns_diagram

bool AddDiagramCommand::m_owns_diagram = true
private

true while the diagram is detached from the project (not currently in its diagram list)

◆ m_position

int AddDiagramCommand::m_position
private

◆ m_project

QPointer<QETProject> AddDiagramCommand::m_project
private

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