! * copies the aspect to the clipboard. The standard XML-serialization * via AbstractAspect::load() is used. */
| 731 | * via AbstractAspect::load() is used. |
| 732 | */ |
| 733 | void AbstractAspect::copy() { |
| 734 | QString output; |
| 735 | QXmlStreamWriter writer(&output); |
| 736 | writer.writeStartDocument(); |
| 737 | |
| 738 | // add LabPlot's copy&paste "identifier" |
| 739 | writer.writeDTD(QLatin1String("<!DOCTYPE LabPlotCopyPasteXML>")); |
| 740 | writer.writeStartElement(QStringLiteral("copy_content")); // root element |
| 741 | |
| 742 | // write the type of the copied aspect |
| 743 | writer.writeStartElement(QStringLiteral("type")); |
| 744 | writer.writeAttribute(QStringLiteral("value"), QString::number(static_cast<int>(m_type))); |
| 745 | writer.writeEndElement(); |
| 746 | |
| 747 | setSuppressWriteUuid(true); |
| 748 | const auto& children = this->children(AspectType::AbstractAspect, {ChildIndexFlag::IncludeHidden, ChildIndexFlag::Recursive}); |
| 749 | for (const auto& child : children) |
| 750 | child->setSuppressWriteUuid(true); |
| 751 | |
| 752 | // write the aspect itself |
| 753 | save(&writer); |
| 754 | |
| 755 | for (const auto& child : children) |
| 756 | child->setSuppressWriteUuid(false); |
| 757 | setSuppressWriteUuid(false); |
| 758 | |
| 759 | writer.writeEndElement(); // end the root-element |
| 760 | writer.writeEndDocument(); |
| 761 | QApplication::clipboard()->setText(output); |
| 762 | } |
| 763 | |
| 764 | /*! |
| 765 | * duplicates the aspect in the project hierarchy, the copy of the duplicated aspect is |
nothing calls this directly
no test coverage detected