QPair<QVariant, RPropertyAttributes> REntity::getProperty( RPropertyTypeId propertyTypeId, bool humanReadable, bool noAttributes) { if (propertyTypeId == PropertyType) { return qMakePair(QVariant(RS::EntityUnknown), RPropertyAttributes()); } else if (propertyTypeId == PropertyBlock) { return qMakePair(QVariant(getData().getBlockId()), RPropertyAttributes()); }else if (propertyTypeId == PropertyLayer) { if (humanReadable) { RDocument* document = getData().getDocument(); if (document != NULL) { RPropertyAttributes attr; if (!noAttributes) { // TODO: filter out locked layers: attr.setChoices(document->getLayerNames()); } return qMakePair(QVariant(document->getLayerName( getData().getLayerId())), attr); } } else { return qMakePair(QVariant(getData().getLayerId()), RPropertyAttributes()); } } else if (propertyTypeId == PropertyLinetype) { if (humanReadable) { RDocument* document = getData().getDocument(); if (document != NULL) { QVariant var; QSharedPointer<RLinetype> linetype = document->queryLinetype( getData().getLinetypeId()); var.setValue<RLinetype> (*linetype.data()); return qMakePair(var, RPropertyAttributes()); } } else { return qMakePair(QVariant(getData().getLinetypeId()), RPropertyAttributes()); } } else if (propertyTypeId == PropertyLineweight) { QVariant v; v.setValue<RLineweight::Lineweight>(getData().getLineweight()); return qMakePair(v, RPropertyAttributes()); } else if (propertyTypeId == PropertyColor) { QVariant var; var.setValue<RColor> (getData().getColor()); return qMakePair(var, RPropertyAttributes()); } else if (propertyTypeId == PropertyDrawOrder) { return qMakePair(QVariant(getData().getDrawOrder()), RPropertyAttributes()); } return RObject::getProperty(propertyTypeId, humanReadable, noAttributes); }
QPair<QVariant, RPropertyAttributes> REntity::getProperty( RPropertyTypeId& propertyTypeId, bool humanReadable, bool noAttributes) { if (propertyTypeId == PropertyType) { return qMakePair(QVariant(getType()), RPropertyAttributes()); } else if (propertyTypeId == PropertyBlock) { return qMakePair(QVariant(getData().getBlockId()), RPropertyAttributes()); } else if (propertyTypeId == PropertyLayer) { if (humanReadable) { RDocument* document = getData().getDocument(); if (document != NULL) { RPropertyAttributes attr; if (!noAttributes) { // TODO: filter out locked layers: attr.setChoices(document->getLayerNames()); } return qMakePair(QVariant(document->getLayerName( getData().getLayerId())), attr); } } else { return qMakePair(QVariant(getData().getLayerId()), RPropertyAttributes()); } } else if (propertyTypeId == PropertyLinetype) { if (humanReadable) { RDocument* document = getData().getDocument(); if (document != NULL) { RPropertyAttributes attr; // if (!noAttributes) { // attr.setChoices(document->getLinetypeNames()); // } QString desc = document->getLinetypeLabel(getData().getLinetypeId()); return qMakePair(QVariant(desc), attr); } } else { return qMakePair(QVariant(getData().getLinetypeId()), RPropertyAttributes()); } } else if (propertyTypeId == PropertyLinetypeScale) { return qMakePair(QVariant(getData().getLinetypeScale()), RPropertyAttributes()); } else if (propertyTypeId == PropertyLineweight) { QVariant v; v.setValue<RLineweight::Lineweight>(getData().getLineweight()); return qMakePair(v, RPropertyAttributes()); } else if (propertyTypeId == PropertyColor) { QVariant var; var.setValue<RColor> (getData().getColor()); return qMakePair(var, RPropertyAttributes()); } else if (propertyTypeId == PropertyDisplayedColor) { QVariant var; QStack<REntity*> stack; var.setValue<RColor> (getData().getColor(true, stack)); return qMakePair(var, RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertyDrawOrder) { return qMakePair(QVariant(getData().getDrawOrder()), RPropertyAttributes()); } else if (propertyTypeId == PropertyMinX) { return qMakePair(QVariant(getBoundingBox().getMinimum().x), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertyMinY) { return qMakePair(QVariant(getBoundingBox().getMinimum().y), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertyMaxX) { return qMakePair(QVariant(getBoundingBox().getMaximum().x), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertyMaxY) { return qMakePair(QVariant(getBoundingBox().getMaximum().y), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertySizeX) { return qMakePair(QVariant(getBoundingBox().getWidth()), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } else if (propertyTypeId == PropertySizeY) { return qMakePair(QVariant(getBoundingBox().getHeight()), RPropertyAttributes(RPropertyAttributes::ReadOnly)); } return RObject::getProperty(propertyTypeId, humanReadable, noAttributes); }
QSharedPointer<RLayer> RClipboardOperation::copyLayer( RLayer::Id layerId, RDocument& src, RDocument& dest, bool overwriteLayers, RTransaction& transaction) const { // copy parent layers: QString layerName = src.getLayerName(layerId); if (layerName.contains(" ... ")) { QStringList l = layerName.split(" ... "); l.removeLast(); while (!l.isEmpty()) { QString parentLayerName = l.join(" ... "); QSharedPointer<RLayer> parentLayer = src.queryLayer(parentLayerName); if (!parentLayer.isNull()) { copyLayer(parentLayer->getId(), src, dest, overwriteLayers, transaction); } else { qWarning() << "parent layer of layer '" << layerName << "' not found: " << parentLayerName; } l.removeLast(); } } bool overwriteLinetypes = false; // add layer the entity is on, if the layer exists it is overwritten // if overwriteLayers is true: QSharedPointer<RLayer> srcLayer = src.queryLayer(layerId); if (srcLayer.isNull()) { qWarning("RClipboardOperation::copyLayer: " "layer is NULL."); return QSharedPointer<RLayer>(); } QSharedPointer<RLinetype> destLinetype = copyLinetype(srcLayer->getLinetypeId(), src, dest, overwriteLinetypes, transaction); QString srcLayerName = srcLayer->getName(); QSharedPointer<RLayer> destLayer; if (copiedLayers.contains(srcLayerName)) { destLayer = copiedLayers.value(srcLayerName); Q_ASSERT(!destLayer.isNull()); } else { if (!dest.hasLayer(srcLayerName) || overwriteLayers) { destLayer = QSharedPointer<RLayer>(srcLayer->clone()); destLayer->setDocument(&dest); if (destLayer->getDocument()!=srcLayer->getDocument()) { dest.getStorage().setObjectId(*destLayer.data(), RObject::INVALID_ID); dest.getStorage().setObjectHandle(*destLayer.data(), RObject::INVALID_HANDLE); } transaction.addObject(destLayer); } else { destLayer = dest.queryLayer(srcLayerName); Q_ASSERT(!destLayer.isNull()); } copiedLayers.insert(srcLayerName, destLayer); } if (!destLinetype.isNull()) { destLayer->setLinetypeId(destLinetype->getId()); } return destLayer; }