summaryrefslogtreecommitdiffstats
path: root/examples/uml/duse-mt/src
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-11-27 22:03:05 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-11-28 03:47:27 +0100
commit55c12a210e2738944ff60e4c9c36f647497f241d (patch)
tree41ad699026c5ac1b3dedcc3268cb5203c02a2572 /examples/uml/duse-mt/src
parent79eb41aa6c59fc62b54759790891b5df424c03dd (diff)
Implement file->closeModel operation in DuSE-MT
Change-Id: Icd4bd36725c9d8c9b8e4580fd831356199087675 Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'examples/uml/duse-mt/src')
-rw-r--r--examples/uml/duse-mt/src/app/mainwindow.ui15
-rw-r--r--examples/uml/duse-mt/src/app/shell/mainwindow.cpp5
-rw-r--r--examples/uml/duse-mt/src/app/shell/mainwindow.h1
-rw-r--r--examples/uml/duse-mt/src/app/shell/projectcontroller.cpp22
-rw-r--r--examples/uml/duse-mt/src/app/shell/projectcontroller.h1
-rw-r--r--examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h3
-rw-r--r--examples/uml/duse-mt/src/plugins/modelinspector/modelinspectorplugin.cpp6
7 files changed, 48 insertions, 5 deletions
diff --git a/examples/uml/duse-mt/src/app/mainwindow.ui b/examples/uml/duse-mt/src/app/mainwindow.ui
index 5806ba2f..5753274d 100644
--- a/examples/uml/duse-mt/src/app/mainwindow.ui
+++ b/examples/uml/duse-mt/src/app/mainwindow.ui
@@ -76,6 +76,8 @@
<addaction name="actionFileSave"/>
<addaction name="actionFileSaveAs"/>
<addaction name="separator"/>
+ <addaction name="actionFileCloseModel"/>
+ <addaction name="separator"/>
<addaction name="actionFileQuit"/>
</widget>
<widget class="QMenu" name="menu_Help">
@@ -184,6 +186,19 @@
<string>About DuSE-MT</string>
</property>
</action>
+ <action name="actionFileCloseModel">
+ <property name="icon">
+ <iconset theme="document-close">
+ <normaloff/>
+ </iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Close Model</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+W</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
diff --git a/examples/uml/duse-mt/src/app/shell/mainwindow.cpp b/examples/uml/duse-mt/src/app/shell/mainwindow.cpp
index b56af3f5..76e06eda 100644
--- a/examples/uml/duse-mt/src/app/shell/mainwindow.cpp
+++ b/examples/uml/duse-mt/src/app/shell/mainwindow.cpp
@@ -152,6 +152,11 @@ void MainWindow::on_actionFileOpenModel_triggered()
}
}
+void MainWindow::on_actionFileCloseModel_triggered()
+{
+ ICore::self()->projectController()->closeModel();
+}
+
void MainWindow::evaluateQualityMetrics()
{
// _engine.evaluate("var m = designspace.qualityMetrics.length;
diff --git a/examples/uml/duse-mt/src/app/shell/mainwindow.h b/examples/uml/duse-mt/src/app/shell/mainwindow.h
index 9e36cba9..7c0f03f1 100644
--- a/examples/uml/duse-mt/src/app/shell/mainwindow.h
+++ b/examples/uml/duse-mt/src/app/shell/mainwindow.h
@@ -85,6 +85,7 @@ 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();
diff --git a/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp b/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp
index bc348c64..60328ec0 100644
--- a/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp
+++ b/examples/uml/duse-mt/src/app/shell/projectcontroller.cpp
@@ -57,7 +57,7 @@ ProjectController::ProjectController()
ProjectController::~ProjectController()
{
- qDeleteAll(_currentModelElements);
+ closeModel();
}
bool ProjectController::initialize()
@@ -87,10 +87,7 @@ QList<QModelingElement *> ProjectController::currentModelElements() const
bool ProjectController::openModel(const QString &fileName)
{
- qDeleteAll(_currentModelElements);
- _currentModelElements.clear();
- _currentModelObjects.clear();
- _errorStrings.clear();
+ closeModel();
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
@@ -112,6 +109,21 @@ bool ProjectController::openModel(const QString &fileName)
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());
diff --git a/examples/uml/duse-mt/src/app/shell/projectcontroller.h b/examples/uml/duse-mt/src/app/shell/projectcontroller.h
index 38bc4c3a..5534d7a0 100644
--- a/examples/uml/duse-mt/src/app/shell/projectcontroller.h
+++ b/examples/uml/duse-mt/src/app/shell/projectcontroller.h
@@ -63,6 +63,7 @@ public:
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);
diff --git a/examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h b/examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h
index c48e066c..dc89e220 100644
--- a/examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h
+++ b/examples/uml/duse-mt/src/libs/duseinterfaces/iprojectcontroller.h
@@ -70,12 +70,15 @@ public:
public Q_SLOTS:
virtual bool openModel(const QString &fileName) = 0;
+ virtual bool closeModel() = 0;
virtual bool saveModel() = 0;
virtual bool saveModelAs(const QString &fileName) = 0;
virtual bool createModel(const QString &modelFileName, QMetaModelPlugin *metamodelPlugin, const QString &topLevelType) = 0;
Q_SIGNALS:
void modelOpened(QList<QModelingObject *> model);
+ void modelAboutToBeClosed(QList<QModelingObject *> model);
+ void modelClosed();
protected:
IProjectController();
diff --git a/examples/uml/duse-mt/src/plugins/modelinspector/modelinspectorplugin.cpp b/examples/uml/duse-mt/src/plugins/modelinspector/modelinspectorplugin.cpp
index 8e308994..9adec971 100644
--- a/examples/uml/duse-mt/src/plugins/modelinspector/modelinspectorplugin.cpp
+++ b/examples/uml/duse-mt/src/plugins/modelinspector/modelinspectorplugin.cpp
@@ -88,8 +88,14 @@ bool ModelInspectorPlugin::initialize(DuSE::ICore *core)
connect(core->projectController(), SIGNAL(modelOpened(QList<QModelingObject*>)), _modelingObjectModel, SLOT(setModelingObjects(QList<QModelingObject*>)));
connect(core->projectController(), SIGNAL(modelOpened(QList<QModelingObject*>)), this, SLOT(populateOutputIssues()));
+
+ connect(core->projectController(), SIGNAL(modelClosed()), _modelingObjectModel, SLOT(clear()));
+ connect(core->projectController(), SIGNAL(modelClosed()), _propertyModel, SLOT(clear()));
+ connect(core->projectController(), SIGNAL(modelClosed()), this, SLOT(populateOutputIssues()));
+
connect(_modelingObjectView, &QModelingObjectView::modelingObjectChanged, _propertyModel, &QModelingObjectPropertyModel::setModelingObject);
connect(_modelingObjectView, SIGNAL(modelingObjectChanged(QModelingObject*)), core->uiController(), SIGNAL(currentModelingObjectChanged(QModelingObject*)));
+
connect(_propertyModel, &QModelingObjectPropertyModel::indexChanged, _modelingObjectModel, &QModelingObjectModel::updateIndex);
connect(core->uiController(), SIGNAL(updateCurrentModelingObject()), _modelingObjectView, SLOT(updateSelected()));
connect(_modelingObjectView, SIGNAL(addToView(QObject*,QQuickItem*)), core->uiController(), SIGNAL(addToView(QObject*,QQuickItem*)));