Engauge Digitizer  2
Public Member Functions | List of all members
CmdCopy Class Reference

Command for moving all selected Points by a specified translation. 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. More...
 
 CmdCopy (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml. More...
 
virtual ~CmdCopy ()
 
virtual void cmdRedo ()
 Redo method that is called when QUndoStack is moved one command forward. More...
 
virtual void cmdUndo ()
 Undo method that is called when QUndoStack is moved one command backward. More...
 
virtual void saveXml (QXmlStreamWriter &writer) const
 Save commands as xml for later uploading. More...
 
- Public Member Functions inherited from CmdAbstract
 CmdAbstract (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor. More...
 
virtual ~CmdAbstract ()
 

Additional Inherited Members

- Protected Member Functions inherited from CmdAbstract
Documentdocument ()
 Return the Document that this command will modify during redo and undo. More...
 
const Documentdocument () const
 Return a const copy of the Document for non redo/undo interaction. More...
 
MainWindowmainWindow ()
 Return the MainWindow so it can be updated by this command as a last step. More...
 
void resetSelection (const PointIdentifiers &pointIdentifiersToSelect)
 Since the set of selected points has probably changed, changed that set back to the specified set. More...
 
void saveOrCheckPostCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document. More...
 
void saveOrCheckPreCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document. More...
 

Detailed Description

Command for moving all selected Points by a specified translation.

Definition at line 17 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  :
31  document,
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,
42  strCsv,
43  strHtml,
46  m_curvesGraphs);
47 }

◆ 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  :
54  document,
55  cmdDescription)
56 {
57  LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::CmdCopy";
58 
59  QXmlStreamAttributes attributes = reader.attributes();
60 
61  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
62  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
63  !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
64  xmlExitWithError (reader,
65  QString ("%1 %2, %3 %4 %5")
66  .arg (QObject::tr ("Missing attribute(s)"))
69  .arg (QObject::tr ("and/or"))
71  }
72 
73  QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
74 
75  m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
76  m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
77  m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
78  m_curvesGraphs.loadXml(reader);
79 }

◆ ~CmdCopy()

CmdCopy::~CmdCopy ( )
virtual

Definition at line 81 of file CmdCopy.cpp.

82 {
83 }

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 85 of file CmdCopy.cpp.

86 {
87  LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::cmdRedo";
88 
89  MimePointsExport *mimePointsExport;
90  if (m_transformIsDefined) {
91  mimePointsExport = new MimePointsExport (m_csv,
92  m_html);
93  } else {
94  mimePointsExport = new MimePointsExport (m_csv);
95  }
96 
97  QClipboard *clipboard = QApplication::clipboard();
98  clipboard->setMimeData (mimePointsExport, QClipboard::Clipboard);
99 
101  document().updatePointOrdinals (mainWindow().transformation());
104 }

◆ cmdUndo()

void CmdCopy::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 106 of file CmdCopy.cpp.

107 {
108  LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::cmdUndo";
109 
111  document().updatePointOrdinals (mainWindow().transformation());
114 }

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 116 of file CmdCopy.cpp.

117 {
118  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
120  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
121  writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
123  writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
124  writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
125  m_curvesGraphs.saveXml(writer);
126  writer.writeEndElement();
127 }

The documentation for this class was generated from the following files:
CurvesGraphs::saveXml
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
Definition: CurvesGraphs.cpp:270
xmlExitWithError
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition: Xml.cpp:25
Document::curveAxes
const Curve & curveAxes() const
Get method for axis curve.
Definition: Document.cpp:321
CmdAbstract::document
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
DOCUMENT_SERIALIZE_BOOL_TRUE
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
CMD_DESCRIPTION
const QString CMD_DESCRIPTION("Copy")
CurvesGraphs::loadXml
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
Definition: CurvesGraphs.cpp:197
ExportToClipboard
Strategy class for exporting to the clipboard. This strategy is external to the Document class so tha...
Definition: ExportToClipboard.h:17
DOCUMENT_SERIALIZE_TRANSFORM_DEFINED
const QString DOCUMENT_SERIALIZE_TRANSFORM_DEFINED
MainWindow::updateAfterCommand
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Definition: MainWindow.cpp:3240
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
MainWindow::transformation
Transformation transformation() const
Return read-only copy of transformation.
Definition: MainWindow.cpp:3230
DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_TYPE
CmdAbstract::saveOrCheckPostCommandDocumentStateHash
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
Definition: CmdAbstract.cpp:102
DOCUMENT_SERIALIZE_CSV
const QString DOCUMENT_SERIALIZE_CSV
CmdAbstract::saveOrCheckPreCommandDocumentStateHash
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
Definition: CmdAbstract.cpp:125
mainCat
log4cpp::Category * mainCat
Definition: Logger.cpp:14
MainWindow::transformIsDefined
bool transformIsDefined() const
Return true if all three axis points have been defined.
Definition: MainWindow.cpp:3235
Document::updatePointOrdinals
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
Definition: Document.cpp:1066
CmdAbstract::mainWindow
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
ExportToClipboard::exportToClipboard
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.
Definition: ExportToClipboard.cpp:18
DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD
DOCUMENT_SERIALIZE_HTML
const QString DOCUMENT_SERIALIZE_HTML
DOCUMENT_SERIALIZE_BOOL_FALSE
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
CmdAbstract
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:18
Document::curvesGraphs
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
Definition: Document.cpp:342
MimePointsExport
Custom mime type for separate treatment of graph coordinates and, when there is no transform,...
Definition: MimePointsExport.h:15
DOCUMENT_SERIALIZE_CMD_COPY
const QString DOCUMENT_SERIALIZE_CMD_COPY