diff options
author | Sandro S. Andrade <sandroandrade@kde.org> | 2013-10-30 16:57:43 -0300 |
---|---|---|
committer | Sandro S. Andrade <sandroandrade@kde.org> | 2013-10-30 21:02:02 +0100 |
commit | e064f1f21ee5739fc65fc11213be962a3fb6f963 (patch) | |
tree | 21e7fba9cc035be836cd832b5a53bead7609485c /examples/uml/duse-mt/src/plugins | |
parent | 5ecf52ae725c7b7154a8c84c5918b11f15287d84 (diff) |
Move further design space functionality from core to plugin
Change-Id: I011d6174063a479122a920eb27ba52a54623e65a
Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'examples/uml/duse-mt/src/plugins')
6 files changed, 382 insertions, 3 deletions
diff --git a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorer.pro b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorer.pro index c75d760f..2f25d194 100644 --- a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorer.pro +++ b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorer.pro @@ -4,11 +4,17 @@ # #------------------------------------------------- +QT += widgets + include(../../duse-mt-plugin.pri) -SOURCES += designspaceexplorerplugin.cpp +SOURCES += designspaceexplorerplugin.cpp \ + newdusedesigndialog.cpp + +HEADERS += designspaceexplorerplugin.h \ + newdusedesigndialog.h -HEADERS += designspaceexplorerplugin.h +FORMS += newdusedesigndialog.ui RESOURCES += qml/designspaceexplorer.qrc diff --git a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.cpp b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.cpp index b16c8ed1..2a3bb396 100644 --- a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.cpp +++ b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.cpp @@ -44,16 +44,32 @@ #include <QtQuick/QQuickView> +#include <QtWidgets/QAction> #include <QtWidgets/QWidget> #include <QtWidgets/QHeaderView> #include <QtWidgets/QTableWidget> +#include <QtWidgets/QApplication> +#include <QtWidgets/QMessageBox> + +#include <QtCore/QFileInfo> + +#include <QtModeling/QXmiReader> +#include <QtModeling/QModelingElement> + +#include "newdusedesigndialog.h" DesignSpaceExplorerPlugin::DesignSpaceExplorerPlugin(QObject *parent) : DuSE::IPlugin(parent), _currentDesignSpaceLocationQuickView(new QQuickView), _metricsQuickView(new QQuickView), - _designSpaceExplorer(new QTableWidget) + _designSpaceExplorer(new QTableWidget), + _newDuseDesignDialog(new NewDuseDesignDialog) +{ +} + +DesignSpaceExplorerPlugin::~DesignSpaceExplorerPlugin() { + delete _newDuseDesignDialog; } bool DesignSpaceExplorerPlugin::initialize(DuSE::ICore *core) @@ -81,6 +97,116 @@ bool DesignSpaceExplorerPlugin::initialize(DuSE::ICore *core) core->uiController()->addDockWidget(Qt::RightDockWidgetArea, "Design Space Explorer", _designSpaceExplorer); + QString iconThemeName; + + QAction *_actionFileNewDuseDesign = new QAction(0); + _actionFileNewDuseDesign->setText(QApplication::translate("MainWindow", "New &DuSE Design ...", 0)); + _actionFileNewDuseDesign->setShortcut(QApplication::translate("MainWindow", "Ctrl+D", 0)); + _actionFileNewDuseDesign->setObjectName(QStringLiteral("actionFileNewDuseDesign")); + QIcon icon8; + iconThemeName = QStringLiteral("document-new"); + if (QIcon::hasThemeIcon(iconThemeName)) { + icon8 = QIcon::fromTheme(iconThemeName); + } else { + icon8.addFile(QStringLiteral(""), QSize(), QIcon::Normal, QIcon::Off); + } + _actionFileNewDuseDesign->setIcon(icon8); + connect(_actionFileNewDuseDesign, &QAction::triggered, this, &DesignSpaceExplorerPlugin::newDuseDesign); + core->uiController()->addAction(_actionFileNewDuseDesign, "menu_File"); + + QAction *_actionFileOpenDuseDesign = new QAction(0); + _actionFileOpenDuseDesign->setText(QApplication::translate("MainWindow", "Open DuSE Design ...", 0)); + _actionFileOpenDuseDesign->setShortcut(QApplication::translate("MainWindow", "Ctrl+U", 0)); + _actionFileOpenDuseDesign->setObjectName(QStringLiteral("actionFileOpenDuseDesign")); + QIcon icon9; + iconThemeName = QStringLiteral("document-open"); + if (QIcon::hasThemeIcon(iconThemeName)) { + icon9 = QIcon::fromTheme(iconThemeName); + } else { + icon9.addFile(QStringLiteral(""), QSize(), QIcon::Normal, QIcon::Off); + } + _actionFileOpenDuseDesign->setIcon(icon9); + connect(_actionFileOpenDuseDesign, &QAction::triggered, this, &DesignSpaceExplorerPlugin::openDuseDesign); + core->uiController()->addAction(_actionFileOpenDuseDesign, "menu_File"); + return true; } +void DesignSpaceExplorerPlugin::newDuseDesign() +{ + do { + if (_newDuseDesignDialog->exec() == QDialog::Accepted) { + if (_newDuseDesignDialog->_inputModelFileName.isEmpty() || _newDuseDesignDialog->_duseInstanceModelFileName.isEmpty()) { + 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); + 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; +// } + + //modelingObjectList.first()->setQmlContextProperties(_metricsQuickView->engine()->rootContext()); + +// _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) { \ +// var selected = eval(designspace.designDimensions[dimensionCounter].instanceSelectionRule); \ +// var selectedLength = selected.length; \ +// for (var selectedCounter = 0; selectedCounter < selectedLength; ++selectedCounter) { \ +// var dimensionInstance = new QDuseDesignDimensionInstance(); \ +// dimensionInstance.objectName = selected[selectedCounter].name; \ +// designspace.designDimensions[dimensionCounter].addDesignDimensionInstance(dimensionInstance); \ +// } \ +// } \ +// }"); + + +// evaluateQualityMetrics(); +// populateDesignSpaceView(modelingObjectList.at(0)); + +// setCursor(Qt::ArrowCursor); + } + } + else + return; + } while (_newDuseDesignDialog->_inputModelFileName.isEmpty() || _newDuseDesignDialog->_duseInstanceModelFileName.isEmpty()); +} + +void DesignSpaceExplorerPlugin::openDuseDesign() +{ +} + diff --git a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.h b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.h index c42eb18b..950edc54 100644 --- a/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.h +++ b/examples/uml/duse-mt/src/plugins/designspaceexplorer/designspaceexplorerplugin.h @@ -43,6 +43,8 @@ #include <interfaces/iplugin.h> +class NewDuseDesignDialog; + class QQuickView; class QTableWidget; @@ -53,13 +55,20 @@ class DesignSpaceExplorerPlugin : public DuSE::IPlugin public: DesignSpaceExplorerPlugin(QObject *parent = 0); + virtual ~DesignSpaceExplorerPlugin(); virtual bool initialize(DuSE::ICore *core); +private Q_SLOTS: + void newDuseDesign(); + void openDuseDesign(); + private: QQuickView *_currentDesignSpaceLocationQuickView; QQuickView *_metricsQuickView; QTableWidget *_designSpaceExplorer; + + NewDuseDesignDialog *_newDuseDesignDialog; }; #endif // DESIGNSPACEEXPLORERPLUGIN_H diff --git a/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.cpp b/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.cpp new file mode 100644 index 00000000..81eb11e3 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade <sandroandrade@kde.org> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "newdusedesigndialog.h" +#include "ui_newdusedesigndialog.h" + +#include <QtWidgets/QFileDialog> + +NewDuseDesignDialog::NewDuseDesignDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::NewDuseDesignDialog) +{ + ui->setupUi(this); +} + +NewDuseDesignDialog::~NewDuseDesignDialog() +{ + delete ui; +} + +void NewDuseDesignDialog::on_tbtInputModel_clicked() +{ + _inputModelFileName = QFileDialog::getOpenFileName(this, tr("Open input model"), QDir::currentPath(), "XMI files (*.xmi)"); + ui->lneInputModel->setText(_inputModelFileName); +} + +void NewDuseDesignDialog::on_tbtDuseInstanceModel_clicked() +{ + _duseInstanceModelFileName = QFileDialog::getOpenFileName(this, tr("Open DuSE instance model"), QDir::currentPath(), "XMI files (*.xmi)"); + ui->lneDuseInstanceModel->setText(_duseInstanceModelFileName); +} diff --git a/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.h b/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.h new file mode 100644 index 00000000..4a63f8aa --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade <sandroandrade@kde.org> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef NEWDUSEDESIGNDIALOG_H +#define NEWDUSEDESIGNDIALOG_H + +#include <QtWidgets/QDialog> + +namespace Ui { +class NewDuseDesignDialog; +} + +class NewDuseDesignDialog : public QDialog +{ + Q_OBJECT + +public: + explicit NewDuseDesignDialog(QWidget *parent = 0); + ~NewDuseDesignDialog(); + + QString _inputModelFileName; + QString _duseInstanceModelFileName; +private Q_SLOTS: + void on_tbtInputModel_clicked(); + void on_tbtDuseInstanceModel_clicked(); + +private: + Ui::NewDuseDesignDialog *ui; +}; + +#endif // NEWDUSEDESIGNDIALOG_H diff --git a/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.ui b/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.ui new file mode 100644 index 00000000..a2b3de08 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/designspaceexplorer/newdusedesigndialog.ui @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>NewDuseDesignDialog</class> + <widget class="QDialog" name="NewDuseDesignDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>453</width> + <height>127</height> + </rect> + </property> + <property name="windowTitle"> + <string>Create new DuSE design</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="lblInputModel"> + <property name="text"> + <string>Input model:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="lneInputModel"/> + </item> + <item row="0" column="2"> + <widget class="QToolButton" name="tbtInputModel"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="lblDuseInstanceModel"> + <property name="text"> + <string>DuSE instance model:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="lneDuseInstanceModel"/> + </item> + <item row="1" column="2"> + <widget class="QToolButton" name="tbtDuseInstanceModel"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>NewDuseDesignDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>NewDuseDesignDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> |