void QXmlTreeView::pasteNode() { QXmlTreeModel* treeModel = static_cast<QXmlTreeModel*>(model()); if( !treeModel ) return; QXmlTreeNode* xmlNode = treeModel->rootNode(); if (currentIndex().isValid()) xmlNode = static_cast<QXmlTreeNode*>(currentIndex().internalPointer()); const QMimeData* mime = QApplication::clipboard()->mimeData();; if (mime->hasFormat("text/plain")) { QDomDocument dom("Paste"); if (dom.setContent(mime->data("text/plain"))) treeModel->undoStack()->push(createAddUndoCommand(dom.documentElement(), xmlNode->xmlNode(), treeModel, tr("Paste nodes"))); } }
void AttachmentTreeView::addSound3DComponent() { AttachmentTreeModel* model = qobject_cast<AttachmentTreeModel*>(QAbstractItemView::model()); model->undoStack()->push(createAddUndoCommand(QDomDocument().createElement("Sound3D"), model->rootNode()->xmlNode(), model, tr("Add Sound3D Component"))); setCurrentIndex(model->index( model->rowCount(), 0)); }
void AttachmentTreeView::addDynamidComponent() { AttachmentTreeModel* model = qobject_cast<AttachmentTreeModel*>(QAbstractItemView::model()); model->undoStack()->push(createAddUndoCommand(QDomDocument().createElement("Dynamid"), model->rootNode()->xmlNode(), model, tr("Add Dynamid Component"))); }