QSysMLAction::QSysMLAction(const QMap<QString, QVariant> &properties, QGraphicsItem *parent) : QAbstractDiagramShape(QSysMLPlugin::staticName(), QSysMLAction::staticItemClass(), properties, parent) { initGeometry(400, 300); textItem()->setTextColorProperty("textColor"); textItem()->setTextProperty("name"); textItem()->setDefaultTextAlignment(Qt::AlignCenter); addProperty("actionType", QDiagramToolkit::String, true, properties.value("actionType")); addProperty("background", QDiagramToolkit::Brush, false, properties.value("background", QColor("wheat"))); addProperty("textColor", QDiagramToolkit::Color, false, properties.value("textColor", QColor("black"))); addProperty("textFont", QDiagramToolkit::Font, false, properties.value("textFont")); addProperty("lineStyle", QDiagramToolkit::Pen, false, properties.value("lineStyle")); addProperty("name", QDiagramToolkit::String, false, "action"); addSizeGripHandle(new QDiagramShapeSizeGripHandle(QDiagramShapeSizeGripHandle::Left, this)); addSizeGripHandle(new QDiagramShapeSizeGripHandle(QDiagramShapeSizeGripHandle::Right, this)); addConnectionPoint(new QSysMLControlConnectionPointIn(this, "controlIn", 0, 1)); addConnectionPoint(new QSysMLControlConnectionPointOut(this, "controlOut", 0, 1)); addConnectionPoint(new QSysMLDataConnectionPointIn(this, "dataIn1", 0, 1)); addConnectionPoint(new QSysMLDataConnectionPointOut(this, "dataOut1", 0, 1)); restoreProperties(properties); }
QSysMLBlock::QSysMLBlock(const QMap<QString, QVariant> &properties, QGraphicsItem *parent) : QAbstractDiagramShape(QSysMLPlugin::staticName(), QSysMLBlock::staticItemClass(), properties, parent) { initGeometry(400, 300); addProperty("blockType", QDiagramToolkit::String, true, properties.value("blockType")); addProperty("backgroundColor", QDiagramToolkit::Color, false, QColor("white")); addProperty("name", QDiagramToolkit::String, false, "action"); addProperty("textFont", QDiagramToolkit::Font, false, properties.value("textFont")); addSizeGripHandle(new QDiagramShapeSizeGripHandle(QDiagramShapeSizeGripHandle::Left, this)); addSizeGripHandle(new QDiagramShapeSizeGripHandle(QDiagramShapeSizeGripHandle::Right, this)); addConnectionPoint(new QSysMLControlConnectionPointIn(this, "controlIn", 0, 1)); addConnectionPoint(new QSysMLControlConnectionPointOut(this, "controlOut", 0, 1)); addConnectionPoint(new QSysMLDataConnectionPointIn(this, "dataIn1", 0, 1)); addConnectionPoint(new QSysMLDataConnectionPointOut(this, "dataOut1", 0, 1)); restoreProperties(properties); }
bool EnhancedPathShape::loadOdf(const KXmlElement & element, KShapeLoadingContext &context) { reset(); loadOdfAttributes(element, context, OdfAdditionalAttributes | OdfCommonChildElements); const KXmlElement enhancedGeometry(KoXml::namedItemNS(element, KOdfXmlNS::draw, "enhanced-geometry" ) ); if (!enhancedGeometry.isNull()) { // load the modifiers QString modifiers = enhancedGeometry.attributeNS(KOdfXmlNS::draw, "modifiers"); if (!modifiers.isEmpty()) { addModifiers(modifiers); } KXmlElement grandChild; forEachElement(grandChild, enhancedGeometry) { if (grandChild.namespaceURI() != KOdfXmlNS::draw) continue; if (grandChild.localName() == "equation") { QString name = grandChild.attributeNS(KOdfXmlNS::draw, "name"); QString formula = grandChild.attributeNS(KOdfXmlNS::draw, "formula"); addFormula(name, formula); } else if (grandChild.localName() == "handle") { EnhancedPathHandle * handle = new EnhancedPathHandle(this); if (handle->loadOdf(grandChild, context)) { m_enhancedHandles.append(handle); evaluateHandles(); } else { delete handle; } } } setMirrorHorizontally(enhancedGeometry.attributeNS(KOdfXmlNS::draw, "mirror-horizontal") == "true"); setMirrorVertically(enhancedGeometry.attributeNS(KOdfXmlNS::draw, "mirror-vertical") == "true"); // load the enhanced path data QString path = enhancedGeometry.attributeNS(KOdfXmlNS::draw, "enhanced-path"); #ifndef NWORKAROUND_ODF_BUGS KOdfWorkaround::fixEnhancedPath(path, enhancedGeometry, context); #endif if (!path.isEmpty()) { parsePathData(path); } // load the viewbox QRectF viewBox = loadOdfViewbox(enhancedGeometry); if (! viewBox.isEmpty()) { m_viewBox = viewBox; } else { // if there is no view box defined make it is big as the path. m_viewBox = m_viewBound; } QString gluePoints(enhancedGeometry.attributeNS(KOdfXmlNS::draw, "glue-points")); if (!gluePoints.isEmpty()) { qreal x = -1; foreach (const QString &token, gluePoints.split(' ')) { if (x == -1) { // processing 'x' x = token.toInt(); } else { addConnectionPoint(QPointF(x, token.toInt())); x = -1; } } }