Commit 70e0286f authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Use auto keyword

Change-Id: I3d36f851227f6f90ddfc7da55169c6a8d4d57c39
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent bf4b16ed
......@@ -147,7 +147,7 @@ QList<QString> NameController::buildElementsPath(const QString &filePath, bool i
QStringList::const_iterator splittedEnd = splitted.end();
if (ignoreLastFilePathPart || splitted.last().isEmpty())
splittedEnd = --splittedEnd;
for (QStringList::const_iterator it = splitted.cbegin(); it != splittedEnd; ++it) {
for (auto it = splitted.cbegin(); it != splittedEnd; ++it) {
QString packageName = qmt::NameController::convertFileNameToElementName(*it);
relativeElements.append(packageName);
}
......
......@@ -57,7 +57,7 @@ void UndoCommand::setDoNotMerge(bool doNotMerge)
bool UndoCommand::mergeWith(const QUndoCommand *other)
{
const UndoCommand *otherCommand = dynamic_cast<const UndoCommand *>(other);
auto otherCommand = dynamic_cast<const UndoCommand *>(other);
if (!otherCommand)
return false;
if (otherCommand->m_doNotMerge)
......
......@@ -70,7 +70,7 @@ void DFactory::visitMElement(const MElement *element)
void DFactory::visitMObject(const MObject *object)
{
DObject *diagramObject = dynamic_cast<DObject *>(m_product);
auto diagramObject = dynamic_cast<DObject *>(m_product);
QMT_CHECK(diagramObject);
diagramObject->setModelUid(object->uid());
visitMElement(object);
......@@ -79,7 +79,7 @@ void DFactory::visitMObject(const MObject *object)
void DFactory::visitMPackage(const MPackage *package)
{
QMT_CHECK(!m_product);
DPackage *diagramPackage = new DPackage();
auto diagramPackage = new DPackage();
m_product = diagramPackage;
visitMObject(package);
}
......@@ -87,7 +87,7 @@ void DFactory::visitMPackage(const MPackage *package)
void DFactory::visitMClass(const MClass *klass)
{
QMT_CHECK(!m_product);
DClass *diagramKlass = new DClass();
auto diagramKlass = new DClass();
m_product = diagramKlass;
visitMObject(klass);
}
......@@ -95,7 +95,7 @@ void DFactory::visitMClass(const MClass *klass)
void DFactory::visitMComponent(const MComponent *component)
{
QMT_CHECK(!m_product);
DComponent *diagramComponent = new DComponent();
auto diagramComponent = new DComponent();
m_product = diagramComponent;
visitMObject(component);
}
......@@ -103,7 +103,7 @@ void DFactory::visitMComponent(const MComponent *component)
void DFactory::visitMDiagram(const MDiagram *diagram)
{
QMT_CHECK(!m_product);
DDiagram *diagramDiagram = new DDiagram();
auto diagramDiagram = new DDiagram();
m_product = diagramDiagram;
visitMObject(diagram);
}
......@@ -117,14 +117,14 @@ void DFactory::visitMCanvasDiagram(const MCanvasDiagram *diagram)
void DFactory::visitMItem(const MItem *item)
{
QMT_CHECK(!m_product);
DItem *diagramItem = new DItem();
auto diagramItem = new DItem();
m_product = diagramItem;
visitMObject(item);
}
void DFactory::visitMRelation(const MRelation *relation)
{
DRelation *diagramRelation = dynamic_cast<DRelation *>(m_product);
auto diagramRelation = dynamic_cast<DRelation *>(m_product);
QMT_CHECK(diagramRelation);
diagramRelation->setModelUid(relation->uid());
visitMElement(relation);
......@@ -133,7 +133,7 @@ void DFactory::visitMRelation(const MRelation *relation)
void DFactory::visitMDependency(const MDependency *dependency)
{
QMT_CHECK(!m_product);
DDependency *diagramDependency = new DDependency();
auto diagramDependency = new DDependency();
m_product = diagramDependency;
visitMRelation(dependency);
}
......@@ -141,7 +141,7 @@ void DFactory::visitMDependency(const MDependency *dependency)
void DFactory::visitMInheritance(const MInheritance *inheritance)
{
QMT_CHECK(!m_product);
DInheritance *diagramInheritance = new DInheritance();
auto diagramInheritance = new DInheritance();
m_product = diagramInheritance;
visitMRelation(inheritance);
}
......@@ -149,7 +149,7 @@ void DFactory::visitMInheritance(const MInheritance *inheritance)
void DFactory::visitMAssociation(const MAssociation *association)
{
QMT_CHECK(!m_product);
DAssociation *diagramAssociation = new DAssociation();
auto diagramAssociation = new DAssociation();
m_product = diagramAssociation;
visitMRelation(association);
}
......
......@@ -63,7 +63,7 @@ void DFlatAssignmentVisitor::visitDElement(const DElement *element)
void DFlatAssignmentVisitor::visitDObject(const DObject *object)
{
visitDElement(object);
DObject *target = dynamic_cast<DObject *>(m_target);
auto target = dynamic_cast<DObject *>(m_target);
QMT_CHECK(target);
target->setStereotypes(object->stereotypes());
target->setName(object->name());
......@@ -85,7 +85,7 @@ void DFlatAssignmentVisitor::visitDPackage(const DPackage *package)
void DFlatAssignmentVisitor::visitDClass(const DClass *klass)
{
visitDObject(klass);
DClass *target = dynamic_cast<DClass *>(m_target);
auto target = dynamic_cast<DClass *>(m_target);
QMT_CHECK(target);
target->setUmlNamespace(klass->umlNamespace());
target->setTemplateParameters(klass->templateParameters());
......@@ -98,7 +98,7 @@ void DFlatAssignmentVisitor::visitDClass(const DClass *klass)
void DFlatAssignmentVisitor::visitDComponent(const DComponent *component)
{
visitDObject(component);
DComponent *target = dynamic_cast<DComponent *>(m_target);
auto target = dynamic_cast<DComponent *>(m_target);
QMT_CHECK(target);
target->setPlainShape(component->isPlainShape());
}
......@@ -111,7 +111,7 @@ void DFlatAssignmentVisitor::visitDDiagram(const DDiagram *diagram)
void DFlatAssignmentVisitor::visitDItem(const DItem *item)
{
visitDObject(item);
DItem *target = dynamic_cast<DItem *>(m_target);
auto target = dynamic_cast<DItem *>(m_target);
QMT_CHECK(target);
target->setVariety(target->variety());
target->setShapeEditable(target->isShapeEditable());
......@@ -121,7 +121,7 @@ void DFlatAssignmentVisitor::visitDItem(const DItem *item)
void DFlatAssignmentVisitor::visitDRelation(const DRelation *relation)
{
visitDElement(relation);
DRelation *target = dynamic_cast<DRelation *>(m_target);
auto target = dynamic_cast<DRelation *>(m_target);
QMT_CHECK(target);
target->setStereotypes(relation->stereotypes());
target->setIntermediatePoints(relation->intermediatePoints());
......@@ -135,7 +135,7 @@ void DFlatAssignmentVisitor::visitDInheritance(const DInheritance *inheritance)
void DFlatAssignmentVisitor::visitDDependency(const DDependency *dependency)
{
visitDRelation(dependency);
DDependency *target = dynamic_cast<DDependency *>(m_target);
auto target = dynamic_cast<DDependency *>(m_target);
QMT_CHECK(target);
target->setDirection(dependency->direction());
}
......@@ -143,7 +143,7 @@ void DFlatAssignmentVisitor::visitDDependency(const DDependency *dependency)
void DFlatAssignmentVisitor::visitDAssociation(const DAssociation *association)
{
visitDRelation(association);
DAssociation *target = dynamic_cast<DAssociation *>(m_target);
auto target = dynamic_cast<DAssociation *>(m_target);
QMT_CHECK(target);
target->setEndA(association->endA());
target->setEndB(association->endB());
......@@ -152,7 +152,7 @@ void DFlatAssignmentVisitor::visitDAssociation(const DAssociation *association)
void DFlatAssignmentVisitor::visitDAnnotation(const DAnnotation *annotation)
{
visitDElement(annotation);
DAnnotation *target = dynamic_cast<DAnnotation *>(m_target);
auto target = dynamic_cast<DAnnotation *>(m_target);
target->setText(annotation->text());
target->setPos(annotation->pos());
target->setRect(annotation->rect());
......@@ -163,7 +163,7 @@ void DFlatAssignmentVisitor::visitDAnnotation(const DAnnotation *annotation)
void DFlatAssignmentVisitor::visitDBoundary(const DBoundary *boundary)
{
visitDElement(boundary);
DBoundary *target = dynamic_cast<DBoundary *>(m_target);
auto target = dynamic_cast<DBoundary *>(m_target);
target->setText(boundary->text());
target->setPos(boundary->pos());
target->setRect(boundary->rect());
......
......@@ -118,7 +118,7 @@ public:
bool mergeWith(const UndoCommand *other)
{
const UpdateElementCommand *otherUpdateCommand = dynamic_cast<const UpdateElementCommand *>(other);
auto otherUpdateCommand = dynamic_cast<const UpdateElementCommand *>(other);
if (!otherUpdateCommand)
return false;
if (diagramKey() != otherUpdateCommand->diagramKey())
......@@ -403,7 +403,7 @@ void DiagramController::addElement(DElement *element, MDiagram *diagram)
emit beginInsertElement(row, diagram);
updateElementFromModel(element, diagram, false);
if (m_undoController) {
AddElementsCommand *undoCommand = new AddElementsCommand(this, diagram->uid(), tr("Add Object"));
auto undoCommand = new AddElementsCommand(this, diagram->uid(), tr("Add Object"));
m_undoController->push(undoCommand);
undoCommand->add(element->uid());
}
......@@ -418,7 +418,7 @@ void DiagramController::removeElement(DElement *element, MDiagram *diagram)
int row = diagram->diagramElements().indexOf(element);
emit beginRemoveElement(row, diagram);
if (m_undoController) {
RemoveElementsCommand *undoCommand = new RemoveElementsCommand(this, diagram->uid(), tr("Remove Object"));
auto undoCommand = new RemoveElementsCommand(this, diagram->uid(), tr("Remove Object"));
m_undoController->push(undoCommand);
undoCommand->add(element);
}
......@@ -511,7 +511,7 @@ void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagr
}
// fix all keys referencing between pasting elements
foreach(DElement *clonedElement, clonedElements) {
DRelation *relation = dynamic_cast<DRelation *>(clonedElement);
auto relation = dynamic_cast<DRelation *>(clonedElement);
if (relation)
updateRelationKeys(relation, renewedKeys);
}
......@@ -524,7 +524,7 @@ void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagr
int row = diagram->diagramElements().size();
emit beginInsertElement(row, diagram);
if (m_undoController) {
AddElementsCommand *undoCommand = new AddElementsCommand(this, diagram->uid(), tr("Paste"));
auto undoCommand = new AddElementsCommand(this, diagram->uid(), tr("Paste"));
m_undoController->push(undoCommand);
undoCommand->add(clonedElement->uid());
}
......@@ -534,12 +534,12 @@ void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagr
}
}
foreach (DElement *clonedElement, clonedElements) {
DRelation *clonedRelation = dynamic_cast<DRelation *>(clonedElement);
auto clonedRelation = dynamic_cast<DRelation *>(clonedElement);
if (clonedRelation && areRelationEndsOnDiagram(clonedRelation, diagram)) {
int row = diagram->diagramElements().size();
emit beginInsertElement(row, diagram);
if (m_undoController) {
AddElementsCommand *undoCommand = new AddElementsCommand(this, diagram->uid(), tr("Paste"));
auto undoCommand = new AddElementsCommand(this, diagram->uid(), tr("Paste"));
m_undoController->push(undoCommand);
undoCommand->add(clonedElement->uid());
}
......@@ -596,7 +596,7 @@ void DiagramController::onEndUpdateObject(int row, const MObject *parent)
{
MObject *modelObject = m_modelController->object(row, parent);
QMT_CHECK(modelObject);
MPackage *modelPackage = dynamic_cast<MPackage *>(modelObject);
auto modelPackage = dynamic_cast<MPackage *>(modelObject);
foreach (MDiagram *diagram, m_allDiagrams) {
DObject *object = findDelegate<DObject>(modelObject, diagram);
if (object) {
......@@ -626,7 +626,7 @@ void DiagramController::onEndInsertObject(int row, const MObject *owner)
QMT_CHECK(owner);
MObject *modelObject = m_modelController->object(row, owner);
if (MDiagram *modelDiagram = dynamic_cast<MDiagram *>(modelObject)) {
if (auto modelDiagram = dynamic_cast<MDiagram *>(modelObject)) {
QMT_CHECK(!m_allDiagrams.contains(modelDiagram));
m_allDiagrams.append(modelDiagram);
}
......@@ -659,7 +659,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);
MDiagram *modelDiagram = dynamic_cast<MDiagram *>(modelObject);
auto modelDiagram = dynamic_cast<MDiagram *>(modelObject);
if (modelDiagram) {
emit beginResetDiagram(modelDiagram);
foreach (DElement *diagramElement, modelDiagram->diagramElements())
......@@ -732,7 +732,7 @@ void DiagramController::deleteElements(const DSelection &diagramSelection, MDiag
int row = diagram->diagramElements().indexOf(element);
emit beginRemoveElement(diagram->diagramElements().indexOf(element), diagram);
if (m_undoController) {
RemoveElementsCommand *cutCommand = new RemoveElementsCommand(this, diagram->uid(), commandLabel);
auto cutCommand = new RemoveElementsCommand(this, diagram->uid(), commandLabel);
m_undoController->push(cutCommand);
cutCommand->add(element);
}
......@@ -773,7 +773,7 @@ void DiagramController::removeObjects(MObject *modelObject)
if (object.hasTarget())
removeObjects(object.target());
}
if (MDiagram *diagram = dynamic_cast<MDiagram *>(modelObject)) {
if (auto diagram = dynamic_cast<MDiagram *>(modelObject)) {
emit diagramAboutToBeRemoved(diagram);
QMT_CHECK(m_allDiagrams.contains(diagram));
m_allDiagrams.removeOne(diagram);
......@@ -797,10 +797,10 @@ void DiagramController::removeRelations(MRelation *modelRelation)
void DiagramController::removeRelations(DElement *element, MDiagram *diagram)
{
DObject *diagramObject = dynamic_cast<DObject *>(element);
auto diagramObject = dynamic_cast<DObject *>(element);
if (diagramObject) {
foreach (DElement *diagramElement, diagram->diagramElements()) {
if (DRelation *diagramRelation = dynamic_cast<DRelation *>(diagramElement)) {
if (auto diagramRelation = dynamic_cast<DRelation *>(diagramElement)) {
if (diagramRelation->endAUid() == diagramObject->uid()
|| diagramRelation->endBUid() == diagramObject->uid()) {
removeElement(diagramRelation, diagram);
......
......@@ -76,7 +76,7 @@ void DUpdateVisitor::visitMElement(const MElement *element)
void DUpdateVisitor::visitMObject(const MObject *object)
{
DObject *dobject = dynamic_cast<DObject *>(m_target);
auto dobject = dynamic_cast<DObject *>(m_target);
QMT_CHECK(dobject);
if (isUpdating(object->stereotypes() != dobject->stereotypes()))
dobject->setStereotypes(object->stereotypes());
......@@ -111,7 +111,7 @@ void DUpdateVisitor::visitMPackage(const MPackage *package)
void DUpdateVisitor::visitMClass(const MClass *klass)
{
DClass *dclass = dynamic_cast<DClass *>(m_target);
auto dclass = dynamic_cast<DClass *>(m_target);
QMT_CHECK(dclass);
if (isUpdating(klass->umlNamespace() != dclass->umlNamespace()))
dclass->setUmlNamespace(klass->umlNamespace());
......@@ -139,7 +139,7 @@ void DUpdateVisitor::visitMCanvasDiagram(const MCanvasDiagram *diagram)
void DUpdateVisitor::visitMItem(const MItem *item)
{
DItem *ditem = dynamic_cast<DItem *>(m_target);
auto ditem = dynamic_cast<DItem *>(m_target);
QMT_CHECK(ditem);
if (isUpdating(item->isShapeEditable() != ditem->isShapeEditable()))
ditem->setShapeEditable(item->isShapeEditable());
......@@ -150,7 +150,7 @@ void DUpdateVisitor::visitMItem(const MItem *item)
void DUpdateVisitor::visitMRelation(const MRelation *relation)
{
DRelation *drelation = dynamic_cast<DRelation *>(m_target);
auto drelation = dynamic_cast<DRelation *>(m_target);
QMT_CHECK(drelation);
if (isUpdating(relation->stereotypes() != drelation->stereotypes()))
drelation->setStereotypes(relation->stereotypes());
......@@ -161,7 +161,7 @@ void DUpdateVisitor::visitMRelation(const MRelation *relation)
void DUpdateVisitor::visitMDependency(const MDependency *dependency)
{
DDependency *ddependency = dynamic_cast<DDependency *>(m_target);
auto ddependency = dynamic_cast<DDependency *>(m_target);
QMT_CHECK(ddependency);
if (isUpdating(dependency->direction() != ddependency->direction()))
ddependency->setDirection(dependency->direction());
......@@ -175,7 +175,7 @@ void DUpdateVisitor::visitMInheritance(const MInheritance *inheritance)
void DUpdateVisitor::visitMAssociation(const MAssociation *association)
{
DAssociation *dassociation = dynamic_cast<DAssociation *>(m_target);
auto dassociation = dynamic_cast<DAssociation *>(m_target);
QMT_CHECK(dassociation);
DAssociationEnd endA;
endA.setName(association->endA().name());
......
......@@ -254,7 +254,7 @@ DElement *DiagramSceneModel::element(QGraphicsItem *item) const
bool DiagramSceneModel::isElementEditable(const DElement *element) const
{
IEditable *editable = dynamic_cast<IEditable *>(m_elementToItemMap.value(element));
auto editable = dynamic_cast<IEditable *>(m_elementToItemMap.value(element));
return editable != 0 && editable->isEditable();
}
......@@ -277,14 +277,14 @@ void DiagramSceneModel::selectElement(DElement *element)
void DiagramSceneModel::editElement(DElement *element)
{
IEditable *editable = dynamic_cast<IEditable *>(m_elementToItemMap.value(element));
auto editable = dynamic_cast<IEditable *>(m_elementToItemMap.value(element));
if (editable != 0 && editable->isEditable())
editable->edit();
}
void DiagramSceneModel::copyToClipboard()
{
QMimeData *mimeData = new QMimeData();
auto mimeData = new QMimeData();
// Selections would also render to the clipboard
m_graphicsScene->clearSelection();
......@@ -461,11 +461,11 @@ void DiagramSceneModel::moveSelectedItems(QGraphicsItem *grabbedItem, const QPoi
if (delta != QPointF(0.0, 0.0)) {
foreach (QGraphicsItem *item, m_selectedItems) {
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item))
if (auto moveable = dynamic_cast<IMoveable *>(item))
moveable->moveDelta(delta);
}
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item))
if (auto moveable = dynamic_cast<IMoveable *>(item))
moveable->moveDelta(delta);
}
}
......@@ -474,11 +474,11 @@ void DiagramSceneModel::moveSelectedItems(QGraphicsItem *grabbedItem, const QPoi
void DiagramSceneModel::alignSelectedItemsPositionOnRaster()
{
foreach (QGraphicsItem *item, m_selectedItems) {
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item))
if (auto moveable = dynamic_cast<IMoveable *>(item))
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
}
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item))
if (auto moveable = dynamic_cast<IMoveable *>(item))
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
}
}
......@@ -495,7 +495,7 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
{
QList<QGraphicsItem *> collidingItems;
const IResizable *resizable = dynamic_cast<const IResizable *>(item);
auto resizable = dynamic_cast<const IResizable *>(item);
if (!resizable)
return collidingItems;
QRectF rect = resizable->rect();
......@@ -504,7 +504,7 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
switch (collidingMode) {
case CollidingInnerItems:
foreach (QGraphicsItem *candidate, m_graphicsItems) {
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
if (auto candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
QRectF candidateRect = candidateResizable->rect();
candidateRect.translate(candidateResizable->pos());
if (candidateRect.left() >= rect.left() && candidateRect.right() <= rect.right()
......@@ -516,7 +516,7 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
break;
case CollidingItems:
foreach (QGraphicsItem *candidate, m_graphicsItems) {
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
if (auto candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
QRectF candidateRect = candidateResizable->rect();
candidateRect.translate(candidateResizable->pos());
if (candidateRect.left() <= rect.right() && candidateRect.right() >= rect.left()
......@@ -528,7 +528,7 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
break;
case CollidingOuterItems:
foreach (QGraphicsItem *candidate, m_graphicsItems) {
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
if (auto candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
QRectF candidateRect = candidateResizable->rect();
candidateRect.translate(candidateResizable->pos());
if (candidateRect.left() <= rect.left() && candidateRect.right() >= rect.right()
......@@ -761,7 +761,7 @@ void DiagramSceneModel::onSelectionChanged()
// select all relations where both ends are primary or secondary selected
foreach (DElement *element, m_diagram->diagramElements()) {
DRelation *relation = dynamic_cast<DRelation *>(element);
auto relation = dynamic_cast<DRelation *>(element);
if (relation) {
QGraphicsItem *relationItem = m_elementToItemMap.value(relation);
QMT_CHECK(relationItem);
......@@ -784,7 +784,7 @@ void DiagramSceneModel::onSelectionChanged()
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
if (!newSecondarySelectedItems.contains(item)) {
ISelectable *selectable = dynamic_cast<ISelectable *>(item);
auto selectable = dynamic_cast<ISelectable *>(item);
QMT_CHECK(selectable);
selectable->setSecondarySelected(false);
selectionChanged = true;
......@@ -792,7 +792,7 @@ void DiagramSceneModel::onSelectionChanged()
}
foreach (QGraphicsItem *item, newSecondarySelectedItems) {
if (!m_secondarySelectedItems.contains(item)) {
ISelectable *selectable = dynamic_cast<ISelectable *>(item);
auto selectable = dynamic_cast<ISelectable *>(item);
QMT_CHECK(selectable);
selectable->setSecondarySelected(true);
selectionChanged = true;
......@@ -894,7 +894,7 @@ void DiagramSceneModel::updateFocusItem(const QSet<QGraphicsItem *> &selectedIte
void DiagramSceneModel::unsetFocusItem()
{
if (m_focusItem) {
if (ISelectable *oldSelectable = dynamic_cast<ISelectable *>(m_focusItem))
if (auto oldSelectable = dynamic_cast<ISelectable *>(m_focusItem))
oldSelectable->setFocusSelected(false);
else
QMT_CHECK(false);
......
......@@ -140,7 +140,7 @@ void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *e
QPointF rectPlacement;
GeometryUtilities::Side alignedSide = GeometryUtilities::SideUnspecified;
if (IIntersectionable *objectItem = dynamic_cast<IIntersectionable *>(endItem)) {
if (auto objectItem = dynamic_cast<IIntersectionable *>(endItem)) {
QPointF intersectionPoint;
QLineF intersectionLine;
......
......@@ -93,7 +93,7 @@ void ClassItem::update()
updateStereotypeIconDisplay();
DClass *diagramClass = dynamic_cast<DClass *>(object());
auto diagramClass = dynamic_cast<DClass *>(object());
QMT_CHECK(diagramClass);
const Style *style = adaptedStyle(stereotypeIconId());
......@@ -315,20 +315,20 @@ void ClassItem::relationDrawn(const QString &id, const QPointF &toScenePos, cons
DElement *targetElement = diagramSceneModel()->findTopmostElement(toScenePos);
if (targetElement) {
if (id == QLatin1String("inheritance")) {
DClass *baseClass = dynamic_cast<DClass *>(targetElement);
auto baseClass = dynamic_cast<DClass *>(targetElement);
if (baseClass) {
DClass *derivedClass = dynamic_cast<DClass *>(object());
auto derivedClass = dynamic_cast<DClass *>(object());
QMT_CHECK(derivedClass);
diagramSceneModel()->diagramSceneController()->createInheritance(derivedClass, baseClass, intermediatePoints, diagramSceneModel()->diagram());
}
} else if (id == QLatin1String("dependency")) {
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
auto dependantObject = dynamic_cast<DObject *>(targetElement);
if (dependantObject)
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
} else if (id == QLatin1String("association")) {
DClass *assoziatedClass = dynamic_cast<DClass *>(targetElement);
auto assoziatedClass = dynamic_cast<DClass *>(targetElement);
if (assoziatedClass) {
DClass *derivedClass = dynamic_cast<DClass *>(object());
auto derivedClass = dynamic_cast<DClass *>(object());
QMT_CHECK(derivedClass);
diagramSceneModel()->diagramSceneController()->createAssociation(derivedClass, assoziatedClass, intermediatePoints, diagramSceneModel()->diagram());
}
......@@ -348,7 +348,7 @@ bool ClassItem::extendContextMenu(QMenu *menu)
bool ClassItem::handleSelectedContextMenuAction(QAction *action)
{
ContextMenuAction *klassAction = dynamic_cast<ContextMenuAction *>(action);
auto klassAction = dynamic_cast<ContextMenuAction *>(action);
if (klassAction) {
if (klassAction->id() == QStringLiteral("showDefinition")) {
diagramSceneModel()->diagramSceneController()->elementTasks()->openClassDefinition(object(), diagramSceneModel()->diagram());
......@@ -543,7 +543,7 @@ void ClassItem::updateMembers(const Style *style)
QString *currentGroup = 0;
QString *text = 0;
DClass *dclass = dynamic_cast<DClass *>(object());
auto dclass = dynamic_cast<DClass *>(object());
QMT_CHECK(dclass);
// TODO move bool haveIconFonts into class Style?
......
......@@ -242,7 +242,7 @@ void ComponentItem::relationDrawn(const QString &id, const QPointF &toScenePos,
DElement *targetElement = diagramSceneModel()->findTopmostElement(toScenePos);
if (targetElement) {
if (id == QStringLiteral("dependency")) {
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
auto dependantObject = dynamic_cast<DObject *>(targetElement);
if (dependantObject)
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
}
......@@ -251,7 +251,7 @@ void ComponentItem::relationDrawn(const QString &id, const QPointF &toScenePos,
bool ComponentItem::hasPlainShape() const
{
DComponent *diagramComponent = dynamic_cast<DComponent *>(object());
auto diagramComponent = dynamic_cast<DComponent *>(object());
QMT_CHECK(diagramComponent);
return diagramComponent->isPlainShape();
}
......
......@@ -78,7 +78,7 @@ void ItemItem::update()
prepareGeometryChange();
updateStereotypeIconDisplay();
DItem *diagramItem = dynamic_cast<DItem *>(object());
auto diagramItem = dynamic_cast<DItem *>(object());
Q_UNUSED(diagramItem); // avoid warning about unsed variable
QMT_CHECK(diagramItem);
......@@ -198,7 +198,7 @@ void ItemItem::relationDrawn(const QString &id, const QPointF &toScenePos, const
DElement *targetElement = diagramSceneModel()->findTopmostElement(toScenePos);
if (targetElement) {
if (id == QStringLiteral("dependency")) {
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
auto dependantObject = dynamic_cast<DObject *>(targetElement);
if (dependantObject)
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
}
......
......@@ -561,7 +561,7 @@ const Style *ObjectItem::adaptedStyle(const QString &stereotypeIconId)
{
QList<const DObject *> collidingObjects;
foreach (const QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::CollidingItems)) {
if (const ObjectItem *objectItem = dynamic_cast<const ObjectItem *>(item))
if (auto objectItem = dynamic_cast<const ObjectItem *>(item))
collidingObjects.append(objectItem->object());
}
QColor baseColor;
......@@ -591,7 +591,7 @@ bool ObjectItem::showContext() const
MObject *owner = mobject->owner();
if (owner) {
foreach (QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::CollidingOuterItems)) {
if (ObjectItem *objectItem = dynamic_cast<ObjectItem *>(item)) {
if (auto objectItem = dynamic_cast<ObjectItem *>(item)) {
if (objectItem->object()->modelUid().isValid() && objectItem->object()->modelUid() == owner->uid()) {
showContext = false;
break;
......@@ -688,7 +688,7 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
QAction *selectedAction = menu.exec(event->screenPos());
if (selectedAction) {
if (!handleSelectedContextMenuAction(selectedAction)) {
ContextMenuAction *action = dynamic_cast<ContextMenuAction *>(selectedAction);
auto action = dynamic_cast<ContextMenuAction *>(selectedAction);
QMT_CHECK(action);
if (action->id() == QStringLiteral("openDiagram")) {
m_diagramSceneModel->diagramSceneController()->elementTasks()->openDiagram(m_object, m_diagramSceneModel->diagram());
......@@ -733,7 +733,7 @@ QSizeF ObjectItem::minimumSize(const QSet<QGraphicsItem *> &items) const
{
QSizeF minimumSize(0.0, 0.0);
foreach (QGraphicsItem *item, items) {
if (IResizable *resizable = dynamic_cast<IResizable *>(item)) {
if (auto resizable = dynamic_cast<IResizable *>(item)) {
QSizeF size = resizable->minimumSize();
if (size.width() > minimumSize.width())
minimumSize.setWidth(size.width());
......
......@@ -213,7 +213,7 @@ void PackageItem::relationDrawn(const QString &id, const QPointF &toScenePos, co
DElement *targetElement = diagramSceneModel()->findTopmostElement(toScenePos);
if (targetElement) {
if (id == QStringLiteral("dependency")) {
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
auto dependantObject = dynamic_cast<DObject *>(targetElement);
if (dependantObject)
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
}
......
......@@ -468,7 +468,7 @@ QPointF RelationItem::calcEndPoint(const Uid &end, const QPointF &otherEndPos, i
{
QGraphicsItem *endItem = m_diagramSceneModel->graphicsItem(end);
QMT_CHECK(endItem);
IIntersectionable *endObjectItem = dynamic_cast<IIntersectionable *>(endItem);
auto endObjectItem = dynamic_cast<IIntersectionable *>(endItem);
QPointF endPos;
if (endObjectItem) {
DObject *endObject = m_diagramSceneModel->diagramController()->findElement<DObject>(end, m_diagramSceneModel->diagram());
......
......@@ -116,7 +116,7 @@ void LatchController::mouseMoveEventLatching(QGraphicsSceneMouseEvent *event)
if (!m_diagramSceneModel->focusItem())
return;
ILatchable *palpedLatchable = dynamic_cast<ILatchable *>(m_diagramSceneModel->focusItem());
auto palpedLatchable = dynamic_cast<ILatchable *>(m_diagramSceneModel->focusItem());
if (!palpedLatchable)
return;
......@@ -135,7 +135,7 @@ void LatchController::mouseMoveEventLatching(QGraphicsSceneMouseEvent *event)
foreach (QGraphicsItem *item, m_diagramSceneModel->graphicsItems()) {
if (item != m_diagramSceneModel->focusItem() && !m_diagramSceneModel->isSelectedItem(item)) {
if (ILatchable *latchable = dynamic_cast<ILatchable *>(item)) {
if (auto latchable = dynamic_cast<ILatchable *>(item)) {
QList<ILatchable::Latch> horizontals = latchable->horizontalLatches(horizAction, false);
foreach (const ILatchable::Latch &palpedLatch, palpedHorizontals) {
foreach (const ILatchable::Latch &latch, horizontals) {
......@@ -226,7 +226,7 @@ void LatchController::mouseReleaseEventLatching(QGraphicsSceneMouseEvent *event)
case ILatchable::Hcenter:
foreach (QGraphicsItem *item, m_diagramSceneModel->selectedItems()) {
DElement *element = m_diagramSceneModel->element(item);
if (DObject *selectedObject = dynamic_cast<DObject *>(element)) {
if (auto selectedObject = dynamic_cast<DObject *>(element)) {
m_diagramSceneModel->diagramController()->startUpdateElement(selectedObject, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
QPointF newPos = selectedObject->pos();