diff options
author | Sandro S. Andrade <[email protected]> | 2014-10-28 11:22:22 -0300 |
---|---|---|
committer | Sandro S. Andrade <[email protected]> | 2014-10-28 15:24:07 +0100 |
commit | 63b4ed0994341b1342eeec6c543f7eb0cfe61b66 (patch) | |
tree | c6324a63ba1c25efa06da975af7062f4637be9d4 /examples/uml/duse-mt/src/app/shell | |
parent | 001a7e58fcaa2b8c149b8e4a223c8d5f097c0ef9 (diff) |
New DuSE-MT location: [email protected]:duse-mt/duse-mt.git
Change-Id: I4f3e65542703e39a54d20fa2c418fc61a1dca59c
Reviewed-by: Sandro S. Andrade <[email protected]>
Diffstat (limited to 'examples/uml/duse-mt/src/app/shell')
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/core.cpp | 120 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/core.h | 75 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/mainwindow.cpp | 410 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/mainwindow.h | 134 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/plugincontroller.cpp | 179 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/plugincontroller.h | 80 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/projectcontroller.cpp | 172 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/projectcontroller.h | 86 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/uicontroller.cpp | 124 | ||||
-rw-r--r-- | examples/uml/duse-mt/src/app/shell/uicontroller.h | 74 |
10 files changed, 0 insertions, 1454 deletions
diff --git a/examples/uml/duse-mt/src/app/shell/core.cpp b/examples/uml/duse-mt/src/app/shell/core.cpp deleted file mode 100644 index 037ddb02..00000000 --- a/examples/uml/duse-mt/src/app/shell/core.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 "core.h" - -#include "plugincontroller.h" -#include "projectcontroller.h" -#include "uicontroller.h" - -#include <QtCore/QDebug> - -namespace DuSE -{ - -Core::~Core() -{ - delete _pluginController; - delete _projectController; - delete _uiController; -} - -bool Core::initialize() -{ - if (_self) - return true; - - _self = new Core(); - - return true; -} - -IPluginController *Core::pluginController() -{ - return _pluginController; -} - -IProjectController *Core::projectController() -{ - return _projectController; -} - -IUiController *Core::uiController() -{ - return _uiController; -} - -Core::Core() : - _pluginController(0), - _projectController(0), - _uiController(0) -{ - initializeInternal(); -} - -bool Core::initializeInternal() -{ - if (!_pluginController) - _pluginController = new PluginController; - if (!_projectController) - _projectController = new ProjectController; - if (!_uiController) - _uiController = new UiController; - - if (!_pluginController->initialize()) { - qDebug() << "Error when initializing plugin controller:"; - qDebug(); - qDebug() << _pluginController->errorStrings(); - qDebug(); - } - if (!_projectController->initialize()) { - qDebug() << "Error when initializing project controller:"; - qDebug(); - qDebug() << _projectController->errorStrings(); - qDebug(); - } - if (!_uiController->initialize()) { - qDebug() << "Error when initializing UI controller:"; - } - - return true; -} - -} diff --git a/examples/uml/duse-mt/src/app/shell/core.h b/examples/uml/duse-mt/src/app/shell/core.h deleted file mode 100644 index 9c96c8c3..00000000 --- a/examples/uml/duse-mt/src/app/shell/core.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 CORE_H -#define CORE_H - -#include <duseinterfaces/icore.h> - -namespace DuSE -{ - -class PluginController; -class ProjectController; -class UiController; - -class Core : public ICore -{ -public: - virtual ~Core(); - - static bool initialize(); - - virtual IPluginController *pluginController(); - virtual IProjectController *projectController(); - virtual IUiController *uiController(); - -protected: - Core(); - bool initializeInternal(); - - PluginController *_pluginController; - ProjectController *_projectController; - UiController *_uiController; -}; - -} - -#endif // CORE_H diff --git a/examples/uml/duse-mt/src/app/shell/mainwindow.cpp b/examples/uml/duse-mt/src/app/shell/mainwindow.cpp deleted file mode 100644 index 19205793..00000000 --- a/examples/uml/duse-mt/src/app/shell/mainwindow.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 "mainwindow.h" -#include "ui_mainwindow.h" -#include "ui_aboutplugins.h" -#include "ui_aboutdusemt.h" -#include "ui_newmodel.h" - -#include <QtCore/QTimer> -#include <QtCore/QDebug> -#include <QtCore/QSettings> -#include <QtCore/QJsonArray> -#include <QtCore/QJsonObject> -#include <QtCore/QPluginLoader> -#include <QtCore/QStringListModel> - -#include <QtWidgets/QFileDialog> -#include <QtWidgets/QMessageBox> -#include <QtWidgets/QItemDelegate> -#include <QtWidgets/QProgressDialog> - -#include <QtGui/QKeyEvent> - -#include <QtModeling/QXmiWriter> -#include <QtModeling/QXmiReader> -#include <QtModeling/QModelingObject> -#include <QtModeling/QModelingElement> -#include <QtModeling/QMetaModelPlugin> -#include <QtModelingWidgets/QModelingObjectModel> -#include <QtModelingWidgets/QModelingObjectView> -#include <QtModelingWidgets/QModelingObjectPropertyModel> - -#include <duseinterfaces/icore.h> -#include <duseinterfaces/iplugin.h> -#include <duseinterfaces/iplugincontroller.h> -#include <duseinterfaces/iprojectcontroller.h> - -namespace DuSE -{ - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow), - _aboutPluginsDialog(new QDialog(this)), - _aboutPlugins(new Ui::AboutPlugins), - _aboutDuSEMTDialog(new QDialog(this)), - _aboutDuSEMT(new Ui::AboutDuSEMT), - _newModelDialog(new QDialog(this)), - _newModel(new Ui::NewModel) -{ - ui->setupUi(this); - - _newModel->setupUi(_newModelDialog); - connect(_newModel->cboMetamodel, SIGNAL(currentIndexChanged(QString)), SLOT(metaModelChanged(QString))); - _aboutPlugins->setupUi(_aboutPluginsDialog); - _aboutDuSEMT->setupUi(_aboutDuSEMTDialog); - -// connect(ui->modelingObjectView, &QModelingObjectView::addToView, this, &MainWindow::addToView); - -} - -MainWindow::~MainWindow() -{ - delete ui; - delete _aboutPlugins; - delete _newModel; - delete _aboutDuSEMT; -} - -void MainWindow::readSettings() -{ - QSettings settings("QtProject", "duse-mt"); - restoreGeometry(settings.value("geometry").toByteArray()); - restoreState(settings.value("windowState").toByteArray()); -} - -void MainWindow::on_actionFileNewModel_triggered() -{ - _newModel->lneModel->clear(); - _newModel->cboMetamodel->clear(); - foreach (QMetaModelPlugin *metamodelPlugin, ICore::self()->pluginController()->metamodelPlugins().values()) - _newModel->cboMetamodel->addItem(metamodelPlugin->metaObject()->className()); - _newModel->lneModel->setFocus(); - if (_newModelDialog->exec() == QDialog::Accepted) { - QMetaModelPlugin *metamodelPlugin = 0; - foreach (QMetaModelPlugin *plugin, ICore::self()->pluginController()->metamodelPlugins().values()) { - if (plugin->metaObject()->className() == _newModel->cboMetamodel->currentText()) - metamodelPlugin = plugin; - } - if (ICore::self()->projectController()->createModel(_newModel->lneModel->text(), metamodelPlugin, _newModel->lstTopLevelContainers->currentItem()->text())) - setWindowTitle(ICore::self()->projectController()->currentModelFileName() + " - DuSE-MT"); - } -} - -void MainWindow::on_actionFileOpenModel_triggered() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), QDir::currentPath(), "XMI files (*.xmi)"); - if (!fileName.isEmpty()) { - setCursor(Qt::WaitCursor); - bool ret = ICore::self()->projectController()->openModel(fileName); - setCursor(Qt::ArrowCursor); - if (!ret) { - QMessageBox::critical(this, tr("Open model"), ICore::self()->projectController()->errorStrings().first()); - return; - } - setWindowTitle(QFileInfo(fileName).fileName() + " - DuSE-MT"); - -// _currentFileName = fileName; -//// foreach (QWrappedObject *object, _inputModel) -//// delete object; -// _inputModel = loadXmi(_currentFileName); -// _modelQuickView->setClearBeforeRendering(true); -// _modelQuickView->setSource(QUrl("qrc:/qml/modelview.qml")); -// addToView(_inputModel[0]); - } -} - -void MainWindow::on_actionFileCloseModel_triggered() -{ - ICore::self()->projectController()->closeModel(); -} - -void MainWindow::evaluateQualityMetrics() -{ -// _engine.evaluate("var m = designspace.qualityMetrics.length; -// for (var j = 0; j < m; ++j) -// designspace.qualityMetrics[j].value = Math.random()*60+eval(designspace.qualityMetrics[j].expression)"); -} - -void MainWindow::populateDesignSpaceView(QModelingElement *modelingObject) -{ - Q_UNUSED(modelingObject); -// QDuseDesignSpace *designSpace = qobject_cast<QDuseDesignSpace *>(modelingObject); -// ui->tblDesignSpace->setRowCount(0); -// int row = 0; -// foreach (QDuseDesignDimension *dimension, designSpace->designDimensions()) { -// ui->tblDesignSpace->setRowCount(ui->tblDesignSpace->rowCount() + dimension->designDimensionInstances().count()); -// foreach (QDuseDesignDimensionInstance *instance, dimension->designDimensionInstances()) { -// ui->tblDesignSpace->setItem(row, 0, new QTableWidgetItem(dimension->name())); -// ui->tblDesignSpace->setItem(row, 1, new QTableWidgetItem(instance->objectName())); -// QComboBox *comboBox = new QComboBox; -// foreach (QDuseVariationPoint *variationPoint, dimension->variationPoints()) { -// comboBox->addItem(variationPoint->objectName()); -// } -// ui->tblDesignSpace->setCellWidget(row, 2, comboBox); -// connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(designSpaceChanged())); -// ++row; -// } -// } -// ui->tblDesignSpace->resizeRowsToContents(); -} - -void MainWindow::on_actionFileSaveAs_triggered() -{ - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), QDir::currentPath(), "XMI files (*.xmi)"); - if (!fileName.isEmpty()) - saveXmi(fileName); -} - -void MainWindow::on_actionFileSave_triggered() -{ - if (ICore::self()->projectController()->currentModelFileName().isEmpty()) - on_actionFileSaveAs_triggered(); - else - saveXmi(); -} - -void MainWindow::saveXmi(QString fileName) -{ - IProjectController *projectController = ICore::self()->projectController(); - setCursor(Qt::WaitCursor); - bool ret; - if (fileName.isEmpty()) - ret = projectController->saveModel(); - else - ret = projectController->saveModelAs(fileName); - setCursor(Qt::ArrowCursor); - if (!ret) { - QMessageBox::critical(this, tr("Save model%1").arg(fileName.isEmpty() ? "":" as"), projectController->errorStrings().first()); - return; - } - else { - statusBar()->showMessage("XMI file successfully saved !", 3000); - setWindowTitle(projectController->currentModelFileName() + " - DuSE-MT"); - } -} - -void MainWindow::on_actionHelpAboutPlugins_triggered() -{ - _aboutPluginsDialog->exec(); -} - -void MainWindow::on_actionHelpAboutDuSEMT_triggered() -{ - _aboutDuSEMTDialog->exec(); -} - -void MainWindow::on_centralWidget_currentChanged(int) -{ -// if (_currentFileName.isEmpty()) -// return; -// if (ui->centralWidget->currentIndex() == 1) { -// foreach (QWrappedObject *object, _inputModel) -// delete object; -// _inputModel = loadXmi(_currentFileName); -// evaluateQualityMetrics(); -// } -// else if (ui->centralWidget->currentIndex() == 2) { -// foreach (QWrappedObject *object, _designSpaceLocation) -// delete object; -// _designSpaceLocation = loadXmi("/data/devel/qtmodeling/examples/uml/r1.xmi"); -// addToDesignSpaceView(_designSpaceLocation.first()); -// evaluateQualityMetrics(); -// } -// else if (ui->centralWidget->currentIndex() == 3) { -// foreach (QWrappedObject *object, _designSpaceLocation) -// delete object; -// } -} - -//void MainWindow::on_btnOptimize_clicked() -//{ -// progress = new QProgressDialog("Optimizing architecture", "Abort", 0, 100, this); -// progress->setWindowModality(Qt::WindowModal); -// timer = new QTimer(this); -// connect(progress, SIGNAL(finished(int)), timer, SLOT(stop())); -// connect(timer, SIGNAL(timeout()), this, SLOT(update())); -// timer->start(1000); -//} - -void MainWindow::update() -{ - progress->setValue(progress->value()+10); - if (progress->value() == 99) { - timer->stop(); - progress->hide(); -// _designSpaceLocation = loadXmi(QString::fromLatin1("/data/devel/qtmodeling/examples/uml/r%1.xmi").arg(qrand() % 11)); -// addToPareto(_designSpaceLocation.first(), 0); -// _designSpaceLocation = loadXmi(QString::fromLatin1("/data/devel/qtmodeling/examples/uml/r%1.xmi").arg(qrand() % 11)); -// addToPareto(_designSpaceLocation.first(), 1); -// _designSpaceLocation = loadXmi(QString::fromLatin1("/data/devel/qtmodeling/examples/uml/r%1.xmi").arg(qrand() % 11)); -// addToPareto(_designSpaceLocation.first(), 2); - evaluateQualityMetrics(); - } -} - -void MainWindow::metaModelChanged(QString newMetaModel) -{ - _newModel->lstTopLevelContainers->clear(); - QVariantList list; - foreach (QMetaModelPlugin *metamodelPlugin, ICore::self()->pluginController()->metamodelPlugins()) { - if (metamodelPlugin->metaObject()->className() == newMetaModel) - list = metamodelPlugin->property("metadata").value<QJsonObject>().value("MetaModelTopLevelTypes").toArray().toVariantList(); - } - foreach (QVariant variant, list) - _newModel->lstTopLevelContainers->addItem(variant.toString()); - _newModel->lstTopLevelContainers->setCurrentRow(0); -} - -//void MainWindow::addToDesignSpaceView(QModelingElement *modelingObject, QQuickItem *parent) -//{ -// QQmlContext *context = new QQmlContext(_designSpaceQuickView->engine()->rootContext()); -// //modelingObject->setQmlContextProperties(context); -// _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->asQModelingObject()->metaObject()->className()).remove(QRegularExpression("^Q"))).arg(x).arg(y).toLatin1(), QUrl()); - -// QQuickItem *item = 0; -// if (_qmlComponent->isError()) { -// qWarning() << _qmlComponent->errors(); -// } else { -// item = qobject_cast<QQuickItem *>(_qmlComponent->create(context)); -// if (item) { -// item->setParentItem(parent ? parent:(qobject_cast<QQuickFlickable *>(_designSpaceQuickView->rootObject()))->contentItem()); -// } -// } - -// foreach (QObject *child, modelingObject->asQModelingObject()->children()) -// addToDesignSpaceView(dynamic_cast<QModelingElement *>(qModelingElement(child))); - -// _qmlComponent->deleteLater(); -//} - -void MainWindow::addToPareto(QModelingElement *modelingObject, int pos) -{ - Q_UNUSED(modelingObject); - Q_UNUSED(pos); -// QQmlContext *context = _paretoFrontQuickView->engine()->rootContext(); -// //modelingObject->setQmlContextProperties(context); -// _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->asQModelingObject()->metaObject()->className()).remove(QRegularExpression("^Q"))).arg(x).arg(y).toLatin1(), QUrl()); - -// QQuickItem *item = 0; -// if (_qmlComponent->isError()) { -// qWarning() << _qmlComponent->errors(); -// } else { -// item = qobject_cast<QQuickItem *>(_qmlComponent->create(context)); -// if (item) { -// item->setParentItem(_paretoFrontQuickView->rootObject()->childItems().first()->childItems().first()->childItems().at(pos)); -// } -// } - -// foreach (QObject *child, modelingObject->asQModelingObject()->children()) -// addToPareto(dynamic_cast<QModelingElement *>(qModelingElement(child)), pos); - -// _qmlComponent->deleteLater(); -} - -void MainWindow::designSpaceChanged() -{ -// _designSpaceQuickView->setSource(QUrl("qrc:/qml/designspaceview.qml")); -// _designSpaceQuickView->setClearBeforeRendering(true); - -// foreach (QWrappedObject *object, _designSpaceLocation) -// delete object; - -// _designSpaceLocation = loadXmi(QString::fromLatin1("/data/devel/qtmodeling/examples/uml/r%1.xmi").arg(qrand() % 11)); -// addToDesignSpaceView(_designSpaceLocation.first()); -// evaluateQualityMetrics(); -} - -QTreeWidgetItem *MainWindow::itemForCategory(const QString &category) -{ - int topLevelItemCount = _aboutPlugins->loadedPlugins->topLevelItemCount(); - for (int i = 0; i < topLevelItemCount; ++i) - if (_aboutPlugins->loadedPlugins->topLevelItem(i)->text(0) == category) - return _aboutPlugins->loadedPlugins->topLevelItem(i); - QTreeWidgetItem *topLevelItem = new QTreeWidgetItem(_aboutPlugins->loadedPlugins, QStringList() << category); - topLevelItem->setData(1, Qt::CheckStateRole, QVariant(Qt::Checked)); - return topLevelItem; -} - -void MainWindow::populatePluginDialog() -{ - _aboutPlugins->loadedPlugins->setColumnWidth(1, 40); - _aboutPlugins->loadedPlugins->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); - _aboutPlugins->loadedPlugins->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); - - foreach (QMetaModelPlugin *metamodelPlugin, ICore::self()->pluginController()->metamodelPlugins()) { - QJsonObject jsonObject = metamodelPlugin->property("metadata").value<QJsonObject>(); - QTreeWidgetItem *metamodelItem = new QTreeWidgetItem(itemForCategory("Metamodels"), - QStringList() << metamodelPlugin->metaObject()->className() - << QString() - << jsonObject.value("Version").toString() - << jsonObject.value("Vendor").toString()); - metamodelItem->setData(1, Qt::CheckStateRole, QVariant(Qt::Checked)); - } - foreach (DuSE::IPlugin *dusePlugin, ICore::self()->pluginController()->dusemtPlugins()) { - QJsonObject jsonObject = dusePlugin->property("metadata").value<QJsonObject>(); - QTreeWidgetItem *dusemtItem = new QTreeWidgetItem(itemForCategory(jsonObject.value("Category").toString()), - QStringList() << dusePlugin->metaObject()->className() - << QString() - << jsonObject.value("Version").toString() - << jsonObject.value("Vendor").toString()); - dusemtItem->setData(1, Qt::CheckStateRole, QVariant(Qt::Checked)); - } - - _aboutPlugins->loadedPlugins->expandAll(); -} - -void MainWindow::closeEvent(QCloseEvent *event) -{ - QSettings settings("QtProject", "duse-mt"); - settings.setValue("geometry", saveGeometry()); - settings.setValue("windowState", saveState()); - QMainWindow::closeEvent(event); -} - -} diff --git a/examples/uml/duse-mt/src/app/shell/mainwindow.h b/examples/uml/duse-mt/src/app/shell/mainwindow.h deleted file mode 100644 index c865c72c..00000000 --- a/examples/uml/duse-mt/src/app/shell/mainwindow.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 MAINWINDOW_H -#define MAINWINDOW_H - -#include <QtWidgets/QMainWindow> - -QT_BEGIN_NAMESPACE -class QQuickItem; -class QQmlComponent; -class QTreeWidgetItem; - -class QModelingElement; -//class QModelingObject; -class QMetaModelPlugin; -class QModelingObjectModel; -class QProgressDialog; -QT_END_NAMESPACE - -class NewDuseDesignDialog; - -namespace DuSE -{ - -namespace Ui { - class MainWindow; - class AboutPlugins; - class AboutDuSEMT; - class NewModel; -} - -class IPlugin; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = 0); - virtual ~MainWindow(); - - void readSettings(); - void populatePluginDialog(); - -protected: - void closeEvent(QCloseEvent *event); - -private Q_SLOTS: - void update(); - void on_actionFileNewModel_triggered(); - void on_actionFileOpenModel_triggered(); - void on_actionFileCloseModel_triggered(); - void on_actionFileSaveAs_triggered(); - void on_actionFileSave_triggered(); - void on_actionHelpAboutPlugins_triggered(); - void on_actionHelpAboutDuSEMT_triggered(); - void on_centralWidget_currentChanged(int); -// void on_btnOptimize_clicked(); - void evaluateQualityMetrics(); - - void metaModelChanged(QString newMetaModel); -// void addToDesignSpaceView(QModelingElement *modelingObject, QQuickItem *parent = 0); - void addToPareto(QModelingElement *modelingObject, int pos); - - void designSpaceChanged(); - -private: - Ui::MainWindow *ui; - - void populateDesignSpaceView(QModelingElement *modelingObject); - - QList<QModelingElement *> _inputModel; - QList<QModelingElement *> _designSpaceLocation; - - QDialog *_aboutPluginsDialog; - Ui::AboutPlugins *_aboutPlugins; - QDialog *_aboutDuSEMTDialog; - Ui::AboutDuSEMT *_aboutDuSEMT; - QDialog *_newModelDialog; - Ui::NewModel *_newModel; - NewDuseDesignDialog *_newDuseDesign; - - QQmlComponent *_qmlComponent; - - QProgressDialog *progress; - QTimer *timer; - - QTreeWidgetItem *itemForCategory(const QString &category); - - friend class UiController; - void saveXmi(QString fileName = QString()); -}; - -} - -#endif // MAINWINDOW_H diff --git a/examples/uml/duse-mt/src/app/shell/plugincontroller.cpp b/examples/uml/duse-mt/src/app/shell/plugincontroller.cpp deleted file mode 100644 index 36c2a7c8..00000000 --- a/examples/uml/duse-mt/src/app/shell/plugincontroller.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 "plugincontroller.h" - -#include <duseinterfaces/icore.h> -#include <duseinterfaces/iplugin.h> - -#include <QtModeling/QMetaModelPlugin> - -#include <QtWidgets/QTreeWidgetItem> - -#include <QtCore/QDir> -#include <QtCore/QJsonArray> -#include <QtCore/QJsonObject> -#include <QtCore/QStringList> -#include <QtCore/QPluginLoader> -#include <QtCore/QCoreApplication> - -#include <QDebug> - -namespace DuSE -{ - -PluginController::PluginController() -{ -} - -PluginController::~PluginController() -{ - qDeleteAll(_dusemtPlugins); -} - -bool PluginController::initialize() -{ - // Load metamodel plugins - foreach (QString pluginPath, QCoreApplication::libraryPaths()) { - QDir pluginsDir(pluginPath); - pluginsDir.cd("metamodels"); - foreach (const QString &fileName, pluginsDir.entryList(QDir::Files)) { - QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); - QObject *plugin = loader.instance(); - QMetaModelPlugin *metamodelPlugin = 0; - if (plugin && (metamodelPlugin = qobject_cast<QMetaModelPlugin *>(plugin))) { - QJsonObject jsonObject = loader.metaData().value(QStringLiteral("MetaData")).toObject(); - metamodelPlugin->setProperty("metadata", jsonObject); - _metamodelPlugins.insert(jsonObject.value(QStringLiteral("MetaModelNamespaceUri")).toString(), metamodelPlugin); - } - } - } - - // Load DuSE-MT plugins - QDir dusePluginsDir(QCoreApplication::applicationDirPath()); - -#if defined(Q_OS_MAC) - if (dusePluginsDir.dirName() == "MacOS") - { - dusePluginsDir.cdUp(); - dusePluginsDir.cdUp(); - dusePluginsDir.cdUp(); - } -#endif - - dusePluginsDir.cdUp(); - dusePluginsDir.cd("lib/duse-mt/plugins"); - - QHash<QString, QString> invertedDependency; - QObjectList pluginList; - foreach (const QFileInfo &subdir, dusePluginsDir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot)) { - QDir dusePluginSubDir(subdir.absoluteFilePath()); - foreach (const QString &fileName, dusePluginSubDir.entryList(QDir::Files)) { - QPluginLoader loader(dusePluginSubDir.absoluteFilePath(fileName)); - QObject *plugin = loader.instance(); - if (plugin && qobject_cast<DuSE::IPlugin *>(plugin)) { - QJsonObject jsonObject = loader.metaData().value(QStringLiteral("MetaData")).toObject(); - QJsonArray dependencies = jsonObject.value(QStringLiteral("DependencyList")).toArray(); - plugin->setProperty("metadata", loader.metaData().value(QStringLiteral("MetaData")).toObject()); - plugin->setObjectName(plugin->metaObject()->className()); - int dependencyCount = dependencies.size(); - for (int i = 0; i < dependencyCount; ++i) - invertedDependency.insert(dependencies.at(i).toString(), plugin->objectName()); - pluginList << plugin; - } - else { - _errorStrings << "Error when loading plugin" << fileName << ":" << loader.errorString(); - } - } - } - - // Initialize DuSE-MT plugins - IPlugin *dusePlugin; - int previousPluginListSize = 0; - while (pluginList.size() != previousPluginListSize) { - previousPluginListSize = pluginList.size(); - foreach (QObject *plugin, pluginList) { - if (plugin && (dusePlugin = qobject_cast<DuSE::IPlugin *>(plugin))) { - int dependencyCount = invertedDependency.values(dusePlugin->metaObject()->className()).count(); - int loadedDependencies = 0; - foreach (const QString &dependency, invertedDependency.values(dusePlugin->metaObject()->className())) { - foreach (DuSE::IPlugin *dusePlugin, _dusemtPlugins) { - if (dusePlugin->metaObject()->className() == dependency) { - ++loadedDependencies; - break; - } - } - } - if (loadedDependencies == dependencyCount) { - if (dusePlugin->initialize()) { - _dusemtPlugins << dusePlugin; - pluginList.removeAll(plugin); - } - } - } - } - } - if (!pluginList.isEmpty()) { - QString errorString = "The following plugins have not been initialized: "; - foreach (QObject *plugin, pluginList) - errorString += plugin->objectName() + ", "; - errorString.chop(2); - _errorStrings << errorString; - } - - return _errorStrings.isEmpty() ? true:false; -} - -const QHash<QString, QMetaModelPlugin *> &PluginController::metamodelPlugins() const -{ - return _metamodelPlugins; -} - -const QList<IPlugin *> &PluginController::dusemtPlugins() const -{ - return _dusemtPlugins; -} - -QStringList PluginController::errorStrings() const -{ - return _errorStrings; -} - -} diff --git a/examples/uml/duse-mt/src/app/shell/plugincontroller.h b/examples/uml/duse-mt/src/app/shell/plugincontroller.h deleted file mode 100644 index acaab850..00000000 --- a/examples/uml/duse-mt/src/app/shell/plugincontroller.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 PLUGINCONTROLLER_H -#define PLUGINCONTROLLER_H - -#include <duseinterfaces/iplugincontroller.h> - -#include <QtCore/QHash> -#include <QtCore/QStringList> - -QT_BEGIN_NAMESPACE -class QTreeWidgetItem; - -class QMetaModelPlugin; -QT_END_NAMESPACE - -namespace DuSE -{ - -class IPlugin; - -class PluginController : public IPluginController -{ -public: - PluginController(); - virtual ~PluginController(); - - virtual bool initialize(); - - virtual const QHash<QString, QMetaModelPlugin *> &metamodelPlugins() const; - virtual const QList<DuSE::IPlugin *> &dusemtPlugins() const; - virtual QStringList errorStrings() const; - -private: - QHash<QString, QMetaModelPlugin *> _metamodelPlugins; - QList<DuSE::IPlugin *> _dusemtPlugins; - QStringList _errorStrings; -}; - -} - -#endif // PLUGINCONTROLLER_H diff --git a/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp b/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp deleted file mode 100644 index 60328ec0..00000000 --- a/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 "projectcontroller.h" - -#include <QtWidgets/QFileDialog> -#include <QtWidgets/QMessageBox> - -#include <QtModeling/QXmiReader> -#include <QtModeling/QXmiWriter> -#include <QtModeling/QMetaModelPlugin> -#include <QtModeling/QModelingElement> - -namespace DuSE -{ - -ProjectController::ProjectController() -{ -} - -ProjectController::~ProjectController() -{ - closeModel(); -} - -bool ProjectController::initialize() -{ - return true; -} - -QStringList ProjectController::errorStrings() const -{ - return _errorStrings; -} - -QString ProjectController::currentModelFileName() const -{ - return _currentModelFileName; -} - -QList<QModelingObject *> ProjectController::currentModelObjects() const -{ - return _currentModelObjects; -} - -QList<QModelingElement *> ProjectController::currentModelElements() const -{ - return _currentModelElements; -} - -bool ProjectController::openModel(const QString &fileName) -{ - closeModel(); - - QFile file(fileName); - if (!file.open(QFile::ReadOnly | QFile::Text)) { - _errorStrings << QObject::tr("Cannot read file %1").arg(fileName); - return false; - } - - _currentModelFileName = fileName; - - QXmiReader reader; - _currentModelElements = reader.readFile(&file); - _errorStrings << reader.errorStrings(); - - foreach (QModelingElement *element, _currentModelElements) - _currentModelObjects << element->asQModelingObject(); - - emit modelOpened(_currentModelObjects); - - return true; -} - -bool ProjectController::closeModel() -{ - if (_currentModelObjects.size() == 0) - return false; - - emit modelAboutToBeClosed(_currentModelObjects); - qDeleteAll(_currentModelElements); - _currentModelElements.clear(); - _currentModelObjects.clear(); - _errorStrings.clear(); - emit modelClosed(); - - return true; -} - -bool ProjectController::saveModel() -{ - Q_ASSERT(!_currentModelFileName.isEmpty()); - _errorStrings.clear(); - - QFile file(_currentModelFileName); - if (!file.open(QFile::WriteOnly | QFile::Text)) { - _errorStrings << QObject::tr("Cannot write file %1").arg(_currentModelFileName); - return false; - } - - QXmiWriter writer; - if (!writer.writeFile(_currentModelObjects, &file)) { - _errorStrings << QObject::tr("Error when writing XMI file %1").arg(_currentModelFileName); - return false; - } - return true; -} - -bool ProjectController::saveModelAs(const QString &fileName) -{ - _currentModelFileName = fileName; - return saveModel(); -} - -bool ProjectController::createModel(const QString &modelFileName, QMetaModelPlugin *metamodelPlugin, const QString &topLevelType) -{ - QModelingElement *topLevelElement = metamodelPlugin->createModelingElement(topLevelType); - if (topLevelElement) { - topLevelElement->asQModelingObject()->setObjectName(modelFileName); - qDeleteAll(_currentModelElements); - _currentModelElements.clear(); - _currentModelObjects.clear(); - - _currentModelElements << topLevelElement; - _currentModelObjects << topLevelElement->asQModelingObject(); - - emit modelOpened(_currentModelObjects); - - return saveModelAs(modelFileName); - } - else - return false; -} - -} diff --git a/examples/uml/duse-mt/src/app/shell/projectcontroller.h b/examples/uml/duse-mt/src/app/shell/projectcontroller.h deleted file mode 100644 index 12536525..00000000 --- a/examples/uml/duse-mt/src/app/shell/projectcontroller.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 PROJECTCONTROLLER_H -#define PROJECTCONTROLLER_H - -#include <duseinterfaces/iprojectcontroller.h> - -#include "mainwindow.h" - -QT_BEGIN_NAMESPACE -class QModelingObject; -class QModelingElement; -class QMetaModelPlugin; -QT_END_NAMESPACE - -namespace DuSE -{ - -class ProjectController : public IProjectController -{ -public: - ProjectController(); - virtual ~ProjectController(); - - virtual bool initialize(); - - virtual QStringList errorStrings() const; - virtual QString currentModelFileName() const; - virtual QList<QModelingObject *> currentModelObjects() const; - virtual QList<QModelingElement *> currentModelElements() const; - -public Q_SLOTS: - virtual bool openModel(const QString &fileName); - virtual bool closeModel(); - virtual bool saveModel(); - virtual bool saveModelAs(const QString &fileName); - virtual bool createModel(const QString &modelFileName, QMetaModelPlugin *metamodelPlugin, const QString &topLevelType); - -private: - QString _currentModelFileName; - QList<QModelingElement *> _currentModelElements; - QList<QModelingObject *> _currentModelObjects; - QStringList _errorStrings; -}; - -} - -#endif // PROJECTCONTROLLER_H diff --git a/examples/uml/duse-mt/src/app/shell/uicontroller.cpp b/examples/uml/duse-mt/src/app/shell/uicontroller.cpp deleted file mode 100644 index ea488cd4..00000000 --- a/examples/uml/duse-mt/src/app/shell/uicontroller.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 "uicontroller.h" - -#include <QtWidgets/QAction> -#include <QtWidgets/QDockWidget> -#include <QtWidgets/QGridLayout> - -#include "ui_mainwindow.h" - -namespace DuSE -{ - -UiController::UiController() : - _lastBottomDockWidgetAdded(0) -{ -} - -UiController::~UiController() -{ -} - -bool UiController::initialize() -{ - _mainWindow.populatePluginDialog(); - _mainWindow.showMaximized(); - _mainWindow.readSettings(); - _mainWindow.ui->centralWidget->setCurrentIndex(0); - - return true; -} - -void UiController::addDockWidget(Qt::DockWidgetArea area, QString name, QWidget *widget) -{ - QDockWidget *dockWidget = new QDockWidget; - dockWidget->setWindowTitle(name); - dockWidget->setObjectName(name); - dockWidget->setWidget(widget); - widget->setParent(dockWidget); - - _mainWindow.addDockWidget(area, dockWidget); - if (area == Qt::BottomDockWidgetArea) { - if (_lastBottomDockWidgetAdded) - _mainWindow.tabifyDockWidget(_lastBottomDockWidgetAdded, dockWidget); - _lastBottomDockWidgetAdded = dockWidget; - } -} - -void UiController::removeDockWidget(const QString &name) -{ - foreach (QObject *child, _mainWindow.children()) - if (child->objectName() == name && qobject_cast<QDockWidget *>(child) != 0) - delete child; -} - -void UiController::addCentralWidgetTab(QWidget *widget, const QString &label, int position, const QIcon &icon) -{ - if (position == -1) - _mainWindow.ui->centralWidget->addTab(widget, icon, label); - else - _mainWindow.ui->centralWidget->insertTab(position, widget, icon, label); - widget->setObjectName(label); -} - -void UiController::removeCentralWidgetTab(const QString &name) -{ - int tabCount = _mainWindow.ui->centralWidget->count(); - for (int i = 0; i < tabCount; ++i) - if (_mainWindow.ui->centralWidget->widget(i)->objectName() == name) { - _mainWindow.ui->centralWidget->removeTab(i); - break; - } -} - -void UiController::addAction(QAction *action, const QString &menuTitle, const QString &toolbarName) -{ - foreach (QMenu *menu, _mainWindow.ui->menuBar->findChildren<QMenu *>()) - if (menu->objectName() == menuTitle) - menu->addAction(action); - foreach (QToolBar *toolbar, _mainWindow.findChildren<QToolBar *>()) - if (toolbar->objectName() == toolbarName) - toolbar->addAction(action); - action->setParent(&_mainWindow); -} - -} diff --git a/examples/uml/duse-mt/src/app/shell/uicontroller.h b/examples/uml/duse-mt/src/app/shell/uicontroller.h deleted file mode 100644 index c7511517..00000000 --- a/examples/uml/duse-mt/src/app/shell/uicontroller.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Sandro S. Andrade <[email protected]> -** 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 UICONTROLLER_H -#define UICONTROLLER_H - -#include <duseinterfaces/iuicontroller.h> - -#include "mainwindow.h" - -namespace DuSE -{ - -class UiController : public IUiController -{ -public: - UiController(); - virtual ~UiController(); - - virtual bool initialize(); - - virtual void addDockWidget(Qt::DockWidgetArea area, QString name, QWidget *widget); - virtual void removeDockWidget(const QString &name); - - virtual void addCentralWidgetTab(QWidget *widget, const QString &label, int position = -1, const QIcon &icon = QIcon()); - virtual void removeCentralWidgetTab(const QString &name); - - virtual void addAction(QAction *action, const QString &menuTitle, const QString &toolbarName = QString()); - -protected: - MainWindow _mainWindow; - QDockWidget *_lastBottomDockWidgetAdded; -}; - -} - -#endif // UICONTROLLER_H |