diff options
author | Sandro S. Andrade <sandroandrade@kde.org> | 2013-11-21 17:08:36 -0300 |
---|---|---|
committer | Sandro S. Andrade <sandroandrade@kde.org> | 2013-11-21 21:13:11 +0100 |
commit | f452e43727226e6ec70d4271914be483035c9831 (patch) | |
tree | 63158d03570265b901f9f52924d9eb8f5cb96f49 | |
parent | c14df4c277d17fd2c23ca53413adcead1c2b2c76 (diff) |
Add initial implementation of design space explorer
Change-Id: I5cd473401433000267c3d157dd7271103f33929c
Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
5 files changed, 37 insertions, 28 deletions
diff --git a/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp b/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp index 78e77b4e..e95e9855 100644 --- a/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp +++ b/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp @@ -74,6 +74,11 @@ QString ProjectController::currentModelFileName() const return _currentModelFileName; } +QList<QModelingObject *> ProjectController::currentModelObjects() const +{ + return _currentModelObjects; +} + bool ProjectController::openModel(const QString &fileName) { qDeleteAll(_currentModelElements); diff --git a/examples/uml/duse-mt/src/app/shell/projectcontroller.h b/examples/uml/duse-mt/src/app/shell/projectcontroller.h index 4cd26549..bc161cdd 100644 --- a/examples/uml/duse-mt/src/app/shell/projectcontroller.h +++ b/examples/uml/duse-mt/src/app/shell/projectcontroller.h @@ -58,6 +58,7 @@ public: virtual QStringList errorStrings() const; virtual QString currentModelFileName() const; + virtual QList<QModelingObject *> currentModelObjects() const; public Q_SLOTS: virtual bool openModel(const QString &fileName); diff --git a/examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h b/examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h index 7fb2b74c..551038f8 100644 --- a/examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h +++ b/examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h @@ -64,6 +64,7 @@ public: virtual QStringList errorStrings() const = 0; virtual QString currentModelFileName() const = 0; + virtual QList<QModelingObject *> currentModelObjects() const = 0; public Q_SLOTS: virtual bool openModel(const QString &fileName) = 0; diff --git a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.cpp b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.cpp index 8d8619b7..994478e4 100644 --- a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.cpp +++ b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.cpp @@ -41,6 +41,7 @@ #include "designspaceexplorerplugin.h" #include <duseinterfaces/iuicontroller.h> +#include <duseinterfaces/iprojectcontroller.h> #include <QtQuick/QQuickView> @@ -74,6 +75,8 @@ DesignSpaceExplorerPlugin::~DesignSpaceExplorerPlugin() bool DesignSpaceExplorerPlugin::initialize(DuSE::ICore *core) { + _core = core; + _currentDesignSpaceLocationQuickView->setSource(QUrl("qrc:/designspaceexplorer/currentdesignspacelocation.qml")); _currentDesignSpaceLocationQuickView->setResizeMode(QQuickView::SizeRootObjectToView); @@ -140,43 +143,33 @@ void DesignSpaceExplorerPlugin::newDuseDesign() QMessageBox::critical(0, tr("Create new DuSE design"), tr("You should select an input model and a DuSE instance model !")); } else { -// setCursor(Qt::WaitCursor); - QFile file(_newDuseDesignDialog->_duseInstanceModelFileName); if (!file.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::critical(0, tr("Create new DuSE design"), tr("Cannot read DuSE instance file !")); -// setCursor(Qt::ArrowCursor); return; } QXmiReader reader; - QList<QModelingElement *> modelingObjectList = reader.readFile(&file); - if (QString::fromLatin1(modelingObjectList.first()->asQModelingObject()->metaObject()->className()) != QString::fromLatin1("QDuseDesignSpace")) { - QMessageBox::critical(0, tr("Create new DuSE design"), QString::fromLatin1("%1 is not a valid DuSE instance !").arg(QFileInfo(file).fileName())); -// setCursor(Qt::ArrowCursor); + _duseInstance = reader.readFile(&file); + if (QString::fromLatin1(_duseInstance.first()->asQModelingObject()->metaObject()->className()) != QStringLiteral("QDuseDesignSpaceObject")) { + QMessageBox::critical(0, tr("Create new DuSE design"), QStringLiteral("%1 is not a valid DuSE instance !").arg(QFileInfo(file).fileName())); + return; + } + + if (!_core->projectController()->openModel(_newDuseDesignDialog->_inputModelFileName)) { + QMessageBox::critical(0, tr("Create new DuSE design"), QStringLiteral("Error loading input file %1 !").arg(_newDuseDesignDialog->_inputModelFileName)); return; } -// _currentFileName = _newDuseDesign->_inputModelFileName; -// foreach (QWrappedObject *object, _inputModel) -// delete object; -// _inputModel = loadXmi(_currentFileName); - -// addToView(_inputModel[0]); - -// QScriptValue value = _engine.evaluate("function checkProfile() \ -// { \ -// var length = input[0].profileApplications.length; \ -// for (var i = 0; i < length; ++i) \ -// 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()->asQModelingObject()->objectName())); -// setCursor(Qt::ArrowCursor); -// return; -// } + bool found = false; + foreach (QObject *profileApplication, _core->projectController()->currentModelObjects().first()->property("profileApplications").value< QSet<QObject *> >()) { + if ((profileApplication->property("appliedProfile").value<QObject *>())->property("name").toString() == _duseInstance.first()->asQModelingObject()->objectName() + QStringLiteral("Profile")) + found = true; + } + + if (!found) { + QMessageBox::critical(0, tr("Create new DuSE design"), QStringLiteral("Input model does not contain the required %1Profile profile application !").arg(_duseInstance.first()->asQModelingObject()->objectName())); + return; + } //modelingObjectList.first()->setQmlContextProperties(_metricsQuickView->engine()->rootContext()); diff --git a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.h b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.h index 8919830e..e24a7fff 100644 --- a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.h +++ b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.h @@ -48,6 +48,12 @@ class NewDuseDesignDialog; class QQuickView; class QTableWidget; +class QModelingElement; + +namespace Duse { + class ICore; +} + class DesignSpaceExplorerPlugin : public DuSE::IPlugin { Q_OBJECT @@ -64,11 +70,14 @@ private Q_SLOTS: void openDuseDesign(); private: + DuSE::ICore *_core; + QQuickView *_currentDesignSpaceLocationQuickView; QQuickView *_metricsQuickView; QTableWidget *_designSpaceExplorer; NewDuseDesignDialog *_newDuseDesignDialog; + QList<QModelingElement *> _duseInstance; }; #endif // DESIGNSPACEEXPLORERPLUGIN_H |