7 #include "CmdSettingsCurveAddRemove.h"
8 #include "CurveNameList.h"
10 #include "DocumentSerialize.h"
12 #include "MainWindow.h"
13 #include <QXmlStreamReader>
16 const QString CMD_DESCRIPTION (
"Curve add/remove");
25 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdSettingsCurveAddRemove::CmdSettingsCurveAddRemove";
30 for (
int row = 0; row < modelCurves.
rowCount (); row++) {
32 QModelIndex idxCurrent = modelCurves.index (row, 0);
33 QModelIndex idxOriginal = modelCurves.index (row, 1);
35 QString curveNameCurrent = modelCurves.
data (idxCurrent).toString ();
36 QString curveNameOriginal = modelCurves.
data (idxOriginal).toString ();
37 if (!curveNameOriginal.isEmpty ()) {
40 const Curve *curveOriginal = ((
const Document&) document).curveForCurveName (curveNameOriginal);
41 Curve curveCurrent (*curveOriginal);
49 Curve curveCurrent (curveNameCurrent,
61 const QString &cmdDescription,
62 QXmlStreamReader &reader) :
67 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdSettingsCurveAddRemove::CmdSettingsCurveAddRemove";
73 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
74 (reader.name() != DOCUMENT_SERIALIZE_CMD)){
75 loadNextFromReader(reader);
77 xmlExitWithError (reader,
79 .arg (QObject::tr (
"Reached end of file before finding end element for"))
80 .arg (DOCUMENT_SERIALIZE_CMD));
85 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
86 (reader.name() == DOCUMENT_SERIALIZE_CURVES_GRAPHS)) {
90 m_curvesGraphsBefore.
loadXml (reader);
95 m_curvesGraphsAfter.
loadXml (reader);
102 reader.raiseError (
"Cannot read curve add/remove settings");
106 CmdSettingsCurveAddRemove::~CmdSettingsCurveAddRemove ()
112 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdSettingsCurveAddRemove::cmdRedo";
122 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdSettingsCurveAddRemove::cmdUndo";
132 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
133 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_ADD_REMOVE);
134 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
135 m_curvesGraphsBefore.
saveXml(writer);
136 m_curvesGraphsAfter.
saveXml(writer);
137 writer.writeEndElement();
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
static LineStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
void updateSettingsCurveAddRemove(const CurvesGraphs &curvesGraphs)
Update with new curves.
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
int numCurves() const
Current number of graphs curves.
void addGraphCurveAtEnd(Curve curve)
Append new graph Curve to end of Curve list.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
static ColorFilterSettings defaultFilter()
Initial default for any Curve.
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
CmdSettingsCurveAddRemove(MainWindow &mainWindow, Document &document, const CurveNameList &modelCurves)
Constructor for normal creation.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Retrieve data from model.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
void setCurveName(const QString &curveName)
Change the curve name.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Container for LineStyle and PointStyle for one Curve.
Storage of one imported image and the data attached to that image.
Container for one set of digitized Points.
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
One row per curve name.
Document & document()
Return the Document that this command will modify during redo and undo.
static PointStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
Model for DlgSettingsCurveAddRemove and CmdSettingsCurveAddRemove.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...