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 ();
67 QClipboard *clipboard = QApplication::clipboard();
68 clipboard->setMimeData (&m_mimePoints, QClipboard::Clipboard);
76 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdPaste::cmdUndo" 77 <<
" pasting=" << m_copiedPoints.
count ();
85 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
86 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_PASTE);
87 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
88 m_copiedPoints.
saveXml (writer);
89 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.
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
void setKeyValue(const QString &pointIdentifier, bool value)
Set key/value pair.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
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.
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.