10 #include "DocumentSerialize.h"
11 #include "EngaugeAssert.h"
13 #include "MainWindow.h"
14 #include "MimePoints.h"
15 #include <QApplication>
17 #include <QGraphicsItem>
18 #include <QTextStream>
19 #include "QtToString.h"
20 #include <QXmlStreamReader>
22 const QString CMD_DESCRIPTION (
"Paste");
26 const QStringList &selectedPointIdentifiers) :
32 QStringList::const_iterator itr;
33 for (itr = selectedPointIdentifiers.begin (); itr != selectedPointIdentifiers.end (); itr++) {
35 QString selectedPointIdentifier = *itr;
37 selected << selectedPointIdentifier;
38 m_copiedPoints.
setKeyValue (selectedPointIdentifier,
true);
41 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdPaste::CmdPaste"
42 <<
" selected=" << selected.join (
", ").toLatin1 ().data () <<
")";
47 const QString &cmdDescription,
48 QXmlStreamReader &reader) :
53 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdPaste::CmdPaste";
55 m_copiedPoints.
loadXml (reader);
58 CmdPaste::~CmdPaste ()
64 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdPaste::cmdRedo"
65 <<
" pasting=" << m_copiedPoints.
count ();
69 QClipboard *clipboard = QApplication::clipboard();
70 clipboard->setMimeData (&m_mimePoints, QClipboard::Clipboard);
79 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdPaste::cmdUndo"
80 <<
" pasting=" << m_copiedPoints.
count ();
91 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
92 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_PASTE);
93 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
94 m_copiedPoints.
saveXml (writer);
95 writer.writeEndElement();
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
void saveXml(QXmlStreamWriter &writer) const
Serialize table to xml.
void setKeyValue(const QString &pointIdentifier, bool value)
Set key/value pair.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
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.
void loadXml(QXmlStreamReader &reader)
Load from serialized xml.
int count() const
Number of entries.
CmdPaste(MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
Constructor for normal creation.
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
Document & document()
Return the Document that this command will modify during redo and undo.
void resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Since the set of selected points has probably changed, changed that set back to the specified set...
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
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.