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

Command for copying all selected Points to the clipboard. More...

#include <CmdCopy.h>

Inheritance diagram for CmdCopy:
Inheritance graph
Collaboration diagram for CmdCopy:
Collaboration graph

Public Member Functions

 CmdCopy (MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
 Constructor for normal creation.
 CmdCopy (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml.
virtual ~CmdCopy ()
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 CmdAbstract
 CmdAbstract (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor.
virtual ~CmdAbstract ()

Additional Inherited Members

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 copying all selected Points to the clipboard.

Definition at line 18 of file CmdCopy.h.

Constructor & Destructor Documentation

◆ CmdCopy() [1/2]

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

Constructor for normal creation.

Definition at line 27 of file CmdCopy.cpp.

29 :
33 m_transformIsDefined (mainWindow.transformIsDefined())
34{
35 LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::CmdCopy"
36 << " selected=" << selectedPointIdentifiers.count ();
37
38 ExportToClipboard exportStrategy;
39 QTextStream strCsv (&m_csv), strHtml (&m_html);
40 exportStrategy.exportToClipboard (selectedPointIdentifiers,
41 mainWindow.transformation(),
42 strCsv,
43 strHtml,
44 document.curveAxes(),
45 document.curvesGraphs(),
46 m_curvesGraphs);
47}
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.
CmdAbstract(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

◆ CmdCopy() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 49 of file CmdCopy.cpp.

52 :
55 cmdDescription)
56{
57 LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::CmdCopy";
58
59 QXmlStreamAttributes attributes = reader.attributes();
60
61 QStringList requiredAttributesLeaf;
62 requiredAttributesLeaf << DOCUMENT_SERIALIZE_TRANSFORM_DEFINED
65 leafAndBaseAttributes (attributes,
66 requiredAttributesLeaf,
67 reader);
68
69 // Boolean values
70 QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
71
72 m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
73 m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
74 m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
75 m_curvesGraphs.loadXml(reader);
76}
const QString DOCUMENT_SERIALIZE_TRANSFORM_DEFINED
const QString DOCUMENT_SERIALIZE_HTML
const QString DOCUMENT_SERIALIZE_CSV
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...

◆ ~CmdCopy()

CmdCopy::~CmdCopy ( )
virtual

Definition at line 78 of file CmdCopy.cpp.

79{
80}

Member Function Documentation

◆ cmdRedo()

void CmdCopy::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 82 of file CmdCopy.cpp.

83{
84 LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::cmdRedo";
85
86 restoreState ();
87 MimePointsExport *mimePointsExport;
88 if (m_transformIsDefined) {
89 mimePointsExport = new MimePointsExport (m_csv,
90 m_html);
91 } else {
92 mimePointsExport = new MimePointsExport (m_csv);
93 }
94
95 QClipboard *clipboard = QApplication::clipboard();
96 clipboard->setMimeData (mimePointsExport, QClipboard::Clipboard);
97
99 document().updatePointOrdinals (mainWindow().transformation());
102}
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 updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.

◆ cmdUndo()

void CmdCopy::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 104 of file CmdCopy.cpp.

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 115 of file CmdCopy.cpp.

116{
117 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
119 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
120 writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
122 writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
123 writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
124 m_curvesGraphs.saveXml(writer);
125 baseAttributes (writer);
126 writer.writeEndElement();
127}
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_CMD_COPY
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: