diff options
Diffstat (limited to 'examples/uml')
-rw-r--r-- | examples/uml/duse-mt/mainwindow.cpp | 41 | ||||
-rw-r--r-- | examples/uml/nested-packages/main.cpp | 16 | ||||
-rw-r--r-- | examples/uml/profiles/main.cpp | 2 | ||||
-rw-r--r-- | examples/uml/xmi-read/main.cpp | 8 | ||||
-rw-r--r-- | examples/uml/xmi-write/main.cpp | 4 |
5 files changed, 37 insertions, 34 deletions
diff --git a/examples/uml/duse-mt/mainwindow.cpp b/examples/uml/duse-mt/mainwindow.cpp index 16c2582c..2c19ef45 100644 --- a/examples/uml/duse-mt/mainwindow.cpp +++ b/examples/uml/duse-mt/mainwindow.cpp @@ -60,6 +60,7 @@ #include <QtModeling/QXmiWriter> #include <QtModeling/QXmiReader> #include <QtModeling/QModelingObject> +#include <QtModeling/QModelingElement> #include <QtModeling/QMetaModelPlugin> //#include <QtWrappedObjects/QMetaWrappedObject> #include <QtModelingWidgets/QModelingObjectModel> @@ -228,7 +229,7 @@ void MainWindow::saveXmi(QModelingElement *rootElement) return; } - QXmiWriter writer(rootElement); + QXmiWriter writer(rootElement->asQModelingObject()); setCursor(Qt::WaitCursor); if (!writer.writeFile(&file)) QMessageBox::critical(this, tr("Save As"), tr("Error when writing XMI file !")); @@ -261,11 +262,11 @@ QList<QModelingElement *> MainWindow::loadXmi(QString fileName) void MainWindow::setModelInspector(QList<QModelingElement *> modelingObjectList) { if (!modelingObjectList.isEmpty()) { - _engine.globalObject().setProperty(modelingObjectList.at(0)->asQObject()->objectName(), _engine.newQObject(modelingObjectList.at(0)->asQObject())); + _engine.globalObject().setProperty(modelingObjectList.at(0)->asQModelingObject()->objectName(), _engine.newQObject(modelingObjectList.at(0)->asQModelingObject())); QScriptValue array = _engine.newArray(); foreach (QModelingElement *modelingObject, modelingObjectList) - array.property(QString::fromLatin1("push")).call(array, QScriptValueList() << _engine.newQObject(modelingObject->asQObject())); + array.property(QString::fromLatin1("push")).call(array, QScriptValueList() << _engine.newQObject(modelingObject->asQModelingObject())); _engine.globalObject().setProperty("input", array); ui->txeJavaScript->setText("self"); @@ -273,7 +274,7 @@ void MainWindow::setModelInspector(QList<QModelingElement *> modelingObjectList) } _modelingObjectModel->clear(); foreach (QModelingElement *object, modelingObjectList) - _modelingObjectModel->addModelingObject(object->asQObject()); + _modelingObjectModel->addModelingObject(object->asQModelingObject()); } void MainWindow::on_actionFileOpenModel_triggered() @@ -310,7 +311,7 @@ void MainWindow::on_actionFileNewDuseDesign_triggered() } QXmiReader reader(&_engine, true); QList<QModelingElement *> modelingObjectList = reader.readFile(&file); - if (QString::fromLatin1(modelingObjectList.first()->asQObject()->metaObject()->className()) != QString::fromLatin1("QDuseDesignSpace")) { + if (QString::fromLatin1(modelingObjectList.first()->asQModelingObject()->metaObject()->className()) != QString::fromLatin1("QDuseDesignSpace")) { QMessageBox::critical(this, tr("Create new DuSE design"), QString::fromLatin1("%1 is not a valid DuSE instance !").arg(QFileInfo(file).fileName())); setCursor(Qt::ArrowCursor); return; @@ -329,20 +330,20 @@ void MainWindow::on_actionFileNewDuseDesign_triggered() { \ var length = input[0].profileApplications.length; \ for (var i = 0; i < length; ++i) \ - if (input[0].profileApplications[0].appliedProfile.name == '" + modelingObjectList.first()->asQObject()->objectName() + "Profile') \ + if (input[0].profileApplications[0].appliedProfile.name == '" + modelingObjectList.first()->asQModelingObject()->objectName() + "Profile') \ return true; \ return false; \ } \ checkProfile();"); if (!value.toBool()) { - QMessageBox::critical(this, tr("Create new DuSE design"), QString::fromLatin1("Input model does not contain the required %1Profile profile application !").arg(modelingObjectList.first()->asQObject()->objectName())); + QMessageBox::critical(this, tr("Create new DuSE design"), QString::fromLatin1("Input model does not contain the required %1Profile profile application !").arg(modelingObjectList.first()->asQModelingObject()->objectName())); setCursor(Qt::ArrowCursor); return; } //modelingObjectList.first()->setQmlContextProperties(_metricsQuickView->engine()->rootContext()); - _engine.globalObject().setProperty("designspace", _engine.newQObject(modelingObjectList.at(0)->asQObject())); + _engine.globalObject().setProperty("designspace", _engine.newQObject(modelingObjectList.at(0)->asQModelingObject())); _engine.evaluate("var dimensionsLength = designspace.designDimensions.length; \ for (var dimensionCounter = 0; dimensionCounter < dimensionsLength; ++dimensionCounter) { \ if (designspace.designDimensions[dimensionCounter].instanceSelectionRule) { \ @@ -406,7 +407,7 @@ void MainWindow::on_actionFileSaveAs_triggered() QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), QDir::currentPath(), "XMI files (*.xmi)"); if (!fileName.isEmpty()) { _currentFileName = fileName; - saveXmi(qModelingObject(_modelingObjectModel->modelingObjects().at(0))); + saveXmi(qModelingElement(_modelingObjectModel->modelingObjects().at(0))); } } @@ -415,7 +416,7 @@ void MainWindow::on_actionFileSave_triggered() if (_currentFileName.isEmpty()) on_actionFileSaveAs_triggered(); else - saveXmi(qModelingObject(_modelingObjectModel->modelingObjects().at(0))); + saveXmi(qModelingElement(_modelingObjectModel->modelingObjects().at(0))); } void MainWindow::on_actionHelpAboutPlugins_triggered() @@ -510,7 +511,7 @@ void MainWindow::metaModelChanged(QString newMetaModel) void MainWindow::modelingObjectChanged(QModelingElement *modelingObject) { - _engine.globalObject().setProperty("self", _engine.newQObject(modelingObject->asQObject())); + _engine.globalObject().setProperty("self", _engine.newQObject(modelingObject->asQModelingObject())); } void MainWindow::addToView(QModelingElement *modelingObject, QQuickItem *parent) @@ -520,7 +521,7 @@ void MainWindow::addToView(QModelingElement *modelingObject, QQuickItem *parent) _qmlComponent = new QQmlComponent(_modelQuickView->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(modelingObject->asQObject()->metaObject()->className()).remove(QRegularExpression("^Q"))).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}").arg(QString(modelingObject->asQModelingObject()->metaObject()->className()).remove(QRegularExpression("^Q"))).arg(x).arg(y).toLatin1(), QUrl()); QQuickItem *item = 0; if (_qmlComponent->isError()) { @@ -532,8 +533,8 @@ void MainWindow::addToView(QModelingElement *modelingObject, QQuickItem *parent) } } - foreach (QObject *child, modelingObject->asQObject()->children()) - addToView(dynamic_cast<QModelingElement *>(qModelingObject(child))); + foreach (QObject *child, modelingObject->asQModelingObject()->children()) + addToView(dynamic_cast<QModelingElement *>(qModelingElement(child))); _qmlComponent->deleteLater(); } @@ -545,7 +546,7 @@ void MainWindow::addToDesignSpaceView(QModelingElement *modelingObject, QQuickIt _qmlComponent = new QQmlComponent(_designSpaceQuickView->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(modelingObject->asQObject()->metaObject()->className()).remove(QRegularExpression("^Q"))).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}").arg(QString(modelingObject->asQModelingObject()->metaObject()->className()).remove(QRegularExpression("^Q"))).arg(x).arg(y).toLatin1(), QUrl()); QQuickItem *item = 0; if (_qmlComponent->isError()) { @@ -557,8 +558,8 @@ void MainWindow::addToDesignSpaceView(QModelingElement *modelingObject, QQuickIt } } - foreach (QObject *child, modelingObject->asQObject()->children()) - addToDesignSpaceView(dynamic_cast<QModelingElement *>(qModelingObject(child))); + foreach (QObject *child, modelingObject->asQModelingObject()->children()) + addToDesignSpaceView(dynamic_cast<QModelingElement *>(qModelingElement(child))); _qmlComponent->deleteLater(); } @@ -570,7 +571,7 @@ void MainWindow::addToPareto(QModelingElement *modelingObject, int pos) _qmlComponent = new QQmlComponent(_paretoFrontQuickView->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(modelingObject->asQObject()->metaObject()->className()).remove(QRegularExpression("^Q"))).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}").arg(QString(modelingObject->asQModelingObject()->metaObject()->className()).remove(QRegularExpression("^Q"))).arg(x).arg(y).toLatin1(), QUrl()); QQuickItem *item = 0; if (_qmlComponent->isError()) { @@ -582,8 +583,8 @@ void MainWindow::addToPareto(QModelingElement *modelingObject, int pos) } } - foreach (QObject *child, modelingObject->asQObject()->children()) - addToPareto(dynamic_cast<QModelingElement *>(qModelingObject(child)), pos); + foreach (QObject *child, modelingObject->asQModelingObject()->children()) + addToPareto(dynamic_cast<QModelingElement *>(qModelingElement(child)), pos); _qmlComponent->deleteLater(); } diff --git a/examples/uml/nested-packages/main.cpp b/examples/uml/nested-packages/main.cpp index ce605a7d..307e3295 100644 --- a/examples/uml/nested-packages/main.cpp +++ b/examples/uml/nested-packages/main.cpp @@ -44,19 +44,19 @@ int main () { QUmlComment *c1 = new QUmlComment; - c1->asQObject()->setObjectName("c1"); + c1->asQModelingObject()->setObjectName("c1"); QUmlComment *c2 = new QUmlComment; - c2->asQObject()->setObjectName("c2"); + c2->asQModelingObject()->setObjectName("c2"); QUmlComment *c3 = new QUmlComment; - c3->asQObject()->setObjectName("c3"); + c3->asQModelingObject()->setObjectName("c3"); c3->setBody("c3 body"); c1->setBody("c1 body"); c2->setBody("c2 body"); c1->addOwnedComment(c2); c1->addOwnedComment(c3); - qDebug() << "c2's parent:" << c2->asQObject()->parent()->objectName(); - qDebug() << "c3's parent:" << c3->asQObject()->parent()->objectName(); + qDebug() << "c2's parent:" << c2->asQModelingObject()->parent()->objectName(); + qDebug() << "c3's parent:" << c3->asQModelingObject()->parent()->objectName(); QUmlComment *c4 = dynamic_cast<QUmlComment *>(c1->clone()); qDebug() << "c1 body:" << c4->body(); @@ -67,16 +67,16 @@ int main () qDebug() << "c4 owned comment body:" << comment->body(); //c1->removeOwnedComment(c3); - qDebug() << "c3's parent:" << c3->asQObject()->parent(); + qDebug() << "c3's parent:" << c3->asQModelingObject()->parent(); qDebug() << "Comment size:" << c1->ownedComments().size(); delete c2; //c1->removeOwnedComment(c2); qDebug() << "Comment size:" << c1->ownedComments().size(); - foreach(QObject *c, c1->asQObject()->property("ownedComment").value< QSet<QObject *> >()) + foreach (QObject *c, c1->asQModelingObject()->property("ownedComment").value< QSet<QObject *> >()) qDebug() << c->objectName(); - foreach(QObject *c, c1->asQObject()->property("ownedElement").value< QSet<QObject *> >()) + foreach (QObject *c, c1->asQModelingObject()->property("ownedElement").value< QSet<QObject *> >()) qDebug() << c->objectName(); delete c1; diff --git a/examples/uml/profiles/main.cpp b/examples/uml/profiles/main.cpp index 3ef20ca6..5bf07989 100644 --- a/examples/uml/profiles/main.cpp +++ b/examples/uml/profiles/main.cpp @@ -124,5 +124,7 @@ int main () delete profile; // That will delete all owned elements delete umlModel; // That will delete all owned elements delete extension; // That will delete all owned elements + delete stereotype; // That will delete all owned elements + delete elementImport; // That will delete all owned elements } diff --git a/examples/uml/xmi-read/main.cpp b/examples/uml/xmi-read/main.cpp index ce523d37..fe71a97d 100644 --- a/examples/uml/xmi-read/main.cpp +++ b/examples/uml/xmi-read/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <QtModeling/QXmiReader> #include <QtModeling/QXmiWriter> -#include <QtModeling/QModelingObject> +#include <QtModeling/QModelingElement> #include <QtCore/QFile> #include <QtCore/QDebug> @@ -55,9 +55,9 @@ int main () } QXmiReader reader(0, true); - QList<QModelingObject *> rootElements = reader.readFile(&file); + QList<QModelingElement *> rootElements = reader.readFile(&file); if (!rootElements.isEmpty()) - qDebug() << "Successfully read object with name" << rootElements.first()->asQObject()->objectName(); + qDebug() << "Successfully read object with name" << rootElements.first()->asQModelingObject()->objectName(); if (reader.errorStrings().size() > 0) { qDebug() << "Errors:"; foreach (QString error, reader.errorStrings()) @@ -70,7 +70,7 @@ int main () qDebug() << "Cannot write file !"; return 1; } - QXmiWriter writer(rootElements.first()); + QXmiWriter writer(rootElements.first()->asQModelingObject()); writer.writeFile(&file2); } diff --git a/examples/uml/xmi-write/main.cpp b/examples/uml/xmi-write/main.cpp index 9ee9f898..ee1194fa 100644 --- a/examples/uml/xmi-write/main.cpp +++ b/examples/uml/xmi-write/main.cpp @@ -74,7 +74,7 @@ int main () class2_->setName("InterStudent"); QUmlGeneralization *generalization = new QUmlGeneralization; - generalization->asQObject()->setObjectName("generalization"); + generalization->asQModelingObject()->setObjectName("generalization"); generalization->setGeneral(class_); class2_->addGeneralization(generalization); @@ -92,7 +92,7 @@ int main () return 1; } - QXmiWriter writer(model); + QXmiWriter writer(model->asQModelingObject()); if (writer.writeFile(&file)) qDebug() << "XMI file saved !"; else |