diff options
author | Sandro S. Andrade <sandroandrade@kde.org> | 2013-11-16 20:32:22 -0300 |
---|---|---|
committer | Sandro S. Andrade <sandroandrade@kde.org> | 2013-11-17 00:28:13 +0100 |
commit | 48d19821a52312b18b9b80ff81679cc4ab224f9e (patch) | |
tree | 393ddb7edd5d6273022335e9de1e73cf9078cc25 /examples/uml/duse-mt/src | |
parent | 7d079325d62bcdf24d46ed5cbb86aa20e82fa0e5 (diff) |
Add implementation of new Association QML item
Change-Id: I5c5527ffcf47d2e91691aed055d5aff66e09a887
Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'examples/uml/duse-mt/src')
4 files changed, 22 insertions, 6 deletions
diff --git a/examples/uml/duse-mt/src/plugins/concretesyntaxview/concretesyntaxviewplugin.cpp b/examples/uml/duse-mt/src/plugins/concretesyntaxview/concretesyntaxviewplugin.cpp index 51576ad5..f90e57cd 100644 --- a/examples/uml/duse-mt/src/plugins/concretesyntaxview/concretesyntaxviewplugin.cpp +++ b/examples/uml/duse-mt/src/plugins/concretesyntaxview/concretesyntaxviewplugin.cpp @@ -78,14 +78,14 @@ void ConcreteSyntaxViewPlugin::addToView(QObject *selectedModelingObject, QQuick QQmlComponent *qmlComponent = new QQmlComponent(_concreteSyntaxQuickView->engine()); int x = qrand() % 400; int y = qrand() % 400; - qmlComponent->setData(QString("import QtQuick 2.0\nimport QtModeling.Uml 1.0\n\n%1 { x: %2; y: %3}").arg(QString(selectedModelingObject->metaObject()->className()).remove(QRegularExpression("^Q")).remove(QRegularExpression("Object$"))).arg(x).arg(y).toLatin1(), QUrl()); + qmlComponent->setData(QString("import QtQuick 2.0\nimport QtModeling.Uml 1.0\n\n%1 { x: %2; y: %3; objectName: \"%4\" }").arg(QString(selectedModelingObject->metaObject()->className()).remove(QRegularExpression("^Q")).remove(QRegularExpression("Object$"))).arg(x).arg(y).arg(selectedModelingObject->objectName()).toLatin1(), QUrl()); - QQuickItem *item = 0; if (qmlComponent->isError()) { qWarning() << qmlComponent->errors(); } else { - item = qobject_cast<QQuickItem *>(qmlComponent->create(context)); + QQuickItem *item = qobject_cast<QQuickItem *>(qmlComponent->create(context)); if (item) { + item->setParent(parent ? parent:(qobject_cast<QQuickFlickable *>(_concreteSyntaxQuickView->rootObject()))->contentItem()); item->setParentItem(parent ? parent:(qobject_cast<QQuickFlickable *>(_concreteSyntaxQuickView->rootObject()))->contentItem()); } } diff --git a/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/qmldir b/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/qmldir index ddc74ca3..105ea978 100644 --- a/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/qmldir +++ b/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/qmldir @@ -4,3 +4,5 @@ internal UmlSlot UmlSlot.qml UmlClass 1.0 UmlClass.qml UmlComponent 1.0 UmlComponent.qml UmlProperty 1.0 UmlProperty.qml +UmlAssociation 1.0 UmlAssociation.qml +plugin qtmodelingumlplugin diff --git a/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/qmlplugin.pro b/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/qmlplugin.pro index c6432afd..27668cf7 100644 --- a/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/qmlplugin.pro +++ b/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/qmlplugin.pro @@ -7,21 +7,28 @@ TARGET = qtmodelingumlplugin TARGETPATH = QtModeling/Uml +QT += quick-private + # Qml QML_FILES = \ UmlElement.qml \ UmlSlot.qml \ UmlClass.qml \ UmlComponent.qml \ - UmlProperty.qml + UmlProperty.qml \ + UmlAssociation.qml # Images QML_FILES += \ images/resize-mark.png \ -HEADERS += umlconcretesyntaxqmlplugin.h +HEADERS += \ + umlconcretesyntaxqmlplugin.h \ + relationshipitem.h -SOURCES += umlconcretesyntaxqmlplugin.cpp +SOURCES += \ + umlconcretesyntaxqmlplugin.cpp \ + relationshipitem.cpp CONFIG += no_cxx_module load(qml_plugin) diff --git a/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/umlconcretesyntaxqmlplugin.cpp b/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/umlconcretesyntaxqmlplugin.cpp index dd09e3d2..e640fcd0 100644 --- a/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/umlconcretesyntaxqmlplugin.cpp +++ b/examples/uml/duse-mt/src/plugins/umlconcretesyntax/qmlplugin/umlconcretesyntaxqmlplugin.cpp @@ -40,7 +40,14 @@ ****************************************************************************/ #include "umlconcretesyntaxqmlplugin.h" +#include <QtQml/QQmlEngine> + +#include "relationshipitem.h" + void UmlConcreteSyntaxQmlPlugin::registerTypes(const char *uri) { + Q_ASSERT(uri == QLatin1String("QtModeling.Uml")); + // @uri QtModeling.Uml + qmlRegisterType<RelationshipItem>(uri, 1, 0, "Relationship"); } |