10 #include "DocumentSerialize.h" 11 #include "EngaugeAssert.h" 12 #include "ExportToClipboard.h" 13 #include "GraphicsItemType.h" 14 #include "GraphicsView.h" 16 #include "MainWindow.h" 17 #include <QTextStream> 18 #include <QtToString.h> 19 #include <QXmlStreamReader> 22 const QString CMD_DESCRIPTION (
"Delete");
26 const QStringList &selectedPointIdentifiers) :
31 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdDelete::CmdDelete" 32 <<
" selected=" << selectedPointIdentifiers.count ();
36 QTextStream strCsv (&m_csv), strHtml (&m_html);
43 m_curvesGraphsRemoved);
48 const QString &cmdDescription,
49 QXmlStreamReader &reader) :
54 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdDelete::CmdDelete";
56 QXmlStreamAttributes attributes = reader.attributes();
58 if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
59 !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
60 !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
61 xmlExitWithError (reader,
62 QString (
"%1 %2, %3 %4 %5")
63 .arg (QObject::tr (
"Missing attribute(s)"))
64 .arg (DOCUMENT_SERIALIZE_TRANSFORM_DEFINED)
65 .arg (DOCUMENT_SERIALIZE_CSV)
66 .arg (QObject::tr (
"and/or"))
67 .arg (DOCUMENT_SERIALIZE_HTML));
70 QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
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_curvesGraphsRemoved.
loadXml(reader);
78 CmdDelete::~CmdDelete ()
84 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdDelete::cmdRedo";
97 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdDelete::cmdUndo";
107 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
108 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_DELETE);
109 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
110 writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
111 m_transformIsDefined ? DOCUMENT_SERIALIZE_BOOL_TRUE : DOCUMENT_SERIALIZE_BOOL_FALSE);
112 writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
113 writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
114 m_curvesGraphsRemoved.
saveXml(writer);
115 writer.writeEndElement();
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
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.
CmdDelete(MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
Constructor for normal creation.
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
Transformation transformation() const
Return read-only copy of transformation.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
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.
Strategy class for exporting to the clipboard. This strategy is external to the Document class so tha...
Document & document()
Return the Document that this command will modify during redo and undo.
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
const Curve & curveAxes() const
Get method for axis curve.
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.
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.
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.