forked from qt-creator/qt-creator
ModelEditor: Introduce QMT_ASSERT
This change shall solve a lot of Coverity findings Change-Id: I1e699f7363426e9b6008fc77d3f498fe3d968b4f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -57,10 +57,10 @@ void StringTextSource::setSourceId(int sourceId)
|
||||
|
||||
SourceChar StringTextSource::readNextChar()
|
||||
{
|
||||
QMT_CHECK(m_sourceId >= 0);
|
||||
QMT_CHECK(m_index >= 0);
|
||||
QMT_CHECK(m_lineNumber >= 0);
|
||||
QMT_CHECK(m_columnNumber >= 0);
|
||||
QMT_ASSERT(m_sourceId >= 0, return SourceChar());
|
||||
QMT_ASSERT(m_index >= 0, return SourceChar());
|
||||
QMT_ASSERT(m_lineNumber >= 0, return SourceChar());
|
||||
QMT_ASSERT(m_columnNumber >= 0, return SourceChar());
|
||||
|
||||
if (m_index >= m_text.length())
|
||||
return SourceChar(QChar(), SourcePos(m_sourceId, m_lineNumber, m_columnNumber));
|
||||
|
||||
@@ -66,7 +66,7 @@ void DFactory::visitMElement(const MElement *element)
|
||||
void DFactory::visitMObject(const MObject *object)
|
||||
{
|
||||
auto diagramObject = dynamic_cast<DObject *>(m_product);
|
||||
QMT_CHECK(diagramObject);
|
||||
QMT_ASSERT(diagramObject, return);
|
||||
diagramObject->setModelUid(object->uid());
|
||||
visitMElement(object);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ void DFactory::visitMItem(const MItem *item)
|
||||
void DFactory::visitMRelation(const MRelation *relation)
|
||||
{
|
||||
auto diagramRelation = dynamic_cast<DRelation *>(m_product);
|
||||
QMT_CHECK(diagramRelation);
|
||||
QMT_ASSERT(diagramRelation, return);
|
||||
diagramRelation->setModelUid(relation->uid());
|
||||
visitMElement(relation);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void DFlatAssignmentVisitor::visitDObject(const DObject *object)
|
||||
{
|
||||
visitDElement(object);
|
||||
auto target = dynamic_cast<DObject *>(m_target);
|
||||
QMT_CHECK(target);
|
||||
QMT_ASSERT(target, return);
|
||||
target->setStereotypes(object->stereotypes());
|
||||
target->setName(object->name());
|
||||
target->setPos(object->pos());
|
||||
@@ -81,7 +81,7 @@ void DFlatAssignmentVisitor::visitDClass(const DClass *klass)
|
||||
{
|
||||
visitDObject(klass);
|
||||
auto target = dynamic_cast<DClass *>(m_target);
|
||||
QMT_CHECK(target);
|
||||
QMT_ASSERT(target, return);
|
||||
target->setUmlNamespace(klass->umlNamespace());
|
||||
target->setTemplateParameters(klass->templateParameters());
|
||||
target->setTemplateDisplay(klass->templateDisplay());
|
||||
@@ -94,7 +94,7 @@ void DFlatAssignmentVisitor::visitDComponent(const DComponent *component)
|
||||
{
|
||||
visitDObject(component);
|
||||
auto target = dynamic_cast<DComponent *>(m_target);
|
||||
QMT_CHECK(target);
|
||||
QMT_ASSERT(target, return);
|
||||
target->setPlainShape(component->isPlainShape());
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ void DFlatAssignmentVisitor::visitDItem(const DItem *item)
|
||||
{
|
||||
visitDObject(item);
|
||||
auto target = dynamic_cast<DItem *>(m_target);
|
||||
QMT_CHECK(target);
|
||||
QMT_ASSERT(target, return);
|
||||
target->setVariety(target->variety());
|
||||
target->setShapeEditable(target->isShapeEditable());
|
||||
target->setShape(target->shape());
|
||||
@@ -117,7 +117,7 @@ void DFlatAssignmentVisitor::visitDRelation(const DRelation *relation)
|
||||
{
|
||||
visitDElement(relation);
|
||||
auto target = dynamic_cast<DRelation *>(m_target);
|
||||
QMT_CHECK(target);
|
||||
QMT_ASSERT(target, return);
|
||||
target->setStereotypes(relation->stereotypes());
|
||||
target->setIntermediatePoints(relation->intermediatePoints());
|
||||
}
|
||||
@@ -131,7 +131,7 @@ void DFlatAssignmentVisitor::visitDDependency(const DDependency *dependency)
|
||||
{
|
||||
visitDRelation(dependency);
|
||||
auto target = dynamic_cast<DDependency *>(m_target);
|
||||
QMT_CHECK(target);
|
||||
QMT_ASSERT(target, return);
|
||||
target->setDirection(dependency->direction());
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void DFlatAssignmentVisitor::visitDAssociation(const DAssociation *association)
|
||||
{
|
||||
visitDRelation(association);
|
||||
auto target = dynamic_cast<DAssociation *>(m_target);
|
||||
QMT_CHECK(target);
|
||||
QMT_ASSERT(target, return);
|
||||
target->setEndA(association->endA());
|
||||
target->setEndB(association->endB());
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ private:
|
||||
MDiagram *diagram = this->diagram();
|
||||
foreach (DElement *clonedElement, m_clonedElements) {
|
||||
DElement *activeElement = diagramController->findElement(clonedElement->uid(), diagram);
|
||||
QMT_CHECK(activeElement);
|
||||
QMT_ASSERT(activeElement, return);
|
||||
int row = diagram->diagramElements().indexOf(activeElement);
|
||||
emit diagramController->beginUpdateElement(row, diagram);
|
||||
// clone active element
|
||||
@@ -198,9 +198,9 @@ protected:
|
||||
Clone &clone = m_clonedElements[i];
|
||||
QMT_CHECK(!clone.m_clonedElement);
|
||||
DElement *activeElement = diagramController->findElement(clone.m_elementKey, diagram);
|
||||
QMT_CHECK(activeElement);
|
||||
QMT_ASSERT(activeElement, return);
|
||||
clone.m_indexOfElement = diagram->diagramElements().indexOf(activeElement);
|
||||
QMT_CHECK(clone.m_indexOfElement >= 0);
|
||||
QMT_ASSERT(clone.m_indexOfElement >= 0, return);
|
||||
emit diagramController->beginRemoveElement(clone.m_indexOfElement, diagram);
|
||||
DCloneDeepVisitor cloneVisitor;
|
||||
activeElement->accept(&cloneVisitor);
|
||||
@@ -221,7 +221,7 @@ protected:
|
||||
bool inserted = false;
|
||||
for (int i = m_clonedElements.count() - 1; i >= 0; --i) {
|
||||
Clone &clone = m_clonedElements[i];
|
||||
QMT_CHECK(clone.m_clonedElement);
|
||||
QMT_ASSERT(clone.m_clonedElement, return);
|
||||
QMT_CHECK(clone.m_clonedElement->uid() == clone.m_elementKey);
|
||||
emit diagramController->beginInsertElement(clone.m_indexOfElement, diagram);
|
||||
diagram->insertDiagramElement(clone.m_indexOfElement, clone.m_clonedElement);
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
DCloneDeepVisitor visitor;
|
||||
element->accept(&visitor);
|
||||
clone.m_clonedElement = visitor.cloned();
|
||||
QMT_CHECK(clone.m_clonedElement);
|
||||
QMT_ASSERT(clone.m_clonedElement, return);
|
||||
m_clonedElements.append(clone);
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ void DiagramController::removeElement(DElement *element, MDiagram *diagram)
|
||||
|
||||
DElement *DiagramController::findElement(const Uid &key, const MDiagram *diagram) const
|
||||
{
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagram, return nullptr);
|
||||
|
||||
return diagram->findDiagramElement(key);
|
||||
}
|
||||
@@ -476,7 +476,7 @@ DContainer DiagramController::cutElements(const DSelection &diagramSelection, MD
|
||||
|
||||
DContainer DiagramController::copyElements(const DSelection &diagramSelection, const MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagram, return DContainer());
|
||||
|
||||
DReferences simplifiedSelection = simplify(diagramSelection, diagram);
|
||||
DContainer copiedElements;
|
||||
@@ -491,7 +491,7 @@ DContainer DiagramController::copyElements(const DSelection &diagramSelection, c
|
||||
|
||||
void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagram, return);
|
||||
|
||||
// clone all elements and renew their keys
|
||||
QHash<Uid, Uid> renewedKeys;
|
||||
@@ -593,7 +593,7 @@ void DiagramController::onBeginUpdateObject(int row, const MObject *parent)
|
||||
void DiagramController::onEndUpdateObject(int row, const MObject *parent)
|
||||
{
|
||||
MObject *modelObject = m_modelController->object(row, parent);
|
||||
QMT_CHECK(modelObject);
|
||||
QMT_ASSERT(modelObject, return);
|
||||
auto modelPackage = dynamic_cast<MPackage *>(modelObject);
|
||||
foreach (MDiagram *diagram, m_allDiagrams) {
|
||||
DObject *object = findDelegate<DObject>(modelObject, diagram);
|
||||
@@ -622,7 +622,7 @@ void DiagramController::onBeginInsertObject(int row, const MObject *owner)
|
||||
|
||||
void DiagramController::onEndInsertObject(int row, const MObject *owner)
|
||||
{
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
|
||||
MObject *modelObject = m_modelController->object(row, owner);
|
||||
if (auto modelDiagram = dynamic_cast<MDiagram *>(modelObject)) {
|
||||
@@ -634,7 +634,7 @@ void DiagramController::onEndInsertObject(int row, const MObject *owner)
|
||||
|
||||
void DiagramController::onBeginRemoveObject(int row, const MObject *parent)
|
||||
{
|
||||
QMT_CHECK(parent);
|
||||
QMT_ASSERT(parent, return);
|
||||
|
||||
MObject *modelObject = m_modelController->object(row, parent);
|
||||
removeObjects(modelObject);
|
||||
@@ -658,7 +658,7 @@ void DiagramController::onEndMoveObject(int row, const MObject *owner)
|
||||
|
||||
// if diagram was moved update all elements because of changed context
|
||||
MObject *modelObject = m_modelController->object(row, owner);
|
||||
QMT_CHECK(modelObject);
|
||||
QMT_ASSERT(modelObject, return);
|
||||
auto modelDiagram = dynamic_cast<MDiagram *>(modelObject);
|
||||
if (modelDiagram) {
|
||||
emit beginResetDiagram(modelDiagram);
|
||||
@@ -691,7 +691,7 @@ void DiagramController::onEndUpdateRelation(int row, const MObject *owner)
|
||||
|
||||
void DiagramController::onBeginRemoveRelation(int row, const MObject *owner)
|
||||
{
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
|
||||
MRelation *modelRelation = owner->relations().at(row);
|
||||
removeRelations(modelRelation);
|
||||
@@ -719,7 +719,7 @@ void DiagramController::onEndMoveRelation(int row, const MObject *owner)
|
||||
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram,
|
||||
const QString &commandLabel)
|
||||
{
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagram, return);
|
||||
|
||||
DReferences simplifiedSelection = simplify(diagramSelection, diagram);
|
||||
if (simplifiedSelection.elements().isEmpty())
|
||||
@@ -818,7 +818,7 @@ void DiagramController::removeRelations(DElement *element, MDiagram *diagram)
|
||||
|
||||
void DiagramController::renewElementKey(DElement *element, QHash<Uid, Uid> *renewedKeys)
|
||||
{
|
||||
QMT_CHECK(renewedKeys);
|
||||
QMT_ASSERT(renewedKeys, return);
|
||||
|
||||
if (element) {
|
||||
DElement *existingElementOnDiagram = findElementOnAnyDiagram(element->uid());
|
||||
@@ -850,7 +850,7 @@ void DiagramController::updateElementFromModel(DElement *element, const MDiagram
|
||||
DUpdateVisitor visitor(element, diagram);
|
||||
|
||||
MElement *melement = m_modelController->findElement(element->modelUid());
|
||||
QMT_CHECK(melement);
|
||||
QMT_ASSERT(melement, return);
|
||||
|
||||
if (emitUpdateSignal) {
|
||||
visitor.setCheckNeedsUpdate(true);
|
||||
@@ -925,7 +925,7 @@ void DiagramController::verifyDiagramsIntegrity()
|
||||
FindDiagramsVisitor visitor(&allDiagrams);
|
||||
m_modelController->rootPackage()->accept(&visitor);
|
||||
}
|
||||
QMT_CHECK(allDiagrams == m_allDiagrams);
|
||||
QMT_ASSERT(allDiagrams == m_allDiagrams, return);
|
||||
foreach (const MDiagram *diagram, allDiagrams)
|
||||
verifyDiagramIntegrity(diagram);
|
||||
}
|
||||
@@ -937,8 +937,8 @@ void DiagramController::verifyDiagramIntegrity(const MDiagram *diagram)
|
||||
foreach (const DElement *delement, diagram->diagramElements()) {
|
||||
delementsMap.insert(delement->uid(), delement);
|
||||
if (dynamic_cast<const DObject *>(delement) != 0 || dynamic_cast<const DRelation *>(delement) != 0) {
|
||||
QMT_CHECK(delement->modelUid().isValid());
|
||||
QMT_CHECK(m_modelController->findElement(delement->modelUid()) != 0);
|
||||
QMT_ASSERT(delement->modelUid().isValid(), return);
|
||||
QMT_ASSERT(m_modelController->findElement(delement->modelUid()) != 0, return);
|
||||
if (!delement->modelUid().isValid() || m_modelController->findElement(delement->modelUid()) == 0) {
|
||||
if (const DObject *dobject = dynamic_cast<const DObject *>(delement))
|
||||
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": object" << dobject->name() << dobject->uid().toString() << "has invalid reference to model element.";
|
||||
@@ -946,17 +946,17 @@ void DiagramController::verifyDiagramIntegrity(const MDiagram *diagram)
|
||||
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid refeference to model element.";
|
||||
}
|
||||
} else {
|
||||
QMT_CHECK(!delement->modelUid().isValid());
|
||||
QMT_ASSERT(!delement->modelUid().isValid(), return);
|
||||
}
|
||||
}
|
||||
foreach (const DElement *delement, diagram->diagramElements()) {
|
||||
if (const DRelation *drelation = dynamic_cast<const DRelation *>(delement)) {
|
||||
QMT_CHECK(drelation->endAUid().isValid());
|
||||
QMT_CHECK(delementsMap.contains(drelation->endAUid()));
|
||||
QMT_ASSERT(drelation->endAUid().isValid(), return);
|
||||
QMT_ASSERT(delementsMap.contains(drelation->endAUid()), return);
|
||||
if (!drelation->endAUid().isValid() || !delementsMap.contains(drelation->endAUid()))
|
||||
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid end A.";
|
||||
QMT_CHECK(drelation->endBUid().isValid());
|
||||
QMT_CHECK(delementsMap.contains(drelation->endBUid()));
|
||||
QMT_ASSERT(drelation->endBUid().isValid(), return);
|
||||
QMT_ASSERT(delementsMap.contains(drelation->endBUid()), return);
|
||||
if (!drelation->endBUid().isValid() || !delementsMap.contains(drelation->endBUid()))
|
||||
qWarning() << "Diagram" << diagram->name() << diagram->uid().toString() << ": relation" << drelation->uid().toString() << "has invalid end B.";
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void DUpdateVisitor::visitMElement(const MElement *element)
|
||||
void DUpdateVisitor::visitMObject(const MObject *object)
|
||||
{
|
||||
auto dobject = dynamic_cast<DObject *>(m_target);
|
||||
QMT_CHECK(dobject);
|
||||
QMT_ASSERT(dobject, return);
|
||||
if (isUpdating(object->stereotypes() != dobject->stereotypes()))
|
||||
dobject->setStereotypes(object->stereotypes());
|
||||
const MObject *objectOwner = object->owner();
|
||||
@@ -107,7 +107,7 @@ void DUpdateVisitor::visitMPackage(const MPackage *package)
|
||||
void DUpdateVisitor::visitMClass(const MClass *klass)
|
||||
{
|
||||
auto dclass = dynamic_cast<DClass *>(m_target);
|
||||
QMT_CHECK(dclass);
|
||||
QMT_ASSERT(dclass, return);
|
||||
if (isUpdating(klass->umlNamespace() != dclass->umlNamespace()))
|
||||
dclass->setUmlNamespace(klass->umlNamespace());
|
||||
if (isUpdating(klass->templateParameters() != dclass->templateParameters()))
|
||||
@@ -135,7 +135,7 @@ void DUpdateVisitor::visitMCanvasDiagram(const MCanvasDiagram *diagram)
|
||||
void DUpdateVisitor::visitMItem(const MItem *item)
|
||||
{
|
||||
auto ditem = dynamic_cast<DItem *>(m_target);
|
||||
QMT_CHECK(ditem);
|
||||
QMT_ASSERT(ditem, return);
|
||||
if (isUpdating(item->isShapeEditable() != ditem->isShapeEditable()))
|
||||
ditem->setShapeEditable(item->isShapeEditable());
|
||||
if (isUpdating(item->variety() != ditem->variety()))
|
||||
@@ -146,7 +146,7 @@ void DUpdateVisitor::visitMItem(const MItem *item)
|
||||
void DUpdateVisitor::visitMRelation(const MRelation *relation)
|
||||
{
|
||||
auto drelation = dynamic_cast<DRelation *>(m_target);
|
||||
QMT_CHECK(drelation);
|
||||
QMT_ASSERT(drelation, return);
|
||||
if (isUpdating(relation->stereotypes() != drelation->stereotypes()))
|
||||
drelation->setStereotypes(relation->stereotypes());
|
||||
if (isUpdating(relation->name() != drelation->name()))
|
||||
@@ -190,7 +190,7 @@ void DUpdateVisitor::visitMRelation(const MRelation *relation)
|
||||
void DUpdateVisitor::visitMDependency(const MDependency *dependency)
|
||||
{
|
||||
auto ddependency = dynamic_cast<DDependency *>(m_target);
|
||||
QMT_CHECK(ddependency);
|
||||
QMT_ASSERT(ddependency, return);
|
||||
if (isUpdating(dependency->direction() != ddependency->direction()))
|
||||
ddependency->setDirection(dependency->direction());
|
||||
visitMRelation(dependency);
|
||||
@@ -204,7 +204,7 @@ void DUpdateVisitor::visitMInheritance(const MInheritance *inheritance)
|
||||
void DUpdateVisitor::visitMAssociation(const MAssociation *association)
|
||||
{
|
||||
auto dassociation = dynamic_cast<DAssociation *>(m_target);
|
||||
QMT_CHECK(dassociation);
|
||||
QMT_ASSERT(dassociation, return);
|
||||
DAssociationEnd endA;
|
||||
endA.setName(association->endA().name());
|
||||
endA.setCardinatlity(association->endA().cardinality());
|
||||
|
||||
@@ -211,7 +211,7 @@ DSelection DiagramSceneModel::selectedElements() const
|
||||
DSelection selection;
|
||||
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
|
||||
DElement *element = m_itemToElementMap.value(item);
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return selection);
|
||||
selection.append(element->uid(), m_diagram->uid());
|
||||
}
|
||||
return selection;
|
||||
@@ -569,8 +569,6 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
QMT_CHECK(false);
|
||||
}
|
||||
return collidingItems;
|
||||
}
|
||||
@@ -649,7 +647,7 @@ void DiagramSceneModel::mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *e
|
||||
if (newOwner) {
|
||||
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
|
||||
DElement *element = m_itemToElementMap.value(item);
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return);
|
||||
if (element->modelUid().isValid()) {
|
||||
MObject *modelObject = modelController->findObject(element->modelUid());
|
||||
if (modelObject) {
|
||||
@@ -805,15 +803,15 @@ void DiagramSceneModel::onSelectionChanged()
|
||||
auto relation = dynamic_cast<DRelation *>(element);
|
||||
if (relation) {
|
||||
QGraphicsItem *relationItem = m_elementToItemMap.value(relation);
|
||||
QMT_CHECK(relationItem);
|
||||
QMT_ASSERT(relationItem, return);
|
||||
DObject *endAObject = m_diagramController->findElement<DObject>(relation->endAUid(), m_diagram);
|
||||
QMT_CHECK(endAObject);
|
||||
QMT_ASSERT(endAObject, return);
|
||||
QGraphicsItem *endAItem = m_elementToItemMap.value(endAObject);
|
||||
QMT_CHECK(endAItem);
|
||||
QMT_ASSERT(endAItem, return);
|
||||
DObject *endBObject = m_diagramController->findElement<DObject>(relation->endBUid(), m_diagram);
|
||||
QMT_CHECK(endBObject);
|
||||
QMT_ASSERT(endBObject, return);
|
||||
QGraphicsItem *endBItem = m_elementToItemMap.value(endBObject);
|
||||
QMT_CHECK(endBItem);
|
||||
QMT_ASSERT(endBItem, return);
|
||||
if (relationItem && !relationItem->isSelected()
|
||||
&& (m_selectedItems.contains(endAItem) || newSecondarySelectedItems.contains(endAItem))
|
||||
&& (m_selectedItems.contains(endBItem) || newSecondarySelectedItems.contains(endBItem))) {
|
||||
@@ -826,7 +824,7 @@ void DiagramSceneModel::onSelectionChanged()
|
||||
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
|
||||
if (!newSecondarySelectedItems.contains(item)) {
|
||||
auto selectable = dynamic_cast<ISelectable *>(item);
|
||||
QMT_CHECK(selectable);
|
||||
QMT_ASSERT(selectable, return);
|
||||
selectable->setSecondarySelected(false);
|
||||
selectionChanged = true;
|
||||
}
|
||||
@@ -834,7 +832,7 @@ void DiagramSceneModel::onSelectionChanged()
|
||||
foreach (QGraphicsItem *item, newSecondarySelectedItems) {
|
||||
if (!m_secondarySelectedItems.contains(item)) {
|
||||
auto selectable = dynamic_cast<ISelectable *>(item);
|
||||
QMT_CHECK(selectable);
|
||||
QMT_ASSERT(selectable, return);
|
||||
selectable->setSecondarySelected(true);
|
||||
selectionChanged = true;
|
||||
}
|
||||
@@ -877,7 +875,7 @@ void DiagramSceneModel::addExtraSceneItems()
|
||||
|
||||
QGraphicsItem *DiagramSceneModel::createGraphicsItem(DElement *element)
|
||||
{
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return nullptr);
|
||||
QMT_CHECK(!m_elementToItemMap.contains(element));
|
||||
|
||||
CreationVisitor visitor(this);
|
||||
@@ -891,8 +889,8 @@ QGraphicsItem *DiagramSceneModel::createGraphicsItem(DElement *element)
|
||||
|
||||
void DiagramSceneModel::updateGraphicsItem(QGraphicsItem *item, DElement *element)
|
||||
{
|
||||
QMT_CHECK(item);
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(item, return);
|
||||
QMT_ASSERT(element, return);
|
||||
|
||||
UpdateVisitor visitor(item, this);
|
||||
element->accept(&visitor);
|
||||
@@ -945,8 +943,8 @@ void DiagramSceneModel::unsetFocusItem()
|
||||
|
||||
bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *frontItem, const QGraphicsItem *backItem)
|
||||
{
|
||||
QMT_CHECK(frontItem);
|
||||
QMT_CHECK(backItem);
|
||||
QMT_ASSERT(frontItem, return false);
|
||||
QMT_ASSERT(backItem, return false);
|
||||
|
||||
// shortcut for usual case of root items
|
||||
if (frontItem->parentItem() == 0 && backItem->parentItem() == 0) {
|
||||
|
||||
@@ -165,11 +165,11 @@ void DiagramSceneModel::UpdateVisitor::visitDObject(DObject *object)
|
||||
|
||||
void DiagramSceneModel::UpdateVisitor::visitDPackage(DPackage *package)
|
||||
{
|
||||
QMT_CHECK(m_graphicsItem);
|
||||
QMT_ASSERT(m_graphicsItem, return);
|
||||
|
||||
if (m_relatedElement == 0) {
|
||||
PackageItem *packageItem = qgraphicsitem_cast<PackageItem *>(m_graphicsItem);
|
||||
QMT_CHECK(packageItem);
|
||||
QMT_ASSERT(packageItem, return);
|
||||
QMT_CHECK(packageItem->object() == package);
|
||||
packageItem->update();
|
||||
}
|
||||
@@ -179,11 +179,11 @@ void DiagramSceneModel::UpdateVisitor::visitDPackage(DPackage *package)
|
||||
|
||||
void DiagramSceneModel::UpdateVisitor::visitDClass(DClass *klass)
|
||||
{
|
||||
QMT_CHECK(m_graphicsItem);
|
||||
QMT_ASSERT(m_graphicsItem, return);
|
||||
|
||||
if (m_relatedElement == 0) {
|
||||
ClassItem *classItem = qgraphicsitem_cast<ClassItem *>(m_graphicsItem);
|
||||
QMT_CHECK(classItem);
|
||||
QMT_ASSERT(classItem, return);
|
||||
QMT_CHECK(classItem->object() == klass);
|
||||
classItem->update();
|
||||
}
|
||||
@@ -193,11 +193,11 @@ void DiagramSceneModel::UpdateVisitor::visitDClass(DClass *klass)
|
||||
|
||||
void DiagramSceneModel::UpdateVisitor::visitDComponent(DComponent *component)
|
||||
{
|
||||
QMT_CHECK(m_graphicsItem);
|
||||
QMT_ASSERT(m_graphicsItem, return);
|
||||
|
||||
if (m_relatedElement == 0) {
|
||||
ComponentItem *componentItem = qgraphicsitem_cast<ComponentItem *>(m_graphicsItem);
|
||||
QMT_CHECK(componentItem);
|
||||
QMT_ASSERT(componentItem, return);
|
||||
QMT_CHECK(componentItem->object() == component);
|
||||
componentItem->update();
|
||||
}
|
||||
@@ -207,11 +207,11 @@ void DiagramSceneModel::UpdateVisitor::visitDComponent(DComponent *component)
|
||||
|
||||
void DiagramSceneModel::UpdateVisitor::visitDDiagram(DDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(m_graphicsItem);
|
||||
QMT_ASSERT(m_graphicsItem, return);
|
||||
|
||||
if (m_relatedElement == 0) {
|
||||
DiagramItem *documentItem = qgraphicsitem_cast<DiagramItem *>(m_graphicsItem);
|
||||
QMT_CHECK(documentItem);
|
||||
QMT_ASSERT(documentItem, return);
|
||||
QMT_CHECK(documentItem->object() == diagram);
|
||||
documentItem->update();
|
||||
}
|
||||
@@ -221,11 +221,11 @@ void DiagramSceneModel::UpdateVisitor::visitDDiagram(DDiagram *diagram)
|
||||
|
||||
void DiagramSceneModel::UpdateVisitor::visitDItem(DItem *item)
|
||||
{
|
||||
QMT_CHECK(m_graphicsItem);
|
||||
QMT_ASSERT(m_graphicsItem, return);
|
||||
|
||||
if (m_relatedElement == 0) {
|
||||
ItemItem *itemItem = qgraphicsitem_cast<ItemItem *>(m_graphicsItem);
|
||||
QMT_CHECK(itemItem);
|
||||
QMT_ASSERT(itemItem, return);
|
||||
QMT_CHECK(itemItem->object() == item);
|
||||
itemItem->update();
|
||||
}
|
||||
@@ -235,13 +235,13 @@ void DiagramSceneModel::UpdateVisitor::visitDItem(DItem *item)
|
||||
|
||||
void DiagramSceneModel::UpdateVisitor::visitDRelation(DRelation *relation)
|
||||
{
|
||||
QMT_CHECK(m_graphicsItem);
|
||||
QMT_ASSERT(m_graphicsItem, return);
|
||||
|
||||
if (m_relatedElement == 0
|
||||
|| m_relatedElement->uid() == relation->endAUid()
|
||||
|| m_relatedElement->uid() == relation->endBUid()) {
|
||||
RelationItem *relationItem = qgraphicsitem_cast<RelationItem *>(m_graphicsItem);
|
||||
QMT_CHECK(relationItem);
|
||||
QMT_ASSERT(relationItem, return);
|
||||
QMT_CHECK(relationItem->relation() == relation);
|
||||
relationItem->update();
|
||||
}
|
||||
@@ -265,10 +265,10 @@ void DiagramSceneModel::UpdateVisitor::visitDAssociation(DAssociation *associati
|
||||
void DiagramSceneModel::UpdateVisitor::visitDAnnotation(DAnnotation *annotation)
|
||||
{
|
||||
Q_UNUSED(annotation); // avoid warning in release mode
|
||||
QMT_CHECK(m_graphicsItem);
|
||||
QMT_ASSERT(m_graphicsItem, return);
|
||||
|
||||
AnnotationItem *annotationItem = qgraphicsitem_cast<AnnotationItem *>(m_graphicsItem);
|
||||
QMT_CHECK(annotationItem);
|
||||
QMT_ASSERT(annotationItem, return);
|
||||
QMT_CHECK(annotationItem->annotation() == annotation);
|
||||
annotationItem->update();
|
||||
}
|
||||
@@ -276,10 +276,10 @@ void DiagramSceneModel::UpdateVisitor::visitDAnnotation(DAnnotation *annotation)
|
||||
void DiagramSceneModel::UpdateVisitor::visitDBoundary(DBoundary *boundary)
|
||||
{
|
||||
Q_UNUSED(boundary); // avoid warning in release mode
|
||||
QMT_CHECK(m_graphicsItem);
|
||||
QMT_ASSERT(m_graphicsItem, return);
|
||||
|
||||
BoundaryItem *boundaryItem = qgraphicsitem_cast<BoundaryItem *>(m_graphicsItem);
|
||||
QMT_CHECK(boundaryItem);
|
||||
QMT_ASSERT(boundaryItem, return);
|
||||
QMT_CHECK(boundaryItem->boundary() == boundary);
|
||||
boundaryItem->update();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QMT_CHECK(option);
|
||||
QMT_ASSERT(option, return);
|
||||
|
||||
QStyleOptionGraphicsItem option2(*option);
|
||||
option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus);
|
||||
|
||||
@@ -60,7 +60,7 @@ void AssociationItem::update(const Style *style)
|
||||
updateEndLabels(m_association->endA(), m_association->endB(), &m_endAName, &m_endACardinality, style);
|
||||
updateEndLabels(m_association->endB(), m_association->endA(), &m_endBName, &m_endBCardinality, style);
|
||||
|
||||
QMT_CHECK(m_arrow);
|
||||
QMT_ASSERT(m_arrow, return);
|
||||
QGraphicsItem *endAItem = m_diagramSceneModel->graphicsItem(m_association->endAUid());
|
||||
if (!endAItem)
|
||||
return;
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QMT_CHECK(option);
|
||||
QMT_ASSERT(option, return);
|
||||
|
||||
QStyleOptionGraphicsItem option2(*option);
|
||||
option2.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus);
|
||||
|
||||
@@ -82,7 +82,7 @@ void ClassItem::update()
|
||||
updateStereotypeIconDisplay();
|
||||
|
||||
auto diagramClass = dynamic_cast<DClass *>(object());
|
||||
QMT_CHECK(diagramClass);
|
||||
QMT_ASSERT(diagramClass, return);
|
||||
|
||||
const Style *style = adaptedStyle(stereotypeIconId());
|
||||
|
||||
@@ -276,7 +276,7 @@ void ClassItem::relationDrawn(const QString &id, const QPointF &toScenePos, cons
|
||||
auto baseClass = dynamic_cast<DClass *>(targetElement);
|
||||
if (baseClass) {
|
||||
auto derivedClass = dynamic_cast<DClass *>(object());
|
||||
QMT_CHECK(derivedClass);
|
||||
QMT_ASSERT(derivedClass, return);
|
||||
diagramSceneModel()->diagramSceneController()->createInheritance(derivedClass, baseClass, intermediatePoints, diagramSceneModel()->diagram());
|
||||
}
|
||||
} else if (id == QLatin1String("dependency")) {
|
||||
@@ -287,7 +287,7 @@ void ClassItem::relationDrawn(const QString &id, const QPointF &toScenePos, cons
|
||||
auto assoziatedClass = dynamic_cast<DClass *>(targetElement);
|
||||
if (assoziatedClass) {
|
||||
auto derivedClass = dynamic_cast<DClass *>(object());
|
||||
QMT_CHECK(derivedClass);
|
||||
QMT_ASSERT(derivedClass, return);
|
||||
diagramSceneModel()->diagramSceneController()->createAssociation(derivedClass, assoziatedClass, intermediatePoints, diagramSceneModel()->diagram());
|
||||
}
|
||||
}
|
||||
@@ -316,7 +316,7 @@ bool ClassItem::handleSelectedContextMenuAction(const QString &id)
|
||||
QString ClassItem::buildDisplayName() const
|
||||
{
|
||||
auto diagramClass = dynamic_cast<DClass *>(object());
|
||||
QMT_CHECK(diagramClass);
|
||||
QMT_ASSERT(diagramClass, return QString());
|
||||
|
||||
QString name;
|
||||
if (templateDisplay() == DClass::TemplateName && !diagramClass->templateParameters().isEmpty()) {
|
||||
@@ -344,7 +344,7 @@ void ClassItem::setFromDisplayName(const QString &displayName)
|
||||
// NOTE namespace is ignored because it has its own edit field
|
||||
if (NameController::parseClassName(displayName, 0, &name, &templateParameters)) {
|
||||
auto diagramClass = dynamic_cast<DClass *>(object());
|
||||
QMT_CHECK(diagramClass);
|
||||
QMT_ASSERT(diagramClass, return);
|
||||
ModelController *modelController = diagramSceneModel()->diagramSceneController()->modelController();
|
||||
MClass *mklass = modelController->findObject<MClass>(diagramClass->modelUid());
|
||||
if (mklass && (name != mklass->name() || templateParameters != mklass->templateParameters())) {
|
||||
@@ -362,7 +362,7 @@ void ClassItem::setFromDisplayName(const QString &displayName)
|
||||
DClass::TemplateDisplay ClassItem::templateDisplay() const
|
||||
{
|
||||
auto diagramClass = dynamic_cast<DClass *>(object());
|
||||
QMT_CHECK(diagramClass);
|
||||
QMT_ASSERT(diagramClass, return DClass::TemplateSmart);
|
||||
|
||||
DClass::TemplateDisplay templateDisplay = diagramClass->templateDisplay();
|
||||
if (templateDisplay == DClass::TemplateSmart) {
|
||||
@@ -560,12 +560,12 @@ void ClassItem::updateMembers(const Style *style)
|
||||
QString *text = 0;
|
||||
|
||||
auto dclass = dynamic_cast<DClass *>(object());
|
||||
QMT_CHECK(dclass);
|
||||
QMT_ASSERT(dclass, return);
|
||||
|
||||
foreach (const MClassMember &member, dclass->members()) {
|
||||
switch (member.memberType()) {
|
||||
case MClassMember::MemberUndefined:
|
||||
QMT_CHECK(false);
|
||||
QMT_ASSERT(false, return);
|
||||
break;
|
||||
case MClassMember::MemberAttribute:
|
||||
currentVisibility = &attributesVisibility;
|
||||
|
||||
@@ -237,7 +237,7 @@ void ComponentItem::relationDrawn(const QString &id, const QPointF &toScenePos,
|
||||
bool ComponentItem::hasPlainShape() const
|
||||
{
|
||||
auto diagramComponent = dynamic_cast<DComponent *>(object());
|
||||
QMT_CHECK(diagramComponent);
|
||||
QMT_ASSERT(diagramComponent, return false);
|
||||
return diagramComponent->isPlainShape();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ void ItemItem::update()
|
||||
|
||||
auto diagramItem = dynamic_cast<DItem *>(object());
|
||||
Q_UNUSED(diagramItem); // avoid warning about unsed variable
|
||||
QMT_CHECK(diagramItem);
|
||||
QMT_ASSERT(diagramItem, return);
|
||||
|
||||
const Style *style = adaptedStyle(shapeIconId());
|
||||
|
||||
|
||||
@@ -674,7 +674,7 @@ bool ObjectItem::showContext() const
|
||||
// TODO Because of this algorithm adding, moving, removing of one item need to update() all colliding items as well
|
||||
QMT_CHECK(object()->modelUid().isValid());
|
||||
MObject *mobject = m_diagramSceneModel->diagramController()->modelController()->findObject(object()->modelUid());
|
||||
QMT_CHECK(mobject);
|
||||
QMT_ASSERT(mobject, return false);
|
||||
MObject *owner = mobject->owner();
|
||||
if (owner) {
|
||||
foreach (QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::CollidingOuterItems)) {
|
||||
@@ -778,7 +778,7 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if (selectedAction) {
|
||||
auto action = dynamic_cast<ContextMenuAction *>(selectedAction);
|
||||
QMT_CHECK(action);
|
||||
QMT_ASSERT(action, return);
|
||||
bool handled = handleSelectedContextMenuAction(action->id());
|
||||
handled |= element_tasks->handleContextMenuAction(object(), diagramSceneModel()->diagram(), action->id());
|
||||
if (!handled) {
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
void visitDInheritance(const DInheritance *inheritance)
|
||||
{
|
||||
DObject *baseObject = m_diagramSceneModel->diagramController()->findElement<DObject>(inheritance->base(), m_diagramSceneModel->diagram());
|
||||
QMT_CHECK(baseObject);
|
||||
QMT_ASSERT(baseObject, return);
|
||||
bool baseIsInterface = false;
|
||||
bool lollipopDisplay = false;
|
||||
if (baseObject) {
|
||||
@@ -289,7 +289,7 @@ QPointF RelationItem::grabHandle(int index)
|
||||
} else {
|
||||
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints();
|
||||
--index;
|
||||
QMT_CHECK(index >= 0 && index < intermediatePoints.size());
|
||||
QMT_ASSERT(index >= 0 && index < intermediatePoints.size(), return QPointF());
|
||||
return intermediatePoints.at(index).pos();
|
||||
}
|
||||
}
|
||||
@@ -337,7 +337,7 @@ void RelationItem::setHandlePos(int index, const QPointF &pos)
|
||||
} else {
|
||||
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints();
|
||||
--index;
|
||||
QMT_CHECK(index >= 0 && index < intermediatePoints.size());
|
||||
QMT_ASSERT(index >= 0 && index < intermediatePoints.size(), return);
|
||||
intermediatePoints[index].setPos(pos);
|
||||
|
||||
m_diagramSceneModel->diagramController()->startUpdateElement(m_relation, m_diagramSceneModel->diagram(), DiagramController::UpdateMinor);
|
||||
@@ -361,7 +361,7 @@ void RelationItem::dropHandle(int index, double rasterWidth, double rasterHeight
|
||||
} else {
|
||||
QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints();
|
||||
--index;
|
||||
QMT_CHECK(index >= 0 && index < intermediatePoints.size());
|
||||
QMT_ASSERT(index >= 0 && index < intermediatePoints.size(), return);
|
||||
|
||||
QPointF pos = intermediatePoints.at(index).pos();
|
||||
double x = qRound(pos.x() / rasterWidth) * rasterWidth;
|
||||
@@ -486,7 +486,7 @@ QPointF RelationItem::calcEndPoint(const Uid &end, const Uid &otherEnd, int near
|
||||
// otherEndPos will not be used
|
||||
} else {
|
||||
DObject *endOtherObject = m_diagramSceneModel->diagramController()->findElement<DObject>(otherEnd, m_diagramSceneModel->diagram());
|
||||
QMT_CHECK(endOtherObject);
|
||||
QMT_ASSERT(endOtherObject, return QPointF());
|
||||
if (endOtherObject)
|
||||
otherEndPos = endOtherObject->pos();
|
||||
}
|
||||
@@ -502,7 +502,7 @@ QPointF RelationItem::calcEndPoint(const Uid &end, const QPointF &otherEndPos, i
|
||||
QPointF endPos;
|
||||
if (endObjectItem) {
|
||||
DObject *endObject = m_diagramSceneModel->diagramController()->findElement<DObject>(end, m_diagramSceneModel->diagram());
|
||||
QMT_CHECK(endObject);
|
||||
QMT_ASSERT(endObject, return QPointF());
|
||||
bool preferAxis = false;
|
||||
QPointF otherPos;
|
||||
if (nearestIntermediatePointIndex >= 0 && nearestIntermediatePointIndex < m_relation->intermediatePoints().size()) {
|
||||
|
||||
@@ -73,7 +73,7 @@ void LatchController::setDiagramSceneModel(DiagramSceneModel *diagramSceneModel)
|
||||
|
||||
void LatchController::addToGraphicsScene(QGraphicsScene *graphicsScene)
|
||||
{
|
||||
QMT_CHECK(graphicsScene);
|
||||
QMT_ASSERT(graphicsScene, return);
|
||||
graphicsScene->addItem(m_horizontalAlignLine);
|
||||
graphicsScene->addItem(m_verticalAlignLine);
|
||||
}
|
||||
|
||||
@@ -346,13 +346,13 @@ QPointF ArrowItem::calcPointAtPercent(double percentage) const
|
||||
|
||||
QLineF ArrowItem::firstLineSegment() const
|
||||
{
|
||||
QTC_ASSERT(m_points.size() > 1, return QLineF());
|
||||
QMT_ASSERT(m_points.size() > 1, return QLineF());
|
||||
return QLineF(m_points.at(0), m_points.at(1));
|
||||
}
|
||||
|
||||
QLineF ArrowItem::lastLineSegment() const
|
||||
{
|
||||
QTC_ASSERT(m_points.size() > 1, return QLineF());
|
||||
QMT_ASSERT(m_points.size() > 1, return QLineF());
|
||||
return QLineF(m_points.at(m_points.size() - 1), m_points.at(m_points.size() - 2));
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ void ArrowItem::update(const Style *style)
|
||||
|
||||
void ArrowItem::updateShaft(const Style *style)
|
||||
{
|
||||
QTC_ASSERT(m_shaftItem, return);
|
||||
QMT_ASSERT(m_shaftItem, return);
|
||||
|
||||
QPen pen(style->linePen());
|
||||
if (m_shaft == ShaftDashed)
|
||||
@@ -424,8 +424,8 @@ void ArrowItem::updateHeadGeometry(GraphicsHeadItem **headItem, const QPointF &p
|
||||
|
||||
void ArrowItem::updateGeometry()
|
||||
{
|
||||
QTC_ASSERT(m_points.size() > 1, return);
|
||||
QTC_ASSERT(m_shaftItem, return);
|
||||
QMT_ASSERT(m_points.size() > 1, return);
|
||||
QMT_ASSERT(m_shaftItem, return);
|
||||
|
||||
prepareGeometryChange();
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ QList<QPointF> PathSelectionItem::points() const
|
||||
|
||||
void PathSelectionItem::setPoints(const QList<QPointF> &points)
|
||||
{
|
||||
QMT_CHECK(points.size() >= 2);
|
||||
QMT_ASSERT(points.size() >= 2, return);
|
||||
prepareGeometryChange();
|
||||
|
||||
GraphicsHandleItem *focusEndBItem = 0;
|
||||
|
||||
@@ -157,7 +157,7 @@ void RectangularSelectionItem::setSecondarySelected(bool secondarySelected)
|
||||
|
||||
void RectangularSelectionItem::update()
|
||||
{
|
||||
QMT_CHECK(HandleFirst == 0 && HandleLast == 7);
|
||||
QMT_ASSERT(HandleFirst == 0 && HandleLast == 7, return);
|
||||
prepareGeometryChange();
|
||||
|
||||
for (int i = 0; i <= 7; ++i) {
|
||||
|
||||
@@ -142,13 +142,13 @@ DiagramSceneModel *DiagramsManager::bindDiagramSceneModel(MDiagram *diagram)
|
||||
DiagramSceneModel *DiagramsManager::diagramSceneModel(const MDiagram *diagram) const
|
||||
{
|
||||
const ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.value(diagram->uid());
|
||||
QMT_CHECK(managedDiagram);
|
||||
QMT_ASSERT(managedDiagram, return nullptr);
|
||||
return managedDiagram->diagramSceneModel();
|
||||
}
|
||||
|
||||
void DiagramsManager::unbindDiagramSceneModel(const MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagram, return);
|
||||
ManagedDiagram *managedDiagram = m_diagramUidToManagedDiagramMap.take(diagram->uid());
|
||||
QMT_CHECK(managedDiagram);
|
||||
delete managedDiagram;
|
||||
|
||||
@@ -58,7 +58,7 @@ void DiagramsView::setDiagramsManager(DiagramsManager *diagramsManager)
|
||||
|
||||
void DiagramsView::openDiagram(MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagram, return);
|
||||
DiagramView *diagramView = m_diagramViews.value(diagram->uid());
|
||||
if (!diagramView) {
|
||||
DiagramSceneModel *diagramSceneModel = m_diagramsManager->bindDiagramSceneModel(diagram);
|
||||
|
||||
@@ -54,7 +54,7 @@ void StackedDiagramsView::setDiagramsManager(DiagramsManager *diagramsManager)
|
||||
|
||||
void StackedDiagramsView::openDiagram(MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagram, return);
|
||||
DiagramView *diagramView = m_diagramViews.value(diagram->uid());
|
||||
if (!diagramView) {
|
||||
DiagramSceneModel *diagramSceneModel = m_diagramsManager->bindDiagramSceneModel(diagram);
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
bool GeometryUtilities::placeRectAtLine(const QRectF &rect, const QLineF &line, double lineOffset, double distance,
|
||||
const QLineF &intersectionLine, QPointF *placement, Side *horizontalAlignedSide)
|
||||
{
|
||||
QMT_CHECK(placement);
|
||||
QMT_ASSERT(placement, return false);
|
||||
|
||||
QList<Candidate> candidates;
|
||||
candidates << Candidate(QVector2D(rect.topRight() - rect.topLeft()), QPointF(0.0, 0.0), SideTop)
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
|
||||
bool contains(const T *t) const
|
||||
{
|
||||
QMT_CHECK(t);
|
||||
QMT_ASSERT(t, return false);
|
||||
return contains(t->uid());
|
||||
}
|
||||
|
||||
@@ -101,13 +101,13 @@ public:
|
||||
|
||||
T *at(int index) const
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index < m_handleList.size());
|
||||
QMT_ASSERT(index >= 0 && index < m_handleList.size(), return nullptr);
|
||||
return m_handleList.at(index).target();
|
||||
}
|
||||
|
||||
T *at(int index)
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index < m_handleList.size());
|
||||
QMT_ASSERT(index >= 0 && index < m_handleList.size(), return nullptr);
|
||||
return m_handleList.at(index);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
|
||||
int indexOf(const T *t) const
|
||||
{
|
||||
QMT_CHECK(t);
|
||||
QMT_ASSERT(t, return -1);
|
||||
return indexOf(t->uid());
|
||||
}
|
||||
|
||||
@@ -164,27 +164,27 @@ public:
|
||||
|
||||
void add(T *t)
|
||||
{
|
||||
QMT_CHECK(t);
|
||||
QMT_ASSERT(t, return);
|
||||
m_handleList.append(Handle<T>(t));
|
||||
}
|
||||
|
||||
void insert(int beforeIndex, const Uid &uid)
|
||||
{
|
||||
QMT_CHECK(beforeIndex >= 0 && beforeIndex <= m_handleList.size());
|
||||
QMT_CHECK(uid.isValid());
|
||||
QMT_ASSERT(beforeIndex >= 0 && beforeIndex <= m_handleList.size(), return);
|
||||
QMT_ASSERT(uid.isValid(), return);
|
||||
m_handleList.insert(beforeIndex, Handle<T>(uid));
|
||||
}
|
||||
|
||||
void insert(int beforeIndex, T *t)
|
||||
{
|
||||
QMT_CHECK(beforeIndex >= 0 && beforeIndex <= m_handleList.size());
|
||||
QMT_CHECK(t);
|
||||
QMT_ASSERT(beforeIndex >= 0 && beforeIndex <= m_handleList.size(), return);
|
||||
QMT_ASSERT(t, return);
|
||||
m_handleList.insert(beforeIndex, Handle<T>(t));
|
||||
}
|
||||
|
||||
void remove(int index)
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index < size());
|
||||
QMT_ASSERT(index >= 0 && index < size(), return);
|
||||
if (m_takesOwnership) {
|
||||
T *t = m_handleList.at(index).target();
|
||||
m_handleList.removeAt(index);
|
||||
@@ -201,13 +201,13 @@ public:
|
||||
|
||||
void remove(T *t)
|
||||
{
|
||||
QMT_CHECK(t);
|
||||
QMT_ASSERT(t, return);
|
||||
remove(indexOf(t));
|
||||
}
|
||||
|
||||
T * take(int index)
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index < size());
|
||||
QMT_ASSERT(index >= 0 && index < size(), return nullptr);
|
||||
T *t = m_handleList.at(index).target();
|
||||
m_handleList.removeAt(index);
|
||||
return t;
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
|
||||
T *take(T *t)
|
||||
{
|
||||
QMT_CHECK(t);
|
||||
QMT_ASSERT(t, return nullptr);
|
||||
return take(indexOf(t));
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ void QCompressedDevice::close()
|
||||
|
||||
qint64 QCompressedDevice::readData(char *data, qint64 maxlen)
|
||||
{
|
||||
QMT_CHECK(m_targetDevice);
|
||||
QMT_CHECK(m_targetDevice->isOpen());
|
||||
QMT_CHECK(m_targetDevice->openMode() == QIODevice::ReadOnly);
|
||||
QMT_ASSERT(m_targetDevice, return 0);
|
||||
QMT_ASSERT(m_targetDevice->isOpen(), return 0);
|
||||
QMT_ASSERT(m_targetDevice->openMode() == QIODevice::ReadOnly, return 0);
|
||||
|
||||
if (m_bytesInBuffer == 0) {
|
||||
QByteArray compressedBuffer;
|
||||
@@ -86,9 +86,9 @@ qint64 QCompressedDevice::readData(char *data, qint64 maxlen)
|
||||
|
||||
qint64 QCompressedDevice::writeData(const char *data, qint64 len)
|
||||
{
|
||||
QMT_CHECK(m_targetDevice);
|
||||
QMT_CHECK(m_targetDevice->isOpen());
|
||||
QMT_CHECK(m_targetDevice->openMode() == QIODevice::WriteOnly);
|
||||
QMT_ASSERT(m_targetDevice, return 0);
|
||||
QMT_ASSERT(m_targetDevice->isOpen(), return 0);
|
||||
QMT_ASSERT(m_targetDevice->openMode() == QIODevice::WriteOnly, return 0);
|
||||
|
||||
m_buffer.append(data, len);
|
||||
if (m_buffer.size() > 1024*1024) {
|
||||
@@ -106,8 +106,8 @@ qint64 QCompressedDevice::writeData(const char *data, qint64 len)
|
||||
qint64 QCompressedDevice::flush()
|
||||
{
|
||||
if (openMode() == QIODevice::WriteOnly && m_buffer.size() > 0) {
|
||||
QMT_CHECK(m_targetDevice->isOpen());
|
||||
QMT_CHECK(m_targetDevice->openMode() == QIODevice::WriteOnly);
|
||||
QMT_ASSERT(m_targetDevice->isOpen(), return 0);
|
||||
QMT_ASSERT(m_targetDevice->openMode() == QIODevice::WriteOnly, return 0);
|
||||
QByteArray compressedBuffer = qCompress(m_buffer);
|
||||
int compressedLen = static_cast<int>(compressedBuffer.size());
|
||||
if (m_targetDevice->write(reinterpret_cast<const char *>(&compressedLen), sizeof(int)) != sizeof(int))
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "utils/qtcassert.h"
|
||||
|
||||
// TODO extend with parameter action
|
||||
#define QMT_CHECK(condition) QTC_CHECK(condition)
|
||||
#define QMT_ASSERT(condition, action) QTC_ASSERT(condition, action)
|
||||
// TODO implement logging of where and what
|
||||
#define QMT_CHECK_X(condition, where, what) QTC_CHECK(condition)
|
||||
#define QMT_CHECK_X(condition, where, what) QMT_CHECK(condition)
|
||||
|
||||
@@ -81,21 +81,21 @@ void MDiagram::setDiagramElements(const QList<DElement *> &elements)
|
||||
|
||||
void MDiagram::addDiagramElement(DElement *element)
|
||||
{
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return);
|
||||
|
||||
m_elements.append(element);
|
||||
}
|
||||
|
||||
void MDiagram::insertDiagramElement(int beforeElement, DElement *element)
|
||||
{
|
||||
QMT_CHECK(beforeElement >= 0 && beforeElement <= m_elements.size());
|
||||
QMT_ASSERT(beforeElement >= 0 && beforeElement <= m_elements.size(), return);
|
||||
|
||||
m_elements.insert(beforeElement, element);
|
||||
}
|
||||
|
||||
void MDiagram::removeDiagramElement(int index)
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index < m_elements.size());
|
||||
QMT_ASSERT(index >= 0 && index < m_elements.size(), return);
|
||||
|
||||
delete m_elements.at(index);
|
||||
m_elements.removeAt(index);
|
||||
@@ -103,7 +103,7 @@ void MDiagram::removeDiagramElement(int index)
|
||||
|
||||
void MDiagram::removeDiagramElement(DElement *element)
|
||||
{
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return);
|
||||
|
||||
removeDiagramElement(m_elements.indexOf(element));
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ void MObject::addChild(const Uid &uid)
|
||||
|
||||
void MObject::addChild(MObject *child)
|
||||
{
|
||||
QMT_CHECK(child);
|
||||
QMT_CHECK(child->owner() == 0);
|
||||
QMT_ASSERT(child, return);
|
||||
QMT_ASSERT(child->owner() == 0, return);
|
||||
m_children.add(child);
|
||||
child->setOwner(this);
|
||||
}
|
||||
@@ -95,15 +95,15 @@ void MObject::insertChild(int beforeIndex, const Uid &uid)
|
||||
|
||||
void MObject::insertChild(int beforeIndex, MObject *child)
|
||||
{
|
||||
QMT_CHECK(child);
|
||||
QMT_CHECK(child->owner() == 0);
|
||||
QMT_ASSERT(child, return);
|
||||
QMT_ASSERT(child->owner() == 0, return);
|
||||
m_children.insert(beforeIndex, child);
|
||||
child->setOwner(this);
|
||||
}
|
||||
|
||||
void MObject::removeChild(const Uid &uid)
|
||||
{
|
||||
QMT_CHECK(m_children.contains(uid));
|
||||
QMT_ASSERT(m_children.contains(uid), return);
|
||||
MObject *child = m_children.find(uid);
|
||||
if (child)
|
||||
child->setOwner(0);
|
||||
@@ -112,15 +112,15 @@ void MObject::removeChild(const Uid &uid)
|
||||
|
||||
void MObject::removeChild(MObject *child)
|
||||
{
|
||||
QMT_CHECK(child);
|
||||
QMT_CHECK(m_children.contains(child));
|
||||
QMT_ASSERT(child, return);
|
||||
QMT_ASSERT(m_children.contains(child), return);
|
||||
child->setOwner(0);
|
||||
m_children.remove(child);
|
||||
}
|
||||
|
||||
void MObject::decontrolChild(const Uid &uid)
|
||||
{
|
||||
QMT_CHECK(m_children.contains(uid));
|
||||
QMT_ASSERT(m_children.contains(uid), return);
|
||||
MObject *child = m_children.find(uid);
|
||||
if (child)
|
||||
child->setOwner(0);
|
||||
@@ -129,8 +129,8 @@ void MObject::decontrolChild(const Uid &uid)
|
||||
|
||||
void MObject::decontrolChild(MObject *child)
|
||||
{
|
||||
QMT_CHECK(child);
|
||||
QMT_CHECK(m_children.contains(child));
|
||||
QMT_ASSERT(child, return);
|
||||
QMT_ASSERT(m_children.contains(child), return);
|
||||
child->setOwner(0);
|
||||
m_children.take(child);
|
||||
}
|
||||
@@ -151,30 +151,30 @@ void MObject::addRelation(const Uid &uid)
|
||||
|
||||
void MObject::addRelation(MRelation *relation)
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
QMT_CHECK(relation->owner() == 0);
|
||||
QMT_ASSERT(relation, return);
|
||||
QMT_ASSERT(relation->owner() == 0, return);
|
||||
relation->setOwner(this);
|
||||
m_relations.add(relation);
|
||||
}
|
||||
|
||||
void MObject::insertRelation(int beforeIndex, MRelation *relation)
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
QMT_CHECK(relation->owner() == 0);
|
||||
QMT_ASSERT(relation, return);
|
||||
QMT_ASSERT(relation->owner() == 0, return);
|
||||
relation->setOwner(this);
|
||||
m_relations.insert(beforeIndex, relation);
|
||||
}
|
||||
|
||||
void MObject::removeRelation(MRelation *relation)
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return);
|
||||
relation->setOwner(0);
|
||||
m_relations.remove(relation);
|
||||
}
|
||||
|
||||
void MObject::decontrolRelation(MRelation *relation)
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return);
|
||||
relation->setOwner(0);
|
||||
m_relations.take(relation);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ MSourceExpansion &MSourceExpansion::operator=(const MSourceExpansion &rhs)
|
||||
MSourceExpansion *MSourceExpansion::clone(const MElement &rhs) const
|
||||
{
|
||||
auto rightExpansion = dynamic_cast<MSourceExpansion *>(rhs.expansion());
|
||||
QMT_CHECK(rightExpansion);
|
||||
QMT_ASSERT(rightExpansion, return nullptr);
|
||||
auto expansion = new MSourceExpansion(*rightExpansion);
|
||||
return expansion;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void MCloneVisitor::visitMDiagram(const MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(m_cloned);
|
||||
auto cloned = dynamic_cast<MDiagram *>(m_cloned);
|
||||
QMT_CHECK(cloned);
|
||||
QMT_ASSERT(cloned, return);
|
||||
foreach (const DElement *element, diagram->diagramElements()) {
|
||||
DCloneDeepVisitor visitor;
|
||||
element->accept(&visitor);
|
||||
@@ -152,13 +152,13 @@ void MCloneDeepVisitor::visitMObject(const MObject *object)
|
||||
QMT_CHECK(m_cloned);
|
||||
visitMElement(object);
|
||||
auto cloned = dynamic_cast<MObject *>(m_cloned);
|
||||
QMT_CHECK(cloned);
|
||||
QMT_ASSERT(cloned, return);
|
||||
foreach (const Handle<MObject> &handle, object->children()) {
|
||||
if (handle.hasTarget()) {
|
||||
MCloneDeepVisitor visitor;
|
||||
handle.target()->accept(&visitor);
|
||||
auto clonedChild = dynamic_cast<MObject *>(visitor.cloned());
|
||||
QMT_CHECK(clonedChild);
|
||||
QMT_ASSERT(clonedChild, return);
|
||||
cloned->addChild(clonedChild);
|
||||
} else {
|
||||
cloned->addChild(handle.uid());
|
||||
@@ -169,7 +169,7 @@ void MCloneDeepVisitor::visitMObject(const MObject *object)
|
||||
MCloneDeepVisitor visitor;
|
||||
handle.target()->accept(&visitor);
|
||||
auto clonedRelation = dynamic_cast<MRelation *>(visitor.cloned());
|
||||
QMT_CHECK(clonedRelation);
|
||||
QMT_ASSERT(clonedRelation, return);
|
||||
cloned->addRelation(clonedRelation);
|
||||
} else {
|
||||
cloned->addRelation(handle.uid());
|
||||
@@ -202,7 +202,7 @@ void MCloneDeepVisitor::visitMDiagram(const MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(m_cloned);
|
||||
auto cloned = dynamic_cast<MDiagram *>(m_cloned);
|
||||
QMT_CHECK(cloned);
|
||||
QMT_ASSERT(cloned, return);
|
||||
foreach (const DElement *element, diagram->diagramElements()) {
|
||||
DCloneDeepVisitor visitor;
|
||||
element->accept(&visitor);
|
||||
@@ -231,7 +231,7 @@ void MCloneDeepVisitor::visitMRelation(const MRelation *relation)
|
||||
QMT_CHECK(m_cloned);
|
||||
visitMElement(relation);
|
||||
auto cloned = dynamic_cast<MRelation *>(m_cloned);
|
||||
QMT_CHECK(cloned);
|
||||
QMT_ASSERT(cloned, return);
|
||||
cloned->setEndAUid(relation->endAUid());
|
||||
cloned->setEndBUid(relation->endBUid());
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ void MFlatAssignmentVisitor::visitMObject(const MObject *object)
|
||||
{
|
||||
visitMElement(object);
|
||||
auto targetObject = dynamic_cast<MObject *>(m_target);
|
||||
QMT_CHECK(targetObject);
|
||||
QMT_ASSERT(targetObject, return);
|
||||
targetObject->setName(object->name());
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ void MFlatAssignmentVisitor::visitMClass(const MClass *klass)
|
||||
{
|
||||
visitMObject(klass);
|
||||
auto targetClass = dynamic_cast<MClass *>(m_target);
|
||||
QMT_CHECK(targetClass);
|
||||
QMT_ASSERT(targetClass, return);
|
||||
targetClass->setUmlNamespace(klass->umlNamespace());
|
||||
targetClass->setTemplateParameters(klass->templateParameters());
|
||||
targetClass->setMembers(klass->members());
|
||||
@@ -82,7 +82,7 @@ void MFlatAssignmentVisitor::visitMDiagram(const MDiagram *diagram)
|
||||
{
|
||||
visitMObject(diagram);
|
||||
auto targetDiagram = dynamic_cast<MDiagram *>(m_target);
|
||||
QMT_CHECK(targetDiagram);
|
||||
QMT_ASSERT(targetDiagram, return);
|
||||
targetDiagram->setToolbarId(diagram->toolbarId());
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ void MFlatAssignmentVisitor::visitMItem(const MItem *item)
|
||||
{
|
||||
visitMObject(item);
|
||||
auto targetItem = dynamic_cast<MItem *>(m_target);
|
||||
QMT_CHECK(targetItem);
|
||||
QMT_ASSERT(targetItem, return);
|
||||
targetItem->setVarietyEditable(item->isVarietyEditable());
|
||||
targetItem->setVariety(item->variety());
|
||||
targetItem->setShapeEditable(item->isShapeEditable());
|
||||
@@ -105,7 +105,7 @@ void MFlatAssignmentVisitor::visitMRelation(const MRelation *relation)
|
||||
{
|
||||
visitMElement(relation);
|
||||
auto targetRelation = dynamic_cast<MRelation *>(m_target);
|
||||
QMT_CHECK(targetRelation);
|
||||
QMT_ASSERT(targetRelation, return);
|
||||
targetRelation->setName(relation->name());
|
||||
targetRelation->setEndAUid(relation->endAUid());
|
||||
targetRelation->setEndBUid(relation->endBUid());
|
||||
@@ -115,7 +115,7 @@ void MFlatAssignmentVisitor::visitMDependency(const MDependency *dependency)
|
||||
{
|
||||
visitMRelation(dependency);
|
||||
auto targetDependency = dynamic_cast<MDependency *>(m_target);
|
||||
QMT_CHECK(targetDependency);
|
||||
QMT_ASSERT(targetDependency, return);
|
||||
targetDependency->setDirection(dependency->direction());
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void MFlatAssignmentVisitor::visitMAssociation(const MAssociation *association)
|
||||
{
|
||||
visitMRelation(association);
|
||||
auto targetAssociation = dynamic_cast<MAssociation *>(m_target);
|
||||
QMT_CHECK(targetAssociation);
|
||||
QMT_ASSERT(targetAssociation, return);
|
||||
targetAssociation->setEndA(association->endA());
|
||||
targetAssociation->setEndB(association->endB());
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
void assign()
|
||||
{
|
||||
MObject *object = m_modelController->findObject<MObject>(m_object->uid());
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return);
|
||||
int row = 0;
|
||||
MObject *parent = object->owner();
|
||||
if (!parent) {
|
||||
@@ -173,9 +173,9 @@ private:
|
||||
void assign()
|
||||
{
|
||||
MRelation *relation = m_modelController->findRelation<MRelation>(m_relation->uid());
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return);
|
||||
MObject *owner = relation->owner();
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
int row = owner->relations().indexOf(relation);
|
||||
emit m_modelController->beginUpdateRelation(row, owner);
|
||||
MCloneVisitor cloneVisitor;
|
||||
@@ -226,10 +226,10 @@ public:
|
||||
bool inserted = false;
|
||||
for (int i = m_clonedElements.count() - 1; i >= 0; --i) {
|
||||
Clone &clone = m_clonedElements[i];
|
||||
QMT_CHECK(clone.m_clonedElement);
|
||||
QMT_ASSERT(clone.m_clonedElement, return);
|
||||
QMT_CHECK(clone.m_clonedElement->uid() == clone.m_elementKey);
|
||||
MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey);
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
QMT_CHECK(clone.m_indexOfElement >= 0);
|
||||
switch (clone.m_elementType) {
|
||||
case TypeObject:
|
||||
@@ -275,12 +275,12 @@ public:
|
||||
Clone &clone = m_clonedElements[i];
|
||||
QMT_CHECK(!clone.m_clonedElement);
|
||||
MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey);
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
switch (clone.m_elementType) {
|
||||
case TypeObject:
|
||||
{
|
||||
MObject *object = m_modelController->findObject<MObject>(clone.m_elementKey);
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return);
|
||||
clone.m_indexOfElement = owner->children().indexOf(object);
|
||||
QMT_CHECK(clone.m_indexOfElement >= 0);
|
||||
emit m_modelController->beginRemoveObject(clone.m_indexOfElement, owner);
|
||||
@@ -296,7 +296,7 @@ public:
|
||||
case TypeRelation:
|
||||
{
|
||||
MRelation *relation = m_modelController->findRelation<MRelation>(clone.m_elementKey);
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return);
|
||||
clone.m_indexOfElement = owner->relations().indexOf(relation);
|
||||
QMT_CHECK(clone.m_indexOfElement >= 0);
|
||||
emit m_modelController->beginRemoveRelation(clone.m_indexOfElement, owner);
|
||||
@@ -360,7 +360,7 @@ public:
|
||||
MCloneDeepVisitor visitor;
|
||||
element->accept(&visitor);
|
||||
clone.m_clonedElement = visitor.cloned();
|
||||
QMT_CHECK(clone.m_clonedElement);
|
||||
QMT_ASSERT(clone.m_clonedElement, return);
|
||||
m_clonedElements.append(clone);
|
||||
}
|
||||
|
||||
@@ -372,12 +372,12 @@ public:
|
||||
Clone &clone = m_clonedElements[i];
|
||||
QMT_CHECK(!clone.m_clonedElement);
|
||||
MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey);
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
switch (clone.m_elementType) {
|
||||
case TypeObject:
|
||||
{
|
||||
MObject *object = m_modelController->findObject<MObject>(clone.m_elementKey);
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return);
|
||||
clone.m_indexOfElement = owner->children().indexOf(object);
|
||||
QMT_CHECK(clone.m_indexOfElement >= 0);
|
||||
emit m_modelController->beginRemoveObject(clone.m_indexOfElement, owner);
|
||||
@@ -393,7 +393,7 @@ public:
|
||||
case TypeRelation:
|
||||
{
|
||||
MRelation *relation = m_modelController->findRelation<MRelation>(clone.m_elementKey);
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return);
|
||||
clone.m_indexOfElement = owner->relations().indexOf(relation);
|
||||
QMT_CHECK(clone.m_indexOfElement >= 0);
|
||||
emit m_modelController->beginRemoveRelation(clone.m_indexOfElement, owner);
|
||||
@@ -423,9 +423,9 @@ public:
|
||||
bool inserted = false;
|
||||
for (int i = m_clonedElements.count() - 1; i >= 0; --i) {
|
||||
Clone &clone = m_clonedElements[i];
|
||||
QMT_CHECK(clone.m_clonedElement);
|
||||
QMT_ASSERT(clone.m_clonedElement, return);
|
||||
MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey);
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
QMT_CHECK(clone.m_indexOfElement >= 0);
|
||||
switch (clone.m_elementType) {
|
||||
case TypeObject:
|
||||
@@ -502,11 +502,11 @@ private:
|
||||
void swap()
|
||||
{
|
||||
MObject *object = m_modelController->findObject(m_objectKey);
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return);
|
||||
MObject *formerOwner = object->owner();
|
||||
int formerRow = formerOwner->children().indexOf(object);
|
||||
MObject *newOwner = m_modelController->findObject(m_ownerKey);
|
||||
QMT_CHECK(newOwner);
|
||||
QMT_ASSERT(newOwner, return);
|
||||
emit m_modelController->beginMoveObject(formerRow, formerOwner);
|
||||
formerOwner->decontrolChild(object);
|
||||
newOwner->insertChild(m_indexOfElement, object);
|
||||
@@ -558,11 +558,11 @@ private:
|
||||
void swap()
|
||||
{
|
||||
MRelation *relation = m_modelController->findRelation(m_relationKey);
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return);
|
||||
MObject *formerOwner = relation->owner();
|
||||
int formerRow = formerOwner->relations().indexOf(relation);
|
||||
MObject *newOwner = m_modelController->findObject(m_ownerKey);
|
||||
QMT_CHECK(newOwner);
|
||||
QMT_ASSERT(newOwner, return);
|
||||
emit m_modelController->beginMoveRelation(formerRow, formerOwner);
|
||||
formerOwner->decontrolRelation(relation);
|
||||
newOwner->insertRelation(m_indexOfElement, relation);
|
||||
@@ -609,7 +609,7 @@ void ModelController::setUndoController(UndoController *undoController)
|
||||
|
||||
Uid ModelController::ownerKey(const MElement *element) const
|
||||
{
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return Uid());
|
||||
MObject *owner = element->owner();
|
||||
if (!owner)
|
||||
return Uid();
|
||||
@@ -649,7 +649,7 @@ MObject *ModelController::object(int row, const MObject *owner) const
|
||||
QMT_CHECK(row == 0);
|
||||
return m_rootPackage;
|
||||
}
|
||||
QMT_CHECK(row >= 0 && row < owner->children().size());
|
||||
QMT_ASSERT(row >= 0 && row < owner->children().size(), return nullptr);
|
||||
return owner->children().at(row);
|
||||
}
|
||||
|
||||
@@ -660,8 +660,8 @@ MObject *ModelController::findObject(const Uid &key) const
|
||||
|
||||
void ModelController::addObject(MPackage *parentPackage, MObject *object)
|
||||
{
|
||||
QMT_CHECK(parentPackage);
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(parentPackage, return);
|
||||
QMT_ASSERT(object, return);
|
||||
int row = parentPackage->children().size();
|
||||
if (!m_isResettingModel)
|
||||
emit beginInsertObject(row, parentPackage);
|
||||
@@ -681,12 +681,12 @@ void ModelController::addObject(MPackage *parentPackage, MObject *object)
|
||||
|
||||
void ModelController::removeObject(MObject *object)
|
||||
{
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return);
|
||||
if (m_undoController)
|
||||
m_undoController->beginMergeSequence(tr("Delete Object"));
|
||||
removeRelatedRelations(object);
|
||||
// remove object
|
||||
QMT_CHECK(object->owner());
|
||||
QMT_ASSERT(object->owner(), return);
|
||||
int row = object->owner()->children().indexOf(object);
|
||||
MObject *owner = object->owner();
|
||||
if (!m_isResettingModel)
|
||||
@@ -709,7 +709,7 @@ void ModelController::removeObject(MObject *object)
|
||||
|
||||
void ModelController::startUpdateObject(MObject *object)
|
||||
{
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return);
|
||||
int row = 0;
|
||||
MObject *parent = object->owner();
|
||||
if (!parent) {
|
||||
@@ -727,7 +727,7 @@ void ModelController::startUpdateObject(MObject *object)
|
||||
|
||||
void ModelController::finishUpdateObject(MObject *object, bool cancelled)
|
||||
{
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return);
|
||||
|
||||
int row = 0;
|
||||
MObject *parent = object->owner();
|
||||
@@ -754,14 +754,14 @@ void ModelController::finishUpdateObject(MObject *object, bool cancelled)
|
||||
|
||||
void ModelController::moveObject(MPackage *newOwner, MObject *object)
|
||||
{
|
||||
QMT_CHECK(newOwner);
|
||||
QMT_CHECK(object);
|
||||
QMT_CHECK(object != m_rootPackage);
|
||||
QMT_ASSERT(newOwner, return);
|
||||
QMT_ASSERT(object, return);
|
||||
QMT_ASSERT(object != m_rootPackage, return);
|
||||
|
||||
if (newOwner != object->owner()) {
|
||||
int formerRow = 0;
|
||||
MObject *formerOwner = object->owner();
|
||||
QMT_CHECK(formerOwner);
|
||||
QMT_ASSERT(formerOwner, return);
|
||||
formerRow = formerOwner->children().indexOf(object);
|
||||
if (!m_isResettingModel)
|
||||
emit beginMoveObject(formerRow, formerOwner);
|
||||
@@ -787,10 +787,10 @@ MRelation *ModelController::findRelation(const Uid &key) const
|
||||
|
||||
void ModelController::addRelation(MObject *owner, MRelation *relation)
|
||||
{
|
||||
QMT_CHECK(owner);
|
||||
QMT_CHECK(relation);
|
||||
QMT_CHECK(findObject(relation->endAUid()));
|
||||
QMT_CHECK(findObject(relation->endBUid()));
|
||||
QMT_ASSERT(owner, return);
|
||||
QMT_ASSERT(relation, return);
|
||||
QMT_ASSERT(findObject(relation->endAUid()), return);
|
||||
QMT_ASSERT(findObject(relation->endBUid()), return);
|
||||
|
||||
int row = owner->relations().size();
|
||||
if (!m_isResettingModel)
|
||||
@@ -811,9 +811,9 @@ void ModelController::addRelation(MObject *owner, MRelation *relation)
|
||||
|
||||
void ModelController::removeRelation(MRelation *relation)
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return);
|
||||
MObject *owner = relation->owner();
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
int row = owner->relations().indexOf(relation);
|
||||
if (!m_isResettingModel)
|
||||
emit beginRemoveRelation(row, owner);
|
||||
@@ -833,9 +833,9 @@ void ModelController::removeRelation(MRelation *relation)
|
||||
|
||||
void ModelController::startUpdateRelation(MRelation *relation)
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return);
|
||||
MObject *owner = relation->owner();
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
if (!m_isResettingModel)
|
||||
emit beginUpdateRelation(owner->relations().indexOf(relation), owner);
|
||||
if (m_undoController)
|
||||
@@ -844,11 +844,11 @@ void ModelController::startUpdateRelation(MRelation *relation)
|
||||
|
||||
void ModelController::finishUpdateRelation(MRelation *relation, bool cancelled)
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
QMT_CHECK(findObject(relation->endAUid()));
|
||||
QMT_CHECK(findObject(relation->endBUid()));
|
||||
QMT_ASSERT(relation, return);
|
||||
QMT_ASSERT(findObject(relation->endAUid()), return);
|
||||
QMT_ASSERT(findObject(relation->endBUid()), return);
|
||||
MObject *owner = relation->owner();
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
if (!m_isResettingModel) {
|
||||
emit endUpdateRelation(owner->relations().indexOf(relation), owner);
|
||||
if (!cancelled)
|
||||
@@ -859,13 +859,13 @@ void ModelController::finishUpdateRelation(MRelation *relation, bool cancelled)
|
||||
|
||||
void ModelController::moveRelation(MObject *newOwner, MRelation *relation)
|
||||
{
|
||||
QMT_CHECK(newOwner);
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(newOwner, return);
|
||||
QMT_ASSERT(relation, return);
|
||||
|
||||
if (newOwner != relation->owner()) {
|
||||
int formerRow = 0;
|
||||
MObject *formerOwner = relation->owner();
|
||||
QMT_CHECK(formerOwner);
|
||||
QMT_ASSERT(formerOwner, return);
|
||||
formerRow = formerOwner->relations().indexOf(relation);
|
||||
if (!m_isResettingModel)
|
||||
emit beginMoveRelation(formerRow, formerOwner);
|
||||
@@ -886,7 +886,7 @@ void ModelController::moveRelation(MObject *newOwner, MRelation *relation)
|
||||
|
||||
QList<MRelation *> ModelController::findRelationsOfObject(const MObject *object) const
|
||||
{
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return QList<MRelation *>());
|
||||
return m_objectRelationsMap.values(object->uid());
|
||||
}
|
||||
|
||||
@@ -1135,7 +1135,7 @@ MReferences ModelController::simplify(const MSelection &modelSelection)
|
||||
MReferences references;
|
||||
foreach (const MSelection::Index &index, modelSelection.indices()) {
|
||||
MElement *element = findElement(index.elementKey());
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return MReferences());
|
||||
// if any (grand-)parent of element is in modelSelection then ignore element
|
||||
bool ignore = false;
|
||||
MObject *owner = element->owner();
|
||||
@@ -1161,28 +1161,28 @@ void ModelController::verifyModelIntegrity() const
|
||||
{
|
||||
static const bool debugModelIntegrity = false;
|
||||
if (debugModelIntegrity) {
|
||||
QMT_CHECK(m_rootPackage);
|
||||
QMT_ASSERT(m_rootPackage, return);
|
||||
|
||||
QHash<Uid, const MObject *> objectsMap;
|
||||
QHash<Uid, const MRelation *> relationsMap;
|
||||
QMultiHash<Uid, MRelation *> objectRelationsMap;
|
||||
verifyModelIntegrity(m_rootPackage, &objectsMap, &relationsMap, &objectRelationsMap);
|
||||
|
||||
QMT_CHECK(objectsMap.size() == m_objectsMap.size());
|
||||
QMT_ASSERT(objectsMap.size() == m_objectsMap.size(), return);
|
||||
foreach (const MObject *object, m_objectsMap) {
|
||||
QMT_CHECK(object);
|
||||
QMT_CHECK(m_objectsMap.contains(object->uid()));
|
||||
QMT_CHECK(objectsMap.contains(object->uid()));
|
||||
QMT_ASSERT(object, return);
|
||||
QMT_ASSERT(m_objectsMap.contains(object->uid()), return);
|
||||
QMT_ASSERT(objectsMap.contains(object->uid()), return);
|
||||
}
|
||||
QMT_CHECK(relationsMap.size() == m_relationsMap.size());
|
||||
QMT_ASSERT(relationsMap.size() == m_relationsMap.size(), return);
|
||||
foreach (const MRelation *relation, m_relationsMap) {
|
||||
QMT_CHECK(relation);
|
||||
QMT_CHECK(m_relationsMap.contains(relation->uid()));
|
||||
QMT_CHECK(relationsMap.contains(relation->uid()));
|
||||
QMT_ASSERT(relation, return);
|
||||
QMT_ASSERT(m_relationsMap.contains(relation->uid()), return);
|
||||
QMT_ASSERT(relationsMap.contains(relation->uid()), return);
|
||||
}
|
||||
QMT_CHECK(objectRelationsMap.size() == m_objectRelationsMap.size());
|
||||
QMT_ASSERT(objectRelationsMap.size() == m_objectRelationsMap.size(), return);
|
||||
for (auto it = m_objectRelationsMap.cbegin(); it != m_objectRelationsMap.cend(); ++it) {
|
||||
QMT_CHECK(objectRelationsMap.contains(it.key(), it.value()));
|
||||
QMT_ASSERT(objectRelationsMap.contains(it.key(), it.value()), return);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1191,19 +1191,19 @@ void ModelController::verifyModelIntegrity(const MObject *object, QHash<Uid, con
|
||||
QHash<Uid, const MRelation *> *relationsMap,
|
||||
QMultiHash<Uid, MRelation *> *objectRelationsMap) const
|
||||
{
|
||||
QMT_CHECK(object);
|
||||
QMT_CHECK(!objectsMap->contains(object->uid()));
|
||||
QMT_ASSERT(object, return);
|
||||
QMT_ASSERT(!objectsMap->contains(object->uid()), return);
|
||||
objectsMap->insert(object->uid(), object);
|
||||
foreach (const Handle<MRelation> &handle, object->relations()) {
|
||||
MRelation *relation = handle.target();
|
||||
if (relation) {
|
||||
QMT_CHECK(!relationsMap->contains(relation->uid()));
|
||||
QMT_ASSERT(!relationsMap->contains(relation->uid()), return);
|
||||
relationsMap->insert(relation->uid(), relation);
|
||||
QMT_CHECK(findObject(relation->endAUid()));
|
||||
QMT_CHECK(findObject(relation->endBUid()));
|
||||
QMT_CHECK(!objectRelationsMap->contains(relation->endAUid(), relation));
|
||||
QMT_ASSERT(findObject(relation->endAUid()), return);
|
||||
QMT_ASSERT(findObject(relation->endBUid()), return);
|
||||
QMT_ASSERT(!objectRelationsMap->contains(relation->endAUid(), relation), return);
|
||||
objectRelationsMap->insert(relation->endAUid(), relation);
|
||||
QMT_CHECK(!objectRelationsMap->contains(relation->endBUid(), relation));
|
||||
QMT_ASSERT(!objectRelationsMap->contains(relation->endBUid(), relation), return);
|
||||
objectRelationsMap->insert(relation->endBUid(), relation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
void visitMObject(const MObject *object)
|
||||
{
|
||||
Q_UNUSED(object);
|
||||
QMT_CHECK(m_item);
|
||||
QMT_ASSERT(m_item, return);
|
||||
m_item->setEditable(false);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
void visitMRelation(const MRelation *relation)
|
||||
{
|
||||
Q_UNUSED(relation);
|
||||
QMT_CHECK(m_item);
|
||||
QMT_ASSERT(m_item, return);
|
||||
m_item->setEditable(false);
|
||||
m_item->setData(TreeModel::Relation, TreeModel::RoleItemType);
|
||||
}
|
||||
@@ -391,13 +391,13 @@ MElement *TreeModel::element(const QModelIndex &index) const
|
||||
if (item) {
|
||||
if (item->parent()) {
|
||||
auto parentModelItem = dynamic_cast<ModelItem *>(item->parent());
|
||||
QMT_CHECK(parentModelItem);
|
||||
QMT_ASSERT(parentModelItem, return nullptr);
|
||||
const MObject *parentObject = m_itemToObjectMap.value(parentModelItem);
|
||||
QMT_CHECK(parentObject);
|
||||
QMT_ASSERT(parentObject, return nullptr);
|
||||
if (parentObject) {
|
||||
if (index.row() >= 0 && index.row() < parentObject->children().size()) {
|
||||
element = parentObject->children().at(index.row());
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return nullptr);
|
||||
} else if (index.row() >= parentObject->children().size()
|
||||
&& index.row() < parentObject->children().size() + parentObject->relations().size()) {
|
||||
element = parentObject->relations().at(index.row() - parentObject->children().size());
|
||||
@@ -510,7 +510,7 @@ void TreeModel::onEndUpdateObject(int row, const MObject *parent)
|
||||
auto object = dynamic_cast<MObject *>(element);
|
||||
if (object) {
|
||||
auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex));
|
||||
QMT_CHECK(item);
|
||||
QMT_ASSERT(item, return);
|
||||
ItemUpdater visitor(this, item);
|
||||
element->accept(&visitor);
|
||||
}
|
||||
@@ -531,7 +531,7 @@ void TreeModel::onEndInsertObject(int row, const MObject *parent)
|
||||
{
|
||||
QMT_CHECK(m_busyState == InsertElement);
|
||||
ModelItem *parentItem =m_objectToItemMap.value(parent);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
MObject *object = parent->children().at(row);
|
||||
ModelItem *item = createItem(object);
|
||||
parentItem->insertRow(row, item);
|
||||
@@ -542,13 +542,13 @@ void TreeModel::onEndInsertObject(int row, const MObject *parent)
|
||||
void TreeModel::onBeginRemoveObject(int row, const MObject *parent)
|
||||
{
|
||||
QMT_CHECK(m_busyState == NotBusy);
|
||||
QMT_ASSERT(parent, return);
|
||||
m_busyState = RemoveElement;
|
||||
QMT_CHECK(parent);
|
||||
MObject *object = parent->children().at(row);
|
||||
if (object)
|
||||
removeObjectFromItemMap(object);
|
||||
ModelItem *parentItem = m_objectToItemMap.value(parent);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
parentItem->removeRow(row);
|
||||
}
|
||||
|
||||
@@ -563,13 +563,13 @@ void TreeModel::onEndRemoveObject(int row, const MObject *parent)
|
||||
void TreeModel::onBeginMoveObject(int formerRow, const MObject *formerOwner)
|
||||
{
|
||||
QMT_CHECK(m_busyState == NotBusy);
|
||||
QMT_ASSERT(formerOwner, return);
|
||||
m_busyState = MoveElement;
|
||||
QMT_CHECK(formerOwner);
|
||||
MObject *object = formerOwner->children().at(formerRow);
|
||||
if (object)
|
||||
removeObjectFromItemMap(object);
|
||||
ModelItem *parentItem = m_objectToItemMap.value(formerOwner);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
parentItem->removeRow(formerRow);
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ void TreeModel::onEndMoveObject(int row, const MObject *owner)
|
||||
{
|
||||
QMT_CHECK(m_busyState == MoveElement);
|
||||
ModelItem *parentItem =m_objectToItemMap.value(owner);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
MObject *object = owner->children().at(row);
|
||||
ModelItem *item = createItem(object);
|
||||
parentItem->insertRow(row, item);
|
||||
@@ -595,12 +595,12 @@ void TreeModel::onBeginUpdateRelation(int row, const MObject *parent)
|
||||
|
||||
void TreeModel::onEndUpdateRelation(int row, const MObject *parent)
|
||||
{
|
||||
QMT_CHECK(parent);
|
||||
QMT_ASSERT(parent, return);
|
||||
QMT_CHECK(m_busyState == UpdateRelation);
|
||||
|
||||
QMT_CHECK(m_objectToItemMap.contains(parent));
|
||||
ModelItem *parentItem = m_objectToItemMap.value(parent);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
QModelIndex parentIndex = indexFromItem(parentItem);
|
||||
|
||||
// reflect updated relation in standard item
|
||||
@@ -611,7 +611,7 @@ void TreeModel::onEndUpdateRelation(int row, const MObject *parent)
|
||||
auto relation = dynamic_cast<MRelation *>(element);
|
||||
if (relation) {
|
||||
auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex));
|
||||
QMT_CHECK(item);
|
||||
QMT_ASSERT(item, return);
|
||||
ItemUpdater visitor(this, item);
|
||||
element->accept(&visitor);
|
||||
}
|
||||
@@ -630,10 +630,10 @@ void TreeModel::onBeginInsertRelation(int row, const MObject *parent)
|
||||
|
||||
void TreeModel::onEndInsertRelation(int row, const MObject *parent)
|
||||
{
|
||||
QMT_CHECK(parent);
|
||||
QMT_ASSERT(parent, return);
|
||||
QMT_CHECK(m_busyState == InsertRelation);
|
||||
ModelItem *parentItem =m_objectToItemMap.value(parent);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
MRelation *relation = parent->relations().at(row);
|
||||
ModelItem *item = createItem(relation);
|
||||
parentItem->insertRow(parent->children().size() + row, item);
|
||||
@@ -642,12 +642,12 @@ void TreeModel::onEndInsertRelation(int row, const MObject *parent)
|
||||
|
||||
void TreeModel::onBeginRemoveRelation(int row, const MObject *parent)
|
||||
{
|
||||
QMT_CHECK(parent);
|
||||
QMT_ASSERT(parent, return);
|
||||
QMT_CHECK(m_busyState == NotBusy);
|
||||
m_busyState = RemoveRelation;
|
||||
QMT_CHECK(parent->relations().at(row));
|
||||
ModelItem *parentItem = m_objectToItemMap.value(parent);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
parentItem->removeRow(parent->children().size() + row);
|
||||
}
|
||||
|
||||
@@ -662,20 +662,20 @@ void TreeModel::onEndRemoveRelation(int row, const MObject *parent)
|
||||
void TreeModel::onBeginMoveRelation(int formerRow, const MObject *formerOwner)
|
||||
{
|
||||
QMT_CHECK(m_busyState == NotBusy);
|
||||
QMT_ASSERT(formerOwner, return);
|
||||
m_busyState = MoveElement;
|
||||
QMT_CHECK(formerOwner);
|
||||
QMT_CHECK(formerOwner->relations().at(formerRow));
|
||||
ModelItem *parentItem = m_objectToItemMap.value(formerOwner);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
parentItem->removeRow(formerOwner->children().size() + formerRow);
|
||||
}
|
||||
|
||||
void TreeModel::onEndMoveRelation(int row, const MObject *owner)
|
||||
{
|
||||
QMT_CHECK(owner);
|
||||
QMT_ASSERT(owner, return);
|
||||
QMT_CHECK(m_busyState == MoveElement);
|
||||
ModelItem *parentItem =m_objectToItemMap.value(owner);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
MRelation *relation = owner->relations().at(row);
|
||||
ModelItem *item = createItem(relation);
|
||||
parentItem->insertRow(owner->children().size() + row, item);
|
||||
@@ -688,10 +688,10 @@ void TreeModel::onRelationEndChanged(MRelation *relation, MObject *endObject)
|
||||
QMT_CHECK(m_busyState == NotBusy);
|
||||
|
||||
MObject *parent = relation->owner();
|
||||
QMT_CHECK(parent);
|
||||
QMT_ASSERT(parent, return);
|
||||
QMT_CHECK(m_objectToItemMap.contains(parent));
|
||||
ModelItem *parentItem = m_objectToItemMap.value(parent);
|
||||
QMT_CHECK(parentItem);
|
||||
QMT_ASSERT(parentItem, return);
|
||||
QModelIndex parentIndex = indexFromItem(parentItem);
|
||||
|
||||
int row = parent->children().size() + relation->owner()->relations().indexOf(relation);
|
||||
@@ -699,7 +699,7 @@ void TreeModel::onRelationEndChanged(MRelation *relation, MObject *endObject)
|
||||
QMT_CHECK(elementIndex.isValid());
|
||||
|
||||
auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex));
|
||||
QMT_CHECK(item);
|
||||
QMT_ASSERT(item, return);
|
||||
|
||||
QString label = createRelationLabel(relation);
|
||||
if (item->text() != label)
|
||||
@@ -758,10 +758,10 @@ void TreeModel::createChildren(const MObject *parentObject, ModelItem *parentIte
|
||||
|
||||
void TreeModel::removeObjectFromItemMap(const MObject *object)
|
||||
{
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return);
|
||||
QMT_CHECK(m_objectToItemMap.contains(object));
|
||||
ModelItem *item = m_objectToItemMap.value(object);
|
||||
QMT_CHECK(item);
|
||||
QMT_ASSERT(item, return);
|
||||
QMT_CHECK(m_itemToObjectMap.contains(item));
|
||||
m_itemToObjectMap.remove(item);
|
||||
m_objectToItemMap.remove(object);
|
||||
@@ -773,7 +773,7 @@ void TreeModel::removeObjectFromItemMap(const MObject *object)
|
||||
|
||||
QString TreeModel::createObjectLabel(const MObject *object)
|
||||
{
|
||||
QMT_CHECK(object);
|
||||
QMT_ASSERT(object, return QString());
|
||||
|
||||
if (object->name().isEmpty()) {
|
||||
if (auto item = dynamic_cast<const MItem *>(object)) {
|
||||
|
||||
@@ -84,7 +84,7 @@ MPackage *TreeModelManager::selectedPackage() const
|
||||
if (m_modelTreeView->currentSourceModelIndex().isValid())
|
||||
{
|
||||
MElement *element = m_treeModel->element(m_modelTreeView->currentSourceModelIndex());
|
||||
QMT_CHECK(element);
|
||||
QMT_ASSERT(element, return nullptr);
|
||||
if (auto package = dynamic_cast<MPackage *>(element)) {
|
||||
return package;
|
||||
} else if (auto object = dynamic_cast<MObject *>(element)) {
|
||||
|
||||
@@ -452,7 +452,7 @@ QString ClassMembersEdit::build(const QList<MClassMember> &members)
|
||||
|
||||
QList<MClassMember> ClassMembersEdit::parse(const QString &text, bool *ok)
|
||||
{
|
||||
QMT_CHECK(ok);
|
||||
QMT_ASSERT(ok, return QList<MClassMember>());
|
||||
|
||||
*ok = true;
|
||||
QList<MClassMember> members;
|
||||
|
||||
@@ -113,7 +113,7 @@ void ModelTreeView::startDrag(Qt::DropActions supportedActions)
|
||||
Q_UNUSED(supportedActions);
|
||||
|
||||
TreeModel *treeModel = m_sortedTreeModel->treeModel();
|
||||
QMT_CHECK(treeModel);
|
||||
QMT_ASSERT(treeModel, return);
|
||||
|
||||
QByteArray dragData;
|
||||
QDataStream dataStream(&dragData, QIODevice::WriteOnly);
|
||||
@@ -170,7 +170,7 @@ void ModelTreeView::dragMoveEvent(QDragMoveEvent *event)
|
||||
QModelIndex dropSourceModelIndex = m_sortedTreeModel->mapToSource(dropIndex);
|
||||
if (dropSourceModelIndex.isValid()) {
|
||||
TreeModel *treeModel = m_sortedTreeModel->treeModel();
|
||||
QMT_CHECK(treeModel);
|
||||
QMT_ASSERT(treeModel, return);
|
||||
MElement *modelElement = treeModel->element(dropSourceModelIndex);
|
||||
if (dynamic_cast<MObject*>(modelElement))
|
||||
accept = true;
|
||||
@@ -202,7 +202,7 @@ void ModelTreeView::dropEvent(QDropEvent *event)
|
||||
QModelIndex dropSourceModelIndex = m_sortedTreeModel->mapToSource(dropIndex);
|
||||
if (dropSourceModelIndex.isValid()) {
|
||||
TreeModel *treeModel = m_sortedTreeModel->treeModel();
|
||||
QMT_CHECK(treeModel);
|
||||
QMT_ASSERT(treeModel, return);
|
||||
MElement *targetModelElement = treeModel->element(dropSourceModelIndex);
|
||||
if (auto targetModelObject = dynamic_cast<MObject *>(targetModelElement)) {
|
||||
QDataStream dataStream(event->mimeData()->data(QStringLiteral("text/model-elements")));
|
||||
@@ -245,9 +245,9 @@ void ModelTreeView::contextMenuEvent(QContextMenuEvent *event)
|
||||
QModelIndex sourceModelIndex = m_sortedTreeModel->mapToSource(index);
|
||||
if (sourceModelIndex.isValid()) {
|
||||
TreeModel *treeModel = m_sortedTreeModel->treeModel();
|
||||
QMT_CHECK(treeModel);
|
||||
QMT_ASSERT(treeModel, return);
|
||||
MElement *melement = treeModel->element(sourceModelIndex);
|
||||
QMT_CHECK(melement);
|
||||
QMT_ASSERT(melement, return);
|
||||
|
||||
QMenu menu;
|
||||
bool addSeparator = false;
|
||||
@@ -268,7 +268,7 @@ void ModelTreeView::contextMenuEvent(QContextMenuEvent *event)
|
||||
QAction *selectedAction = menu.exec(event->globalPos());
|
||||
if (selectedAction) {
|
||||
auto action = dynamic_cast<ContextMenuAction *>(selectedAction);
|
||||
QMT_CHECK(action);
|
||||
QMT_ASSERT(action, return);
|
||||
if (action->id() == QStringLiteral("showDefinition")) {
|
||||
m_elementTasks->openClassDefinition(melement);
|
||||
} else if (action->id() == QStringLiteral("openDiagram")) {
|
||||
|
||||
@@ -47,13 +47,13 @@ PaletteBox::~PaletteBox()
|
||||
|
||||
QBrush PaletteBox::brush(int index) const
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index <= m_brushes.size());
|
||||
QMT_ASSERT(index >= 0 && index <= m_brushes.size(), return QBrush());
|
||||
return m_brushes.at(index);
|
||||
}
|
||||
|
||||
void PaletteBox::setBrush(int index, const QBrush &brush)
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index <= m_brushes.size());
|
||||
QMT_ASSERT(index >= 0 && index <= m_brushes.size(), return);
|
||||
if (m_brushes[index] != brush) {
|
||||
m_brushes[index] = brush;
|
||||
update();
|
||||
@@ -62,13 +62,13 @@ void PaletteBox::setBrush(int index, const QBrush &brush)
|
||||
|
||||
QPen PaletteBox::linePen(int index) const
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index <= m_pens.size());
|
||||
QMT_ASSERT(index >= 0 && index <= m_pens.size(), return QPen());
|
||||
return m_pens.at(index);
|
||||
}
|
||||
|
||||
void PaletteBox::setLinePen(int index, const QPen &pen)
|
||||
{
|
||||
QMT_CHECK(index >= 0 && index <= m_pens.size());
|
||||
QMT_ASSERT(index >= 0 && index <= m_pens.size(), return);
|
||||
if (m_pens[index] != pen) {
|
||||
m_pens[index] = pen;
|
||||
update();
|
||||
@@ -125,7 +125,7 @@ void PaletteBox::mousePressEvent(QMouseEvent *event)
|
||||
qreal w = static_cast<qreal>(width()) / static_cast<qreal>(m_brushes.size());
|
||||
|
||||
int i = static_cast<int>((event->x() / w));
|
||||
QMT_CHECK(i >= 0 && i < m_brushes.size());
|
||||
QMT_ASSERT(i >= 0 && i < m_brushes.size(), return);
|
||||
setCurrentIndex(i);
|
||||
if (m_currentIndex >= 0 && m_currentIndex < m_brushes.size())
|
||||
emit activated(m_currentIndex);
|
||||
|
||||
@@ -172,7 +172,7 @@ void PropertiesView::setSelectedModelElements(const QList<MElement *> &modelElem
|
||||
void PropertiesView::setSelectedDiagramElements(const QList<DElement *> &diagramElements, MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(diagramElements.size() > 0);
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagram, return);
|
||||
|
||||
if (m_selectedDiagramElements != diagramElements || m_selectedDiagram != diagram) {
|
||||
m_selectedDiagramElements = diagramElements;
|
||||
@@ -386,7 +386,7 @@ void PropertiesView::onEndRemoveElement(int row, const MDiagram *diagram)
|
||||
|
||||
void PropertiesView::beginUpdate(MElement *modelElement)
|
||||
{
|
||||
QMT_CHECK(modelElement);
|
||||
QMT_ASSERT(modelElement, return);
|
||||
|
||||
if (auto object = dynamic_cast<MObject *>(modelElement)) {
|
||||
m_modelController->startUpdateObject(object);
|
||||
@@ -399,7 +399,7 @@ void PropertiesView::beginUpdate(MElement *modelElement)
|
||||
|
||||
void PropertiesView::endUpdate(MElement *modelElement, bool cancelled)
|
||||
{
|
||||
QMT_CHECK(modelElement);
|
||||
QMT_ASSERT(modelElement, return);
|
||||
|
||||
if (auto object = dynamic_cast<MObject *>(modelElement)) {
|
||||
m_modelController->finishUpdateObject(object, cancelled);
|
||||
@@ -412,18 +412,18 @@ void PropertiesView::endUpdate(MElement *modelElement, bool cancelled)
|
||||
|
||||
void PropertiesView::beginUpdate(DElement *diagramElement)
|
||||
{
|
||||
QMT_CHECK(diagramElement);
|
||||
QMT_CHECK(m_selectedDiagram != 0);
|
||||
QMT_CHECK(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement);
|
||||
QMT_ASSERT(diagramElement, return);
|
||||
QMT_ASSERT(m_selectedDiagram, return);
|
||||
QMT_ASSERT(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement, return);
|
||||
|
||||
m_diagramController->startUpdateElement(diagramElement, m_selectedDiagram, DiagramController::UpdateMinor);
|
||||
}
|
||||
|
||||
void PropertiesView::endUpdate(DElement *diagramElement, bool cancelled)
|
||||
{
|
||||
QMT_CHECK(diagramElement);
|
||||
QMT_CHECK(m_selectedDiagram != 0);
|
||||
QMT_CHECK(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement);
|
||||
QMT_ASSERT(diagramElement, return);
|
||||
QMT_ASSERT(m_selectedDiagram, return);
|
||||
QMT_ASSERT(m_diagramController->findElement(diagramElement->uid(), m_selectedDiagram) == diagramElement, return);
|
||||
|
||||
m_diagramController->finishUpdateElement(diagramElement, m_selectedDiagram, cancelled);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ static MDependency::Direction translateIndexToDirection(int index)
|
||||
static const MDependency::Direction map[] = {
|
||||
MDependency::AToB, MDependency::BToA, MDependency::Bidirectional
|
||||
};
|
||||
QMT_CHECK(isValidDirectionIndex(index));
|
||||
QMT_ASSERT(isValidDirectionIndex(index), return MDependency::AToB);
|
||||
return map[index];
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static MAssociationEnd::Kind translateIndexToAssociationKind(int index)
|
||||
static const MAssociationEnd::Kind map[] = {
|
||||
MAssociationEnd::Association, MAssociationEnd::Aggregation, MAssociationEnd::Composition
|
||||
};
|
||||
QMT_CHECK(isValidAssociationKindIndex(index));
|
||||
QMT_ASSERT(isValidAssociationKindIndex(index), return MAssociationEnd::Association);
|
||||
return map[index];
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ static DObject::VisualPrimaryRole translateIndexToVisualPrimaryRole(int index)
|
||||
DObject::PrimaryRoleCustom1, DObject::PrimaryRoleCustom2, DObject::PrimaryRoleCustom3,
|
||||
DObject::PrimaryRoleCustom4, DObject::PrimaryRoleCustom5
|
||||
};
|
||||
QMT_CHECK(index >= 0 && index <= 5);
|
||||
QMT_ASSERT(index >= 0 && index <= 5, return DObject::PrimaryRoleNormal);
|
||||
return map[index];
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ static DObject::VisualSecondaryRole translateIndexToVisualSecondaryRole(int inde
|
||||
DObject::SecondaryRoleLighter, DObject::SecondaryRoleDarker,
|
||||
DObject::SecondaryRoleSoften, DObject::SecondaryRoleOutline
|
||||
};
|
||||
QMT_CHECK(index >= 0 && index <= 4);
|
||||
QMT_ASSERT(index >= 0 && index <= 4, return DObject::SecondaryRoleNone);
|
||||
return map[index];
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ static DObject::StereotypeDisplay translateIndexToStereotypeDisplay(int index)
|
||||
DObject::StereotypeDecoration,
|
||||
DObject::StereotypeIcon
|
||||
};
|
||||
QMT_CHECK(index >= 0 && index <= 4);
|
||||
QMT_ASSERT(index >= 0 && index <= 4, return DObject::StereotypeSmart);
|
||||
return map[index];
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ static DClass::TemplateDisplay translateIndexToTemplateDisplay(int index)
|
||||
DClass::TemplateBox,
|
||||
DClass::TemplateName
|
||||
};
|
||||
QMT_CHECK(index >= 0 && index <= 2);
|
||||
QMT_ASSERT(index >= 0 && index <= 2, return DClass::TemplateSmart);
|
||||
return map[index];
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ static DAnnotation::VisualRole translateIndexToAnnotationVisualRole(int index)
|
||||
DAnnotation::RoleNormal, DAnnotation::RoleTitle, DAnnotation::RoleSubtitle,
|
||||
DAnnotation::RoleEmphasized, DAnnotation::RoleSoften, DAnnotation::RoleFootnote
|
||||
};
|
||||
QMT_CHECK(index >= 0 && index <= 5);
|
||||
QMT_ASSERT(index >= 0 && index <= 5, return DAnnotation::RoleNormal);
|
||||
return map[index];
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ PropertiesView::MView::~MView()
|
||||
|
||||
void PropertiesView::MView::update(QList<MElement *> &modelElements)
|
||||
{
|
||||
QMT_CHECK(modelElements.size() > 0);
|
||||
QMT_ASSERT(modelElements.size() > 0, return);
|
||||
|
||||
m_modelElements = modelElements;
|
||||
m_diagramElements.clear();
|
||||
@@ -344,8 +344,8 @@ void PropertiesView::MView::update(QList<MElement *> &modelElements)
|
||||
|
||||
void PropertiesView::MView::update(QList<DElement *> &diagramElements, MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(diagramElements.size() > 0);
|
||||
QMT_CHECK(diagram);
|
||||
QMT_ASSERT(diagramElements.size() > 0, return);
|
||||
QMT_ASSERT(diagram, return);
|
||||
|
||||
m_diagramElements = diagramElements;
|
||||
m_diagram = diagram;
|
||||
@@ -599,10 +599,10 @@ void PropertiesView::MView::visitMRelation(const MRelation *relation)
|
||||
if (m_elementNameLineEdit->isEnabled() != isSingleSelection)
|
||||
m_elementNameLineEdit->setEnabled(isSingleSelection);
|
||||
MObject *endAObject = m_propertiesView->modelController()->findObject(relation->endAUid());
|
||||
QMT_CHECK(endAObject);
|
||||
QMT_ASSERT(endAObject, return);
|
||||
setEndAName(tr("End A: %1").arg(endAObject->name()));
|
||||
MObject *endBObject = m_propertiesView->modelController()->findObject(relation->endBUid());
|
||||
QMT_CHECK(endBObject);
|
||||
QMT_ASSERT(endBObject, return);
|
||||
setEndBName(tr("End B: %1").arg(endBObject->name()));
|
||||
}
|
||||
|
||||
@@ -636,10 +636,10 @@ void PropertiesView::MView::visitMInheritance(const MInheritance *inheritance)
|
||||
{
|
||||
setTitle<MInheritance>(m_modelElements, tr("Inheritance"), tr("Inheritances"));
|
||||
MObject *derivedClass = m_propertiesView->modelController()->findObject(inheritance->derived());
|
||||
QMT_CHECK(derivedClass);
|
||||
QMT_ASSERT(derivedClass, return);
|
||||
setEndAName(tr("Derived class: %1").arg(derivedClass->name()));
|
||||
MObject *baseClass = m_propertiesView->modelController()->findObject(inheritance->base());
|
||||
QMT_CHECK(baseClass);
|
||||
QMT_ASSERT(baseClass, return);
|
||||
setEndBName(tr("Base class: %1").arg(baseClass->name()));
|
||||
visitMRelation(inheritance);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ ProjectSerializer::~ProjectSerializer()
|
||||
|
||||
void ProjectSerializer::save(const QString &fileName, const Project *project)
|
||||
{
|
||||
QMT_CHECK(project);
|
||||
QMT_ASSERT(project, return);
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
@@ -108,7 +108,7 @@ QByteArray ProjectSerializer::save(const Project *project)
|
||||
|
||||
void ProjectSerializer::load(const QString &fileName, Project *project)
|
||||
{
|
||||
QMT_CHECK(project);
|
||||
QMT_ASSERT(project, return);
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
|
||||
@@ -510,7 +510,7 @@ QColor DefaultStyleEngine::baseColor(ElementType elementType, ObjectVisuals obje
|
||||
};
|
||||
|
||||
int index = static_cast<int>(objectVisuals.visualPrimaryRole()) - static_cast<int>(DObject::PrimaryRoleCustom1);
|
||||
QMT_CHECK(index >= 0 && index <= 4);
|
||||
QMT_ASSERT(index >= 0 && index <= 4, return baseColor);
|
||||
baseColor = customColors[index];
|
||||
}
|
||||
|
||||
|
||||
@@ -150,10 +150,10 @@ void DiagramSceneController::deleteFromDiagram(const DSelection &dselection, MDi
|
||||
DSelection remainingDselection;
|
||||
foreach (const DSelection::Index &index, dselection.indices()) {
|
||||
DElement *delement = m_diagramController->findElement(index.elementKey(), diagram);
|
||||
QMT_CHECK(delement);
|
||||
QMT_ASSERT(delement, return);
|
||||
if (delement->modelUid().isValid()) {
|
||||
MElement *melement = m_modelController->findElement(delement->modelUid());
|
||||
QMT_CHECK(melement);
|
||||
QMT_ASSERT(melement, return);
|
||||
if (melement->owner())
|
||||
mselection.append(melement->uid(), melement->owner()->uid());
|
||||
} else {
|
||||
@@ -173,9 +173,9 @@ void DiagramSceneController::createDependency(DObject *endAObject, DObject *endB
|
||||
m_diagramController->undoController()->beginMergeSequence(tr("Create Dependency"));
|
||||
|
||||
MObject *endAModelObject = m_modelController->findObject<MObject>(endAObject->modelUid());
|
||||
QMT_CHECK(endAModelObject);
|
||||
QMT_ASSERT(endAModelObject, return);
|
||||
MObject *endBModelObject = m_modelController->findObject<MObject>(endBObject->modelUid());
|
||||
QMT_CHECK(endBModelObject);
|
||||
QMT_ASSERT(endBModelObject, return);
|
||||
|
||||
if (endAModelObject == endBModelObject)
|
||||
return;
|
||||
@@ -200,9 +200,9 @@ void DiagramSceneController::createInheritance(DClass *derivedClass, DClass *bas
|
||||
m_diagramController->undoController()->beginMergeSequence(tr("Create Inheritance"));
|
||||
|
||||
MClass *derivedModelClass = m_modelController->findObject<MClass>(derivedClass->modelUid());
|
||||
QMT_CHECK(derivedModelClass);
|
||||
QMT_ASSERT(derivedModelClass, return);
|
||||
MClass *baseModelClass = m_modelController->findObject<MClass>(baseClass->modelUid());
|
||||
QMT_CHECK(baseModelClass);
|
||||
QMT_ASSERT(baseModelClass, return);
|
||||
|
||||
if (derivedModelClass == baseModelClass)
|
||||
return;
|
||||
@@ -226,9 +226,9 @@ void DiagramSceneController::createAssociation(DClass *endAClass, DClass *endBCl
|
||||
m_diagramController->undoController()->beginMergeSequence(tr("Create Association"));
|
||||
|
||||
MClass *endAModelObject = m_modelController->findObject<MClass>(endAClass->modelUid());
|
||||
QMT_CHECK(endAModelObject);
|
||||
QMT_ASSERT(endAModelObject, return);
|
||||
MClass *endBModelObject = m_modelController->findObject<MClass>(endBClass->modelUid());
|
||||
QMT_CHECK(endBModelObject);
|
||||
QMT_ASSERT(endBModelObject, return);
|
||||
|
||||
// TODO allow self assignment with just one intermediate point and a nice round arrow
|
||||
if (endAModelObject == endBModelObject && intermediatePoints.count() < 2)
|
||||
@@ -263,18 +263,18 @@ bool DiagramSceneController::relocateRelationEndB(DRelation *relation, DObject *
|
||||
bool DiagramSceneController::isAddingAllowed(const Uid &modelElementKey, MDiagram *diagram)
|
||||
{
|
||||
MElement *modelElement = m_modelController->findElement(modelElementKey);
|
||||
QMT_CHECK(modelElement);
|
||||
QMT_ASSERT(modelElement, return false);
|
||||
if (m_diagramController->hasDelegate(modelElement, diagram))
|
||||
return false;
|
||||
if (auto modelRelation = dynamic_cast<MRelation *>(modelElement)) {
|
||||
MObject *endAModelObject = m_modelController->findObject(modelRelation->endAUid());
|
||||
QMT_CHECK(endAModelObject);
|
||||
QMT_ASSERT(endAModelObject, return false);
|
||||
DObject *endADiagramObject = m_diagramController->findDelegate<DObject>(endAModelObject, diagram);
|
||||
if (!endADiagramObject)
|
||||
return false;
|
||||
|
||||
MObject *endBModelObject = m_modelController->findObject(modelRelation->endBUid());
|
||||
QMT_CHECK(endBModelObject);
|
||||
QMT_ASSERT(endBModelObject, return false);
|
||||
DObject *endBDiagramObject = m_diagramController->findDelegate<DObject>(endBModelObject, diagram);
|
||||
if (!endBDiagramObject)
|
||||
return false;
|
||||
@@ -595,7 +595,7 @@ DElement *DiagramSceneController::addModelElement(const Uid &modelElementKey, co
|
||||
|
||||
DObject *DiagramSceneController::addObject(MObject *modelObject, const QPointF &pos, MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(modelObject);
|
||||
QMT_ASSERT(modelObject, return nullptr);
|
||||
|
||||
if (m_diagramController->hasDelegate(modelObject, diagram))
|
||||
return 0;
|
||||
@@ -605,7 +605,7 @@ DObject *DiagramSceneController::addObject(MObject *modelObject, const QPointF &
|
||||
DFactory factory;
|
||||
modelObject->accept(&factory);
|
||||
auto diagramObject = dynamic_cast<DObject *>(factory.product());
|
||||
QMT_CHECK(diagramObject);
|
||||
QMT_ASSERT(diagramObject, return nullptr);
|
||||
diagramObject->setPos(pos);
|
||||
m_diagramController->addElement(diagramObject, diagram);
|
||||
alignOnRaster(diagramObject, diagram);
|
||||
@@ -657,7 +657,7 @@ DObject *DiagramSceneController::addObject(MObject *modelObject, const QPointF &
|
||||
DRelation *DiagramSceneController::addRelation(MRelation *modelRelation, const QList<QPointF> &intermediatePoints,
|
||||
MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(modelRelation);
|
||||
QMT_ASSERT(modelRelation, return nullptr);
|
||||
|
||||
if (m_diagramController->hasDelegate(modelRelation, diagram))
|
||||
return 0;
|
||||
@@ -665,18 +665,18 @@ DRelation *DiagramSceneController::addRelation(MRelation *modelRelation, const Q
|
||||
DFactory factory;
|
||||
modelRelation->accept(&factory);
|
||||
auto diagramRelation = dynamic_cast<DRelation *>(factory.product());
|
||||
QMT_CHECK(diagramRelation);
|
||||
QMT_ASSERT(diagramRelation, return nullptr);
|
||||
|
||||
MObject *endAModelObject = m_modelController->findObject(modelRelation->endAUid());
|
||||
QMT_CHECK(endAModelObject);
|
||||
QMT_ASSERT(endAModelObject, return nullptr);
|
||||
DObject *endADiagramObject = m_diagramController->findDelegate<DObject>(endAModelObject, diagram);
|
||||
QMT_CHECK(endADiagramObject);
|
||||
QMT_ASSERT(endADiagramObject, return nullptr);
|
||||
diagramRelation->setEndAUid(endADiagramObject->uid());
|
||||
|
||||
MObject *endBModelObject = m_modelController->findObject(modelRelation->endBUid());
|
||||
QMT_CHECK(endBModelObject);
|
||||
QMT_ASSERT(endBModelObject, return nullptr);
|
||||
DObject *endBDiagramObject = m_diagramController->findDelegate<DObject>(endBModelObject, diagram);
|
||||
QMT_CHECK(endBDiagramObject);
|
||||
QMT_ASSERT(endBDiagramObject, return nullptr);
|
||||
diagramRelation->setEndBUid(endBDiagramObject->uid());
|
||||
|
||||
QList<DRelation::IntermediatePoint> relationPoints;
|
||||
@@ -712,17 +712,17 @@ bool DiagramSceneController::relocateRelationEnd(DRelation *relation, DObject *t
|
||||
Uid (MRelation::*endUid)() const,
|
||||
void (MRelation::*setEndUid)(const Uid &))
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
QMT_ASSERT(relation, return false);
|
||||
if (targetObject && targetObject->uid() != relation->endAUid()) {
|
||||
MRelation *modelRelation = m_modelController->findRelation(relation->modelUid());
|
||||
QMT_CHECK(modelRelation);
|
||||
QMT_ASSERT(modelRelation, return false);
|
||||
MObject *targetMObject = m_modelController->findObject(targetObject->modelUid());
|
||||
QMT_CHECK(targetMObject);
|
||||
QMT_ASSERT(targetMObject, return false);
|
||||
AcceptRelationVisitor visitor(modelRelation);
|
||||
targetMObject->accept(&visitor);
|
||||
if (visitor.isAccepted()) {
|
||||
MObject *currentTargetMObject = m_modelController->findObject((modelRelation->*endUid)());
|
||||
QMT_CHECK(currentTargetMObject);
|
||||
QMT_ASSERT(currentTargetMObject, return false);
|
||||
m_modelController->undoController()->beginMergeSequence(tr("Relocate Relation"));
|
||||
// move relation into new target if it was a child of the old target
|
||||
if (currentTargetMObject == modelRelation->owner())
|
||||
|
||||
@@ -190,7 +190,7 @@ void UpdateIncludeDependenciesVisitor::visitMComponent(qmt::MComponent *componen
|
||||
|
||||
int componentHighestAncestorIndex = componentAncestors.size() - 1;
|
||||
int includeComponentHighestAncestorIndex = includeComponentAncestors.size() - 1;
|
||||
QTC_ASSERT(componentAncestors.at(componentHighestAncestorIndex) == includeComponentAncestors.at(includeComponentHighestAncestorIndex), return);
|
||||
QMT_ASSERT(componentAncestors.at(componentHighestAncestorIndex) == includeComponentAncestors.at(includeComponentHighestAncestorIndex), return);
|
||||
while (componentHighestAncestorIndex > 0 && includeComponentHighestAncestorIndex > 0) {
|
||||
if (componentAncestors.at(componentHighestAncestorIndex) != includeComponentAncestors.at(includeComponentHighestAncestorIndex))
|
||||
break;
|
||||
|
||||
@@ -401,7 +401,7 @@ void ElementTasks::createAndOpenDiagram(const qmt::MElement *element)
|
||||
auto newDiagram = new qmt::MCanvasDiagram();
|
||||
newDiagram->setName(package->name());
|
||||
qmt::MPackage *parentPackage = d->documentController->modelController()->findObject<qmt::MPackage>(package->uid());
|
||||
QTC_ASSERT(parentPackage, delete newDiagram; return);
|
||||
QMT_ASSERT(parentPackage, delete newDiagram; return);
|
||||
d->documentController->modelController()->addObject(parentPackage, newDiagram);
|
||||
ModelEditorPlugin::modelsManager()->openDiagram(
|
||||
d->documentController->projectController()->project()->uid(),
|
||||
|
||||
@@ -363,7 +363,7 @@ void ModelEditor::initDocument()
|
||||
|
||||
d->diagramView->setPxNodeController(documentController->pxNodeController());
|
||||
|
||||
QTC_CHECK(!d->diagramsViewManager);
|
||||
QMT_CHECK(!d->diagramsViewManager);
|
||||
d->diagramsViewManager = new DiagramsViewManager(this);
|
||||
//connect(diagramsViewManager, &DiagramsViewManager::someDiagramOpened,
|
||||
// documentController->diagramsManager(), &qmt::DiagramsManager::someDiagramOpened);
|
||||
@@ -767,7 +767,7 @@ void ModelEditor::clearProperties()
|
||||
if (d->propertiesGroupWidget) {
|
||||
QWidget *scrollWidget = d->propertiesScrollArea->takeWidget();
|
||||
Q_UNUSED(scrollWidget); // avoid warning in release mode
|
||||
QTC_CHECK(scrollWidget == d->propertiesGroupWidget);
|
||||
QMT_CHECK(scrollWidget == d->propertiesGroupWidget);
|
||||
d->propertiesGroupWidget->deleteLater();
|
||||
d->propertiesGroupWidget = 0;
|
||||
}
|
||||
@@ -801,8 +801,8 @@ QToolButton *ModelEditor::createToolbarCommandButton(const Core::Id &id, const s
|
||||
|
||||
bool ModelEditor::updateButtonIconByTheme(QAbstractButton *button, const QString &name)
|
||||
{
|
||||
QTC_ASSERT(button, return false);
|
||||
QTC_ASSERT(!name.isEmpty(), return false);
|
||||
QMT_ASSERT(button, return false);
|
||||
QMT_ASSERT(!name.isEmpty(), return false);
|
||||
|
||||
if (QIcon::hasThemeIcon(name)) {
|
||||
button->setIcon(QIcon::fromTheme(name));
|
||||
@@ -1015,7 +1015,7 @@ void ModelEditor::initToolbars()
|
||||
toolBars.insert(toolbar.id(), toolBar);
|
||||
} else {
|
||||
toolBarLayout = toolBar->layout();
|
||||
QTC_ASSERT(toolBarLayout, continue);
|
||||
QMT_ASSERT(toolBarLayout, continue);
|
||||
}
|
||||
foreach (const qmt::Toolbar::Tool &tool, toolbar.tools()) {
|
||||
switch (tool.m_toolType) {
|
||||
@@ -1115,9 +1115,9 @@ void ModelEditor::initToolbars()
|
||||
// add stretch to all layouts and calculate width of tool bar
|
||||
int maxWidth = 48;
|
||||
foreach (QWidget *toolBar, toolBars) {
|
||||
QTC_ASSERT(toolBar, continue);
|
||||
QMT_ASSERT(toolBar, continue);
|
||||
auto layout = qobject_cast<QBoxLayout *>(toolBar->layout());
|
||||
QTC_ASSERT(layout, continue);
|
||||
QMT_ASSERT(layout, continue);
|
||||
layout->addStretch(1);
|
||||
toolBar->adjustSize();
|
||||
if (maxWidth < toolBar->width())
|
||||
|
||||
@@ -233,12 +233,12 @@ class ModelIndexer::ModelIndexerPrivate
|
||||
public:
|
||||
~ModelIndexerPrivate()
|
||||
{
|
||||
QTC_CHECK(filesQueue.isEmpty());
|
||||
QTC_CHECK(queuedFilesSet.isEmpty());
|
||||
QTC_CHECK(indexedModels.isEmpty());
|
||||
QTC_CHECK(indexedModelsByUid.isEmpty());
|
||||
QTC_CHECK(indexedDiagramReferences.isEmpty());
|
||||
QTC_CHECK(indexedDiagramReferencesByDiagramUid.isEmpty());
|
||||
QMT_CHECK(filesQueue.isEmpty());
|
||||
QMT_CHECK(queuedFilesSet.isEmpty());
|
||||
QMT_CHECK(indexedModels.isEmpty());
|
||||
QMT_CHECK(indexedModelsByUid.isEmpty());
|
||||
QMT_CHECK(indexedDiagramReferences.isEmpty());
|
||||
QMT_CHECK(indexedDiagramReferencesByDiagramUid.isEmpty());
|
||||
delete indexerThread;
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ QString ModelIndexer::findModel(const qmt::Uid &modelUid)
|
||||
if (indexedModels.isEmpty())
|
||||
return QString();
|
||||
IndexedModel *indexedModel = *indexedModels.cbegin();
|
||||
QTC_ASSERT(indexedModel, return QString());
|
||||
QMT_ASSERT(indexedModel, return QString());
|
||||
return indexedModel->file();
|
||||
}
|
||||
|
||||
@@ -357,8 +357,8 @@ QString ModelIndexer::findDiagram(const qmt::Uid &modelUid, const qmt::Uid &diag
|
||||
if (indexedDiagramReferences.isEmpty())
|
||||
return QString();
|
||||
IndexedDiagramReference *indexedDiagramReference = *indexedDiagramReferences.cbegin();
|
||||
QTC_ASSERT(indexedDiagramReference, return QString());
|
||||
QTC_ASSERT(indexedDiagramReference->modelUid() == modelUid, return QString());
|
||||
QMT_ASSERT(indexedDiagramReference, return QString());
|
||||
QMT_ASSERT(indexedDiagramReference->modelUid() == modelUid, return QString());
|
||||
return indexedDiagramReference->file();
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ void ModelIndexer::scanProject(ProjectExplorer::Project *project)
|
||||
while (!filesQueue.isEmpty()) {
|
||||
QueuedFile queuedFile = filesQueue.takeFirst();
|
||||
if (!d->queuedFilesSet.contains(queuedFile)) {
|
||||
QTC_CHECK(!d->filesQueue.contains(queuedFile));
|
||||
QMT_CHECK(!d->filesQueue.contains(queuedFile));
|
||||
d->filesQueue.append(queuedFile);
|
||||
d->queuedFilesSet.insert(queuedFile);
|
||||
filesAreQueued = true;
|
||||
@@ -475,9 +475,9 @@ void ModelIndexer::forgetProject(ProjectExplorer::Project *project)
|
||||
// remove file from queue
|
||||
QueuedFile queuedFile(file, project);
|
||||
if (d->queuedFilesSet.contains(queuedFile)) {
|
||||
QTC_CHECK(d->filesQueue.contains(queuedFile));
|
||||
QMT_CHECK(d->filesQueue.contains(queuedFile));
|
||||
d->filesQueue.removeOne(queuedFile);
|
||||
QTC_CHECK(!d->filesQueue.contains(queuedFile));
|
||||
QMT_CHECK(!d->filesQueue.contains(queuedFile));
|
||||
d->queuedFilesSet.remove(queuedFile);
|
||||
}
|
||||
removeModelFile(file, project);
|
||||
@@ -497,9 +497,9 @@ void ModelIndexer::removeModelFile(const QString &file, ProjectExplorer::Project
|
||||
d->indexedModels.remove(file);
|
||||
|
||||
// remove indexedModel from set of indexedModelsByUid
|
||||
QTC_CHECK(d->indexedModelsByUid.contains(indexedModel->modelUid()));
|
||||
QMT_CHECK(d->indexedModelsByUid.contains(indexedModel->modelUid()));
|
||||
QSet<IndexedModel *> indexedModels = d->indexedModelsByUid.value(indexedModel->modelUid());
|
||||
QTC_CHECK(indexedModels.contains(indexedModel));
|
||||
QMT_CHECK(indexedModels.contains(indexedModel));
|
||||
indexedModels.remove(indexedModel);
|
||||
if (indexedModels.isEmpty())
|
||||
d->indexedModelsByUid.remove(indexedModel->modelUid());
|
||||
@@ -516,7 +516,7 @@ void ModelIndexer::removeDiagramReferenceFile(const QString &file,
|
||||
{
|
||||
IndexedDiagramReference *indexedDiagramReference = d->indexedDiagramReferences.value(file);
|
||||
if (indexedDiagramReference) {
|
||||
QTC_CHECK(indexedDiagramReference->owningProjects().contains(project));
|
||||
QMT_CHECK(indexedDiagramReference->owningProjects().contains(project));
|
||||
qCDebug(logger) << "remove diagram reference file "
|
||||
<< file << " from project " << project->displayName();
|
||||
indexedDiagramReference->removeOwningProject(project);
|
||||
@@ -525,9 +525,9 @@ void ModelIndexer::removeDiagramReferenceFile(const QString &file,
|
||||
d->indexedDiagramReferences.remove(file);
|
||||
|
||||
// remove indexedDiagramReference from set of indexedDiagramReferecesByDiagramUid
|
||||
QTC_CHECK(d->indexedDiagramReferencesByDiagramUid.contains(indexedDiagramReference->diagramUid()));
|
||||
QMT_CHECK(d->indexedDiagramReferencesByDiagramUid.contains(indexedDiagramReference->diagramUid()));
|
||||
QSet<IndexedDiagramReference *> indexedDiagramReferences = d->indexedDiagramReferencesByDiagramUid.value(indexedDiagramReference->diagramUid());
|
||||
QTC_CHECK(indexedDiagramReferences.contains(indexedDiagramReference));
|
||||
QMT_CHECK(indexedDiagramReferences.contains(indexedDiagramReference));
|
||||
indexedDiagramReferences.remove(indexedDiagramReference);
|
||||
if (indexedDiagramReferences.isEmpty()) {
|
||||
d->indexedDiagramReferencesByDiagramUid.remove(
|
||||
|
||||
@@ -123,7 +123,7 @@ ModelsManager::ModelsManager(QObject *parent)
|
||||
|
||||
ModelsManager::~ModelsManager()
|
||||
{
|
||||
QTC_CHECK(d->managedModels.isEmpty());
|
||||
QMT_CHECK(d->managedModels.isEmpty());
|
||||
delete d->modelIndexer;
|
||||
delete d;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ void ModelsManager::releaseModel(ExtDocumentController *documentController)
|
||||
return;
|
||||
}
|
||||
}
|
||||
QTC_CHECK(false);
|
||||
QMT_CHECK(false);
|
||||
}
|
||||
|
||||
void ModelsManager::openDiagram(const qmt::Uid &modelUid, const qmt::Uid &diagramUid)
|
||||
@@ -158,7 +158,7 @@ void ModelsManager::openDiagram(const qmt::Uid &modelUid, const qmt::Uid &diagra
|
||||
foreach (const ManagedModel &managedModel, d->managedModels) {
|
||||
if (managedModel.m_documentController->projectController()->project()->uid() == modelUid) {
|
||||
qmt::MDiagram *diagram = managedModel.m_documentController->modelController()->findObject<qmt::MDiagram>(diagramUid);
|
||||
QTC_ASSERT(diagram, continue);
|
||||
QMT_ASSERT(diagram, continue);
|
||||
openDiagram(managedModel.m_documentController, diagram);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ void PxNodeController::addExplorerNode(const ProjectExplorer::Node *node,
|
||||
qmt::DElement *topMostElementAtPos, const QPointF &pos,
|
||||
qmt::MDiagram *diagram)
|
||||
{
|
||||
QTC_ASSERT(node, return);
|
||||
QTC_ASSERT(diagram, return);
|
||||
QMT_ASSERT(node, return);
|
||||
QMT_ASSERT(diagram, return);
|
||||
|
||||
QString elementName = qmt::NameController::convertFileNameToElementName(
|
||||
node->filePath().toString());
|
||||
@@ -252,7 +252,7 @@ qmt::MDiagram *PxNodeController::findDiagramForExplorerNode(const ProjectExplore
|
||||
}
|
||||
|
||||
if (found) {
|
||||
QTC_ASSERT(relativeIndex >= relativeElements.size(), return 0);
|
||||
QMT_ASSERT(relativeIndex >= relativeElements.size(), return 0);
|
||||
// complete package chain found so check for appropriate diagram within deepest package
|
||||
qmt::MDiagram *diagram = d->diagramSceneController->findDiagramBySearchId(
|
||||
package, package->name());
|
||||
@@ -329,7 +329,7 @@ void PxNodeController::onMenuActionTriggered(PxNodeController::MenuAction *actio
|
||||
if (qmt::MObject *existingObject = d->pxnodeUtilities->findSameObject(relativeElements, package)) {
|
||||
delete package;
|
||||
package = dynamic_cast<qmt::MPackage *>(existingObject);
|
||||
QTC_ASSERT(package, return);
|
||||
QMT_ASSERT(package, return);
|
||||
d->diagramSceneController->addExistingModelElement(package->uid(), pos, diagram);
|
||||
} else {
|
||||
qmt::MPackage *requestedRootPackage = d->diagramSceneController->findSuitableParentPackage(topMostElementAtPos, diagram);
|
||||
@@ -367,7 +367,7 @@ void PxNodeController::onMenuActionTriggered(PxNodeController::MenuAction *actio
|
||||
// if requested and not existing then create new diagram in package
|
||||
if (newDiagramInObject) {
|
||||
auto package = dynamic_cast<qmt::MPackage *>(parentForDiagram);
|
||||
QTC_ASSERT(package, return);
|
||||
QMT_ASSERT(package, return);
|
||||
if (d->diagramSceneController->findDiagramBySearchId(package, newDiagramInObject->name()))
|
||||
delete newDiagramInObject;
|
||||
else
|
||||
|
||||
@@ -144,7 +144,7 @@ qmt::MPackage *PxNodeUtilities::createBestMatchingPackagePath(
|
||||
if (found)
|
||||
return package; // complete chain found, innermost package is already the result
|
||||
|
||||
QTC_CHECK(!(relativeIndex == maxChainLength && minChainDepth < 0));
|
||||
QMT_CHECK(!(relativeIndex == maxChainLength && minChainDepth < 0));
|
||||
if (relativeIndex >= 1
|
||||
&& (relativeIndex > maxChainLength
|
||||
|| (relativeIndex == maxChainLength && depth < minChainDepth))) {
|
||||
@@ -154,14 +154,14 @@ qmt::MPackage *PxNodeUtilities::createBestMatchingPackagePath(
|
||||
}
|
||||
}
|
||||
|
||||
QTC_CHECK(maxChainLength < relativeElements.size());
|
||||
QMT_CHECK(maxChainLength < relativeElements.size());
|
||||
if (!bestParentPackage) {
|
||||
QTC_CHECK(maxChainLength == -1);
|
||||
QTC_CHECK(minChainDepth == -1);
|
||||
QMT_CHECK(maxChainLength == -1);
|
||||
QMT_CHECK(minChainDepth == -1);
|
||||
maxChainLength = 0;
|
||||
bestParentPackage = suggestedParentPackage;
|
||||
} else {
|
||||
QTC_CHECK(maxChainLength >= 1);
|
||||
QMT_CHECK(maxChainLength >= 1);
|
||||
}
|
||||
|
||||
int i = maxChainLength;
|
||||
@@ -215,7 +215,7 @@ qmt::MObject *PxNodeUtilities::findSameObject(const QStringList &relativeElement
|
||||
}
|
||||
|
||||
if (found) {
|
||||
QTC_CHECK(relativeIndex >= relativeElements.size());
|
||||
QMT_CHECK(relativeIndex >= relativeElements.size());
|
||||
// chain was found so check for given object within deepest package
|
||||
QString objectSearchId = qmt::NameController::calcElementNameSearchId(object->name());
|
||||
foreach (const qmt::Handle<qmt::MObject> &handle, package->children()) {
|
||||
|
||||
Reference in New Issue
Block a user