2016-01-15 14:58:39 +01:00
|
|
|
/****************************************************************************
|
2015-08-16 13:11:15 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 Jochen Becher
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-08-16 13:11:15 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-08-16 13:11:15 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-08-16 13:11:15 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "propertiesview.h"
|
|
|
|
|
#include "propertiesviewmview.h"
|
|
|
|
|
|
|
|
|
|
#include "qmt/model_controller/modelcontroller.h"
|
|
|
|
|
|
|
|
|
|
#include "qmt/model/mobject.h"
|
|
|
|
|
#include "qmt/model/mrelation.h"
|
|
|
|
|
#include "qmt/model/mdiagram.h"
|
|
|
|
|
#include "qmt/diagram_controller/diagramcontroller.h"
|
|
|
|
|
|
|
|
|
|
#include "qmt/diagram/delement.h"
|
|
|
|
|
|
|
|
|
|
namespace qmt {
|
|
|
|
|
|
|
|
|
|
PropertiesView::PropertiesView(QObject *parent)
|
|
|
|
|
: QObject(parent),
|
2015-11-03 22:30:46 +01:00
|
|
|
m_modelController(0),
|
|
|
|
|
m_diagramController(0),
|
|
|
|
|
m_stereotypeController(0),
|
|
|
|
|
m_styleController(0),
|
2016-02-14 11:02:49 +01:00
|
|
|
m_viewFactory([=](PropertiesView *propertiesView) { return new MView(propertiesView); }),
|
2015-11-03 22:30:46 +01:00
|
|
|
m_selectedDiagram(0),
|
|
|
|
|
m_widget(0)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertiesView::~PropertiesView()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::setModelController(ModelController *modelController)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
if (m_modelController != modelController) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_modelController)
|
2015-11-03 22:30:46 +01:00
|
|
|
disconnect(m_modelController, 0, this, 0);
|
2015-11-04 07:52:44 +01:00
|
|
|
m_modelController = modelController;
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_modelController) {
|
2015-11-21 18:50:29 +01:00
|
|
|
connect(m_modelController, &ModelController::beginResetModel,
|
|
|
|
|
this, &PropertiesView::onBeginResetModel);
|
|
|
|
|
connect(m_modelController, &ModelController::endResetModel,
|
|
|
|
|
this, &PropertiesView::onEndResetModel);
|
|
|
|
|
|
|
|
|
|
connect(m_modelController, &ModelController::beginInsertObject,
|
|
|
|
|
this, &PropertiesView::onBeginInsertObject);
|
|
|
|
|
connect(m_modelController, &ModelController::endInsertObject,
|
|
|
|
|
this, &PropertiesView::onEndInsertObject);
|
|
|
|
|
connect(m_modelController, &ModelController::beginUpdateObject,
|
|
|
|
|
this, &PropertiesView::onBeginUpdateObject);
|
|
|
|
|
connect(m_modelController, &ModelController::endUpdateObject,
|
|
|
|
|
this, &PropertiesView::onEndUpdateObject);
|
|
|
|
|
connect(m_modelController, &ModelController::beginRemoveObject,
|
|
|
|
|
this, &PropertiesView::onBeginRemoveObject);
|
|
|
|
|
connect(m_modelController, &ModelController::endRemoveObject,
|
|
|
|
|
this, &PropertiesView::onEndRemoveObject);
|
|
|
|
|
connect(m_modelController, &ModelController::beginMoveObject,
|
|
|
|
|
this, &PropertiesView::onBeginMoveObject);
|
|
|
|
|
connect(m_modelController, &ModelController::endMoveObject,
|
|
|
|
|
this, &PropertiesView::onEndMoveObject);
|
|
|
|
|
|
|
|
|
|
connect(m_modelController, &ModelController::beginInsertRelation,
|
|
|
|
|
this, &PropertiesView::onBeginInsertRelation);
|
|
|
|
|
connect(m_modelController, &ModelController::endInsertRelation,
|
|
|
|
|
this, &PropertiesView::onEndInsertRelation);
|
|
|
|
|
connect(m_modelController, &ModelController::beginUpdateRelation,
|
|
|
|
|
this, &PropertiesView::onBeginUpdateRelation);
|
|
|
|
|
connect(m_modelController, &ModelController::endUpdateRelation,
|
|
|
|
|
this, &PropertiesView::onEndUpdateRelation);
|
|
|
|
|
connect(m_modelController, &ModelController::beginRemoveRelation,
|
|
|
|
|
this, &PropertiesView::onBeginRemoveRelation);
|
|
|
|
|
connect(m_modelController, &ModelController::endRemoveRelation,
|
|
|
|
|
this, &PropertiesView::onEndRemoveRelation);
|
|
|
|
|
connect(m_modelController, &ModelController::beginMoveRelation,
|
|
|
|
|
this, &PropertiesView::onBeginMoveRelation);
|
|
|
|
|
connect(m_modelController, &ModelController::endMoveRelation,
|
|
|
|
|
this, &PropertiesView::onEndMoveRelation);
|
|
|
|
|
|
|
|
|
|
connect(m_modelController, &ModelController::relationEndChanged,
|
|
|
|
|
this, &PropertiesView::onRelationEndChanged);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::setDiagramController(DiagramController *diagramController)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
if (m_diagramController != diagramController) {
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_diagramController) {
|
|
|
|
|
disconnect(m_diagramController, 0, this, 0);
|
|
|
|
|
m_diagramController = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-04 07:52:44 +01:00
|
|
|
m_diagramController = diagramController;
|
|
|
|
|
if (diagramController) {
|
2015-11-21 18:50:29 +01:00
|
|
|
connect(m_diagramController, &DiagramController::beginResetAllDiagrams,
|
|
|
|
|
this, &PropertiesView::onBeginResetAllDiagrams);
|
|
|
|
|
connect(m_diagramController, &DiagramController::endResetAllDiagrams,
|
|
|
|
|
this, &PropertiesView::onEndResetAllDiagrams);
|
|
|
|
|
|
|
|
|
|
connect(m_diagramController, &DiagramController::beginResetDiagram,
|
|
|
|
|
this, &PropertiesView::onBeginResetDiagram);
|
|
|
|
|
connect(m_diagramController, &DiagramController::endResetDiagram,
|
|
|
|
|
this, &PropertiesView::onEndResetDiagram);
|
|
|
|
|
|
|
|
|
|
connect(m_diagramController, &DiagramController::beginUpdateElement,
|
|
|
|
|
this, &PropertiesView::onBeginUpdateElement);
|
|
|
|
|
connect(m_diagramController, &DiagramController::endUpdateElement,
|
|
|
|
|
this, &PropertiesView::onEndUpdateElement);
|
|
|
|
|
connect(m_diagramController, &DiagramController::beginInsertElement,
|
|
|
|
|
this, &PropertiesView::onBeginInsertElement);
|
|
|
|
|
connect(m_diagramController, &DiagramController::endInsertElement,
|
|
|
|
|
this, &PropertiesView::onEndInsertElement);
|
|
|
|
|
connect(m_diagramController, &DiagramController::beginRemoveElement,
|
|
|
|
|
this, &PropertiesView::onBeginRemoveElement);
|
|
|
|
|
connect(m_diagramController, &DiagramController::endRemoveElement,
|
|
|
|
|
this, &PropertiesView::onEndRemoveElement);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::setStereotypeController(StereotypeController *stereotypeController)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
m_stereotypeController = stereotypeController;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::setStyleController(StyleController *styleController)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
m_styleController = styleController;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-14 11:02:49 +01:00
|
|
|
void PropertiesView::setMViewFactory(std::function<MView *(PropertiesView *)> factory)
|
|
|
|
|
{
|
|
|
|
|
m_viewFactory = factory;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::setSelectedModelElements(const QList<MElement *> &modelElements)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
QMT_CHECK(modelElements.size() > 0);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
if (m_selectedModelElements != modelElements) {
|
|
|
|
|
m_selectedModelElements = modelElements;
|
2015-11-03 22:30:46 +01:00
|
|
|
m_selectedDiagramElements.clear();
|
|
|
|
|
m_selectedDiagram = 0;
|
2016-02-14 11:02:49 +01:00
|
|
|
m_mview.reset(m_viewFactory(this));
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedModelElements);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_widget = m_mview->topLevelWidget();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::setSelectedDiagramElements(const QList<DElement *> &diagramElements, MDiagram *diagram)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
QMT_CHECK(diagramElements.size() > 0);
|
2017-07-09 11:49:13 +02:00
|
|
|
QMT_ASSERT(diagram, return);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
if (m_selectedDiagramElements != diagramElements || m_selectedDiagram != diagram) {
|
|
|
|
|
m_selectedDiagramElements = diagramElements;
|
2015-11-03 22:30:46 +01:00
|
|
|
m_selectedDiagram = diagram;
|
|
|
|
|
m_selectedModelElements.clear();
|
2016-02-14 11:02:49 +01:00
|
|
|
m_mview.reset(m_viewFactory(this));
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedDiagramElements, m_selectedDiagram);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_widget = m_mview->topLevelWidget();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::clearSelection()
|
|
|
|
|
{
|
2015-11-03 22:30:46 +01:00
|
|
|
m_selectedModelElements.clear();
|
|
|
|
|
m_selectedDiagramElements.clear();
|
|
|
|
|
m_selectedDiagram = 0;
|
|
|
|
|
m_mview.reset();
|
|
|
|
|
m_widget = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-04 22:44:41 +01:00
|
|
|
QWidget *PropertiesView::widget() const
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-03 22:30:46 +01:00
|
|
|
return m_widget;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::editSelectedElement()
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_selectedModelElements.size() == 1 || (m_selectedDiagramElements.size() == 1 && m_selectedDiagram))
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->edit();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginResetModel()
|
|
|
|
|
{
|
|
|
|
|
clearSelection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndResetModel()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginUpdateObject(int row, const MObject *parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndUpdateObject(int row, const MObject *parent)
|
|
|
|
|
{
|
2015-11-04 22:44:41 +01:00
|
|
|
MObject *mobject = m_modelController->object(row, parent);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (mobject && m_selectedModelElements.contains(mobject))
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedModelElements);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginInsertObject(int row, const MObject *parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndInsertObject(int row, const MObject *parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginRemoveObject(int row, const MObject *parent)
|
|
|
|
|
{
|
2015-11-04 22:44:41 +01:00
|
|
|
MObject *mobject = m_modelController->object(row, parent);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (mobject && m_selectedModelElements.contains(mobject))
|
2015-08-16 13:11:15 +02:00
|
|
|
clearSelection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndRemoveObject(int row, const MObject *parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::onBeginMoveObject(int formerRow, const MObject *formerOwner)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
Q_UNUSED(formerRow);
|
|
|
|
|
Q_UNUSED(formerOwner);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndMoveObject(int row, const MObject *owner)
|
|
|
|
|
{
|
2015-11-04 22:44:41 +01:00
|
|
|
MObject *mobject = m_modelController->object(row, owner);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (mobject && m_selectedModelElements.contains(mobject))
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedModelElements);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginUpdateRelation(int row, const MObject *parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndUpdateRelation(int row, const MObject *parent)
|
|
|
|
|
{
|
2015-11-04 22:44:41 +01:00
|
|
|
MRelation *mrelation = parent->relations().at(row);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (mrelation && m_selectedModelElements.contains(mrelation))
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedModelElements);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginInsertRelation(int row, const MObject *parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndInsertRelation(int row, const MObject *parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginRemoveRelation(int row, const MObject *parent)
|
|
|
|
|
{
|
2015-11-04 22:44:41 +01:00
|
|
|
MRelation *mrelation = parent->relations().at(row);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (mrelation && m_selectedModelElements.contains(mrelation))
|
2015-08-16 13:11:15 +02:00
|
|
|
clearSelection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndRemoveRelation(int row, const MObject *parent)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::onBeginMoveRelation(int formerRow, const MObject *formerOwner)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
Q_UNUSED(formerRow);
|
|
|
|
|
Q_UNUSED(formerOwner);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndMoveRelation(int row, const MObject *owner)
|
|
|
|
|
{
|
2015-11-04 22:44:41 +01:00
|
|
|
MRelation *mrelation = owner->relations().at(row);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (mrelation && m_selectedModelElements.contains(mrelation))
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedModelElements);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::onRelationEndChanged(MRelation *relation, MObject *endObject)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 07:52:44 +01:00
|
|
|
Q_UNUSED(endObject);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (relation && m_selectedModelElements.contains(relation))
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedModelElements);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginResetAllDiagrams()
|
|
|
|
|
{
|
|
|
|
|
clearSelection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndResetAllDiagrams()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginResetDiagram(const MDiagram *diagram)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(diagram);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndResetDiagram(const MDiagram *diagram)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (diagram == m_selectedDiagram && m_selectedDiagramElements.size() > 0)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedDiagramElements, m_selectedDiagram);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginUpdateElement(int row, const MDiagram *diagram)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(diagram);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndUpdateElement(int row, const MDiagram *diagram)
|
|
|
|
|
{
|
2015-11-03 22:30:46 +01:00
|
|
|
if (diagram == m_selectedDiagram) {
|
2015-11-04 22:44:41 +01:00
|
|
|
DElement *delement = diagram->diagramElements().at(row);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_selectedDiagramElements.contains(delement))
|
2015-11-03 22:30:46 +01:00
|
|
|
m_mview->update(m_selectedDiagramElements, m_selectedDiagram);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginInsertElement(int row, const MDiagram *diagram)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(diagram);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndInsertElement(int row, const MDiagram *diagram)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(diagram);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onBeginRemoveElement(int row, const MDiagram *diagram)
|
|
|
|
|
{
|
2015-11-03 22:30:46 +01:00
|
|
|
if (diagram == m_selectedDiagram) {
|
2015-11-04 22:44:41 +01:00
|
|
|
DElement *delement = diagram->diagramElements().at(row);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_selectedDiagramElements.contains(delement))
|
2015-08-16 13:11:15 +02:00
|
|
|
clearSelection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertiesView::onEndRemoveElement(int row, const MDiagram *diagram)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(row);
|
|
|
|
|
Q_UNUSED(diagram);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::beginUpdate(MElement *modelElement)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2017-07-09 11:49:13 +02:00
|
|
|
QMT_ASSERT(modelElement, return);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-21 20:54:19 +01:00
|
|
|
if (auto object = dynamic_cast<MObject *>(modelElement)) {
|
2015-11-03 22:30:46 +01:00
|
|
|
m_modelController->startUpdateObject(object);
|
2015-11-21 20:54:19 +01:00
|
|
|
} else if (auto relation = dynamic_cast<MRelation *>(modelElement)) {
|
2015-11-03 22:30:46 +01:00
|
|
|
m_modelController->startUpdateRelation(relation);
|
2015-08-16 13:11:15 +02:00
|
|
|
} else {
|
|
|
|
|
QMT_CHECK(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::endUpdate(MElement *modelElement, bool cancelled)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2017-07-09 11:49:13 +02:00
|
|
|
QMT_ASSERT(modelElement, return);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-21 20:54:19 +01:00
|
|
|
if (auto object = dynamic_cast<MObject *>(modelElement)) {
|
2015-11-03 22:30:46 +01:00
|
|
|
m_modelController->finishUpdateObject(object, cancelled);
|
2015-11-21 20:54:19 +01:00
|
|
|
} else if (auto relation = dynamic_cast<MRelation *>(modelElement)) {
|
2015-11-03 22:30:46 +01:00
|
|
|
m_modelController->finishUpdateRelation(relation, cancelled);
|
2015-08-16 13:11:15 +02:00
|
|
|
} else {
|
|
|
|
|
QMT_CHECK(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::beginUpdate(DElement *diagramElement)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2017-07-09 11:49:13 +02:00
|
|
|
QMT_ASSERT(diagramElement, return);
|
|
|
|
|
QMT_ASSERT(m_selectedDiagram, return);
|
|
|
|
|
QMT_ASSERT(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement, return);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 23:34:44 +01:00
|
|
|
m_diagramController->startUpdateElement(diagramElement, m_selectedDiagram, DiagramController::UpdateMinor);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void PropertiesView::endUpdate(DElement *diagramElement, bool cancelled)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2017-07-09 11:49:13 +02:00
|
|
|
QMT_ASSERT(diagramElement, return);
|
|
|
|
|
QMT_ASSERT(m_selectedDiagram, return);
|
|
|
|
|
QMT_ASSERT(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement, return);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
m_diagramController->finishUpdateElement(diagramElement, m_selectedDiagram, cancelled);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-14 16:59:30 +01:00
|
|
|
} // namespace qmt
|