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 "MimePoints.h"
12 #include <QApplication>
14 #include <QTextStream>
15 #include "QtToString.h"
16 #include <QXmlStreamReader>
18 const QString CMD_DESCRIPTION (
"Copy");
22 const QStringList &selectedPointIdentifiers) :
26 m_transformIsDefined (mainWindow.transformIsDefined())
28 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCopy::CmdCopy"
29 <<
" selected=" << selectedPointIdentifiers.join (
", ").toLatin1 ().data () <<
")";
32 QTextStream strCsv (&m_csv), strHtml (&m_html);
44 const QString &cmdDescription,
45 QXmlStreamReader &reader) :
50 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCopy::CmdCopy";
52 QXmlStreamAttributes attributes = reader.attributes();
54 if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
55 !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
56 !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
57 ENGAUGE_ASSERT (
false);
60 QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
62 m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
63 m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
64 m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
74 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCopy::cmdRedo";
77 if (m_transformIsDefined) {
84 QClipboard *clipboard = QApplication::clipboard();
85 clipboard->setMimeData (mimePoints, QClipboard::Clipboard);
93 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCopy::cmdUndo";
101 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
102 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_COPY);
103 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
104 writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
105 m_transformIsDefined ? DOCUMENT_SERIALIZE_BOOL_TRUE : DOCUMENT_SERIALIZE_BOOL_FALSE);
106 writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
107 writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
108 m_curvesGraphs.
saveXml(writer);
109 writer.writeEndElement();
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
CmdCopy(MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
Constructor for normal creation.
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
Transformation transformation() const
Return read-only copy of transformation.
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
const Curve & curveAxes() const
Get method for axis curve.
Custom mime type for separate treatment of graph coordinates and, when there is no transform...
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
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.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
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...
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.