4 #include "DocumentSerialize.h"
5 #include "EngaugeAssert.h"
6 #include "ExportToClipboard.h"
7 #include "GraphicsItemType.h"
8 #include "GraphicsView.h"
10 #include "MainWindow.h"
11 #include <QTextStream>
12 #include <QtToString.h>
13 #include <QXmlStreamReader>
15 const QString CMD_DESCRIPTION (
"Delete");
19 const QStringList &selectedPointIdentifiers) :
24 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdDelete::CmdDelete"
25 <<
" selected=(" << selectedPointIdentifiers.join (
", ").toLatin1 ().data () <<
")";
29 QTextStream strCsv (&m_csv), strHtml (&m_html);
36 m_curvesGraphsRemoved);
41 const QString &cmdDescription,
42 QXmlStreamReader &reader) :
47 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdDelete::CmdDelete";
49 QXmlStreamAttributes attributes = reader.attributes();
51 if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
52 !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
53 !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
54 ENGAUGE_ASSERT (
false);
57 QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
59 m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
60 m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
61 m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
62 m_curvesGraphsRemoved.
loadXml(reader);
65 CmdDelete::~CmdDelete ()
71 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdDelete::cmdRedo";
81 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdDelete::cmdUndo";
91 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
92 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_DELETE);
93 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
94 writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
95 m_transformIsDefined ? DOCUMENT_SERIALIZE_BOOL_TRUE : DOCUMENT_SERIALIZE_BOOL_FALSE);
96 writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
97 writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
98 m_curvesGraphsRemoved.
saveXml(writer);
99 writer.writeEndElement();
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
void loadXml(QXmlStreamReader &reader)
Load from serialized file.
Transformation transformation() const
Return read-only copy of transformation.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
CmdDelete(MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
Constructor for normal creation.
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
const Curve & curveAxes() const
Get method for axis curve.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
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.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Storage of one imported image and the data attached to that image.
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
Strategy class for exporting to the clipboard. This strategy is external to the Document class so tha...
void addPointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs.
Document & document()
Return the Document that this command will modify during redo and undo.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.