Engauge Digitizer 2
Loading...
Searching...
No Matches
CmdDelete Class Reference

Command for deleting all selected Points. More...

#include <CmdDelete.h>

Inheritance diagram for CmdDelete:
Inheritance graph
Collaboration diagram for CmdDelete:
Collaboration graph

Public Member Functions

 CmdDelete (MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
 Constructor for normal creation.
 CmdDelete (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml.
virtual ~CmdDelete ()
virtual void cmdRedo ()
 Redo method that is called when QUndoStack is moved one command forward.
virtual void cmdUndo ()
 Undo method that is called when QUndoStack is moved one command backward.
virtual void saveXml (QXmlStreamWriter &writer) const
 Save commands as xml for later uploading.
Public Member Functions inherited from CmdPointChangeBase
 CmdPointChangeBase (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor.
virtual ~CmdPointChangeBase ()
Public Member Functions inherited from CmdAbstract
 CmdAbstract (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor.
virtual ~CmdAbstract ()

Additional Inherited Members

Protected Member Functions inherited from CmdPointChangeBase
void restoreDocumentState (Document &document) const
 Restore the document previously saved by saveDocumentState.
void saveDocumentState (const Document &document)
 Save the document state for restoration by restoreDocumentState.
Protected Member Functions inherited from CmdAbstract
void baseAttributes (QXmlStreamWriter &writer) const
 After writing leaf class attributes, this writes the base class atributes.
Documentdocument ()
 Return the Document that this command will modify during redo and undo.
const Documentdocument () const
 Return a const copy of the Document for non redo/undo interaction.
void leafAttributes (const QXmlStreamAttributes &attributes, const QStringList &requiredAttributesLeaf, QXmlStreamReader &reader)
 Same as often-used leafAndBaseAttributes, except this is used in the special case where a class inherits from another class (e.g.
void leafAndBaseAttributes (const QXmlStreamAttributes &attributes, const QStringList &requiredAttributesLeaf, QXmlStreamReader &reader)
 Before reading leaf class attributes, check all required attributes from leaf and this base class are included, then extract the parent class attributes.
MainWindowmainWindow ()
 Return the MainWindow so it can be updated by this command as a last step.
void resetSelection (const PointIdentifiers &pointIdentifiersToSelect)
 Call this (for consistency) after writing leaf class attributes, to write the base class attributes.
void restoreState ()
 Before any other operations associated with a Cmd class are performed, this method is called to restore original states to all relevant state machines.
void saveOrCheckPostCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document.
void saveOrCheckPreCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document.
void selectAddedPointForMoving (const QString &pointAdded)
 Select point that was just added so it can be moved by the user next for convenience.
void selectAddedPointsForMoving (const QStringList &pointsAdded)
 Select points that were just added so they can be moved by the user next for convenience.

Detailed Description

Command for deleting all selected Points.

Definition at line 18 of file CmdDelete.h.

Constructor & Destructor Documentation

◆ CmdDelete() [1/2]

CmdDelete::CmdDelete ( MainWindow & mainWindow,
Document & document,
const QStringList & selectedPointIdentifiers )

Constructor for normal creation.

Definition at line 25 of file CmdDelete.cpp.

27 :
31 m_deletedPointIdentifiers (deletedPointIdentifiers)
32{
33 LOG4CPP_INFO_S ((*mainCat)) << "CmdDelete::CmdDelete";
34
35 // Export to clipboard
36 ExportToClipboard exportStrategy;
37 QTextStream strCsv (&m_csv), strHtml (&m_html);
38 exportStrategy.exportToClipboard (deletedPointIdentifiers,
39 mainWindow.transformation(),
40 strCsv,
41 strHtml,
42 document.curveAxes(),
43 document.curvesGraphs(),
44 m_curvesGraphsRemoved);
45}
const QString CMD_DESCRIPTION("Add axis point")
log4cpp::Category * mainCat
Definition Logger.cpp:14
Document & document()
Return the Document that this command will modify during redo and undo.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
CmdPointChangeBase(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
void exportToClipboard(const QStringList &selected, const Transformation &transformation, QTextStream &strCsv, QTextStream &strHtml, const Curve &curveAxis, const CurvesGraphs &curvesGraphsAll, CurvesGraphs &curvesGraphsSelected) const
Export, curve-by-curve, raw data points to a string that will be copied to the clipboard.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ CmdDelete() [2/2]

CmdDelete::CmdDelete ( MainWindow & mainWindow,
Document & document,
const QString & cmdDescription,
QXmlStreamReader & reader )

Constructor for parsing error report file xml.

Definition at line 47 of file CmdDelete.cpp.

50 :
53 cmdDescription)
54{
55 LOG4CPP_INFO_S ((*mainCat)) << "CmdDelete::CmdDelete";
56
57 QXmlStreamAttributes attributes = reader.attributes();
58
59 QStringList requiredAttributesLeaf;
60 requiredAttributesLeaf << DOCUMENT_SERIALIZE_TRANSFORM_DEFINED
64 leafAndBaseAttributes (attributes,
65 requiredAttributesLeaf,
66 reader);
67
68 // Boolean values
69 QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
70
71 m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
72 m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
73 m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
74 m_deletedPointIdentifiers = attributes.value(DOCUMENT_SERIALIZE_CMD_DELETE_ADDED_POINTS).toString().split(ADDED_DELIMITER);
75 m_curvesGraphsRemoved.loadXml(reader);
76}
const QString ADDED_DELIMITER(",")
const QString DOCUMENT_SERIALIZE_TRANSFORM_DEFINED
const QString DOCUMENT_SERIALIZE_HTML
const QString DOCUMENT_SERIALIZE_CSV
const QString DOCUMENT_SERIALIZE_CMD_DELETE_ADDED_POINTS
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
void leafAndBaseAttributes(const QXmlStreamAttributes &attributes, const QStringList &requiredAttributesLeaf, QXmlStreamReader &reader)
Before reading leaf class attributes, check all required attributes from leaf and this base class are...

◆ ~CmdDelete()

CmdDelete::~CmdDelete ( )
virtual

Definition at line 78 of file CmdDelete.cpp.

79{
80}

Member Function Documentation

◆ cmdRedo()

void CmdDelete::cmdRedo ( )
virtual

Redo method that is called when QUndoStack is moved one command forward.

Implements CmdAbstract.

Definition at line 82 of file CmdDelete.cpp.

83{
84 LOG4CPP_INFO_S ((*mainCat)) << "CmdDelete::cmdRedo";
85
86 restoreState ();
89 document().removePointsInCurvesGraphs (m_curvesGraphsRemoved);
90
91 document().updatePointOrdinals (mainWindow().transformation());
94}
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void restoreState()
Before any other operations associated with a Cmd class are performed, this method is called to resto...
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
Definition Document.cpp:903
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.

◆ cmdUndo()

void CmdDelete::cmdUndo ( )
virtual

Undo method that is called when QUndoStack is moved one command backward.

Implements CmdAbstract.

Definition at line 96 of file CmdDelete.cpp.

97{
98 LOG4CPP_INFO_S ((*mainCat)) << "CmdDelete::cmdUndo";
99
100 restoreState ();
104 selectAddedPointsForMoving(m_deletedPointIdentifiers);
106}
void selectAddedPointsForMoving(const QStringList &pointsAdded)
Select points that were just added so they can be moved by the user next for convenience.
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.

◆ saveXml()

void CmdDelete::saveXml ( QXmlStreamWriter & writer) const
virtual

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 108 of file CmdDelete.cpp.

109{
110 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
112 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
113 writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
115 writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
116 writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
117 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DELETE_ADDED_POINTS, m_deletedPointIdentifiers.join (ADDED_DELIMITER));
118 m_curvesGraphsRemoved.saveXml(writer);
119 baseAttributes (writer);
120 writer.writeEndElement();
121}
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DELETE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
void baseAttributes(QXmlStreamWriter &writer) const
After writing leaf class attributes, this writes the base class atributes.

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