Commit 32576910 authored by Jochen Becher's avatar Jochen Becher

ModelEditor: break lines in source files

Change-Id: Ie8a01d146c062be75657fca2423734f3d2f7f296
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent aecfeb87
......@@ -476,30 +476,36 @@ void StereotypeDefinitionParser::parseIconCommands(StereotypeIcon *stereotypeIco
break;
case KEYWORD_ELLIPSE:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
iconShape.addEllipse(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)));
iconShape.addEllipse(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_LINE:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
iconShape.addLine(ShapePointF(parameters.at(0), parameters.at(1)), ShapePointF(parameters.at(2), parameters.at(3)));
iconShape.addLine(ShapePointF(parameters.at(0), parameters.at(1)),
ShapePointF(parameters.at(2), parameters.at(3)));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_RECT:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED);
iconShape.addRect(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)));
iconShape.addRect(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_ROUNDEDRECT:
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << FIX);
iconShape.addRoundedRect(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), parameters.at(4));
iconShape.addRoundedRect(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)), parameters.at(4));
expectSemicolonOrEndOfLine();
break;
case KEYWORD_ARC:
{
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
parameters = parseIconCommandParameters(
Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
qreal startAngle = expectAbsoluteValue(parameters.at(4), d->m_scanner->sourcePos());
qreal spanAngle = expectAbsoluteValue(parameters.at(5), d->m_scanner->sourcePos());
iconShape.addArc(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), startAngle, spanAngle);
iconShape.addArc(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)), startAngle, spanAngle);
expectSemicolonOrEndOfLine();
break;
}
......@@ -515,18 +521,22 @@ void StereotypeDefinitionParser::parseIconCommands(StereotypeIcon *stereotypeIco
break;
case KEYWORD_ARCMOVETO:
{
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE);
parameters = parseIconCommandParameters(
Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE);
qreal angle = expectAbsoluteValue(parameters.at(4), d->m_scanner->sourcePos());
iconShape.arcMoveTo(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), angle);
iconShape.arcMoveTo(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)), angle);
expectSemicolonOrEndOfLine();
break;
}
case KEYWORD_ARCTO:
{
parameters = parseIconCommandParameters(Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
parameters = parseIconCommandParameters(
Parameters() << SCALED << SCALED << SCALED << SCALED << ABSOLUTE << ABSOLUTE);
qreal startAngle = expectAbsoluteValue(parameters.at(4), d->m_scanner->sourcePos());
qreal sweepLength = expectAbsoluteValue(parameters.at(5), d->m_scanner->sourcePos());
iconShape.arcTo(ShapePointF(parameters.at(0), parameters.at(1)), ShapeSizeF(parameters.at(2), parameters.at(3)), startAngle, sweepLength);
iconShape.arcTo(ShapePointF(parameters.at(0), parameters.at(1)),
ShapeSizeF(parameters.at(2), parameters.at(3)), startAngle, sweepLength);
expectSemicolonOrEndOfLine();
break;
}
......@@ -550,7 +560,8 @@ QList<ShapeValueF> StereotypeDefinitionParser::parseIconCommandParameters(const
Token token;
for (;;) {
if (values.count() <= parameters.count())
values << ShapeValueF(parseFloatExpression(), parameters.at(values.count()).m_unit, parameters.at(values.count()).m_origin);
values << ShapeValueF(parseFloatExpression(), parameters.at(values.count()).m_unit,
parameters.at(values.count()).m_origin);
else
values << ShapeValueF(parseFloatExpression());
token = d->m_scanner->read();
......@@ -716,8 +727,10 @@ qreal StereotypeDefinitionParser::expectAbsoluteValue(const ShapeValueF &value,
void StereotypeDefinitionParser::expectSemicolonOrEndOfLine()
{
Token token = d->m_scanner->read();
if (token.type() != Token::TokenEndOfLine && (token.type() != Token::TokenOperator || token.subtype() != OPERATOR_SEMICOLON))
if (token.type() != Token::TokenEndOfLine
&& (token.type() != Token::TokenOperator || token.subtype() != OPERATOR_SEMICOLON)) {
throw StereotypeDefinitionParserError(QStringLiteral("Expected ';' or end-of-line."), token.sourcePos());
}
}
bool StereotypeDefinitionParser::nextIsComma()
......
......@@ -173,14 +173,19 @@ void TextScanner::skipWhitespaces()
if (secondSourceChar.ch == QLatin1Char('/')) {
for (;;) {
SourceChar commentChar = readChar();
if (commentChar.ch.isNull() || commentChar.ch == QChar::LineFeed || commentChar.ch == QChar::CarriageReturn)
if (commentChar.ch.isNull()
|| commentChar.ch == QChar::LineFeed
|| commentChar.ch == QChar::CarriageReturn) {
break;
}
}
} else {
unreadChar(secondSourceChar);
unreadChar(sourceChar);
}
} else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn || !sourceChar.ch.isSpace()) {
} else if (sourceChar.ch == QChar::LineFeed
|| sourceChar.ch == QChar::CarriageReturn
|| !sourceChar.ch.isSpace()) {
unreadChar(sourceChar);
return;
}
......
......@@ -123,7 +123,8 @@ public:
return false;
if (diagramKey() != otherUpdateCommand->diagramKey())
return false;
if (m_updateAction == DiagramController::UpdateMajor || otherUpdateCommand->m_updateAction == DiagramController::UpdateMajor
if (m_updateAction == DiagramController::UpdateMajor
|| otherUpdateCommand->m_updateAction == DiagramController::UpdateMajor
|| m_updateAction != otherUpdateCommand->m_updateAction) {
return false;
}
......@@ -352,21 +353,35 @@ void DiagramController::setModelController(ModelController *modelController)
connect(modelController, SIGNAL(beginResetModel()), this, SLOT(onBeginResetModel()));
connect(modelController, SIGNAL(endResetModel()), this, SLOT(onEndResetModel()));
connect(modelController, SIGNAL(beginUpdateObject(int,const MObject*)), this, SLOT(onBeginUpdateObject(int,const MObject*)));
connect(modelController, SIGNAL(endUpdateObject(int,const MObject*)), this, SLOT(onEndUpdateObject(int,const MObject*)));
connect(modelController, SIGNAL(beginInsertObject(int,const MObject*)), this, SLOT(onBeginInsertObject(int,const MObject*)));
connect(modelController, SIGNAL(endInsertObject(int,const MObject*)), this, SLOT(onEndInsertObject(int,const MObject*)));
connect(modelController, SIGNAL(beginRemoveObject(int,const MObject*)), this, SLOT(onBeginRemoveObject(int,const MObject*)));
connect(modelController, SIGNAL(endRemoveObject(int,const MObject*)), this, SLOT(onEndRemoveObject(int,const MObject*)));
connect(modelController, SIGNAL(beginMoveObject(int,const MObject*)), this, SLOT(onBeginMoveObject(int,const MObject*)));
connect(modelController, SIGNAL(endMoveObject(int,const MObject*)), this, SLOT(onEndMoveObject(int,const MObject*)));
connect(modelController, SIGNAL(beginUpdateRelation(int,const MObject*)), this, SLOT(onBeginUpdateRelation(int,const MObject*)));
connect(modelController, SIGNAL(endUpdateRelation(int,const MObject*)), this, SLOT(onEndUpdateRelation(int,const MObject*)));
connect(modelController, SIGNAL(beginRemoveRelation(int,const MObject*)), this, SLOT(onBeginRemoveRelation(int,const MObject*)));
connect(modelController, SIGNAL(endRemoveRelation(int,const MObject*)), this, SLOT(onEndRemoveRelation(int,const MObject*)));
connect(modelController, SIGNAL(beginMoveRelation(int,const MObject*)), this, SLOT(onBeginMoveRelation(int,const MObject*)));
connect(modelController, SIGNAL(endMoveRelation(int,const MObject*)), this, SLOT(onEndMoveRelation(int,const MObject*)));
connect(modelController, SIGNAL(beginUpdateObject(int,const MObject*)),
this, SLOT(onBeginUpdateObject(int,const MObject*)));
connect(modelController, SIGNAL(endUpdateObject(int,const MObject*)),
this, SLOT(onEndUpdateObject(int,const MObject*)));
connect(modelController, SIGNAL(beginInsertObject(int,const MObject*)),
this, SLOT(onBeginInsertObject(int,const MObject*)));
connect(modelController, SIGNAL(endInsertObject(int,const MObject*)),
this, SLOT(onEndInsertObject(int,const MObject*)));
connect(modelController, SIGNAL(beginRemoveObject(int,const MObject*)),
this, SLOT(onBeginRemoveObject(int,const MObject*)));
connect(modelController, SIGNAL(endRemoveObject(int,const MObject*)),
this, SLOT(onEndRemoveObject(int,const MObject*)));
connect(modelController, SIGNAL(beginMoveObject(int,const MObject*)),
this, SLOT(onBeginMoveObject(int,const MObject*)));
connect(modelController, SIGNAL(endMoveObject(int,const MObject*)),
this, SLOT(onEndMoveObject(int,const MObject*)));
connect(modelController, SIGNAL(beginUpdateRelation(int,const MObject*)),
this, SLOT(onBeginUpdateRelation(int,const MObject*)));
connect(modelController, SIGNAL(endUpdateRelation(int,const MObject*)),
this, SLOT(onEndUpdateRelation(int,const MObject*)));
connect(modelController, SIGNAL(beginRemoveRelation(int,const MObject*)),
this, SLOT(onBeginRemoveRelation(int,const MObject*)));
connect(modelController, SIGNAL(endRemoveRelation(int,const MObject*)),
this, SLOT(onEndRemoveRelation(int,const MObject*)));
connect(modelController, SIGNAL(beginMoveRelation(int,const MObject*)),
this, SLOT(onBeginMoveRelation(int,const MObject*)));
connect(modelController, SIGNAL(endMoveRelation(int,const MObject*)),
this, SLOT(onEndMoveRelation(int,const MObject*)));
}
}
......@@ -697,7 +712,8 @@ void DiagramController::onEndMoveRelation(int row, const MObject *owner)
onEndUpdateRelation(row, owner);
}
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram, const QString &commandLabel)
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram,
const QString &commandLabel)
{
QMT_CHECK(diagram);
......@@ -783,8 +799,10 @@ void DiagramController::removeRelations(DElement *element, MDiagram *diagram)
if (diagramObject) {
foreach (DElement *diagramElement, diagram->diagramElements()) {
if (DRelation *diagramRelation = dynamic_cast<DRelation *>(diagramElement)) {
if (diagramRelation->endAUid() == diagramObject->uid() || diagramRelation->endBUid() == diagramObject->uid())
if (diagramRelation->endAUid() == diagramObject->uid()
|| diagramRelation->endBUid() == diagramObject->uid()) {
removeElement(diagramRelation, diagram);
}
}
}
}
......@@ -843,7 +861,8 @@ void DiagramController::updateElementFromModel(DElement *element, const MDiagram
void DiagramController::diagramModified(MDiagram *diagram)
{
// the modification date is updated intentionally without signalling model controller avoiding recursive change updates
// the modification date is updated intentionally without signalling model controller
// avoiding recursive change updates
diagram->setLastModifiedToNow();
emit modified(diagram);
}
......
......@@ -139,14 +139,22 @@ void DiagramSceneModel::setDiagramController(DiagramController *diagramControlle
if (diagramController) {
connect(m_diagramController, SIGNAL(beginResetAllDiagrams()), this, SLOT(onBeginResetAllDiagrams()));
connect(m_diagramController, SIGNAL(endResetAllDiagrams()), this, SLOT(onEndResetAllDiagrams()));
connect(m_diagramController, SIGNAL(beginResetDiagram(const MDiagram*)), this, SLOT(onBeginResetDiagram(const MDiagram*)));
connect(m_diagramController, SIGNAL(endResetDiagram(const MDiagram*)), this, SLOT(onEndResetDiagram(const MDiagram*)));
connect(m_diagramController, SIGNAL(beginUpdateElement(int,const MDiagram*)), this, SLOT(onBeginUpdateElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(endUpdateElement(int,const MDiagram*)), this, SLOT(onEndUpdateElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(beginInsertElement(int,const MDiagram*)), this, SLOT(onBeginInsertElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(endInsertElement(int,const MDiagram*)), this, SLOT(onEndInsertElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(beginRemoveElement(int,const MDiagram*)), this, SLOT(onBeginRemoveElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(endRemoveElement(int,const MDiagram*)), this, SLOT(onEndRemoveElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(beginResetDiagram(const MDiagram*)),
this, SLOT(onBeginResetDiagram(const MDiagram*)));
connect(m_diagramController, SIGNAL(endResetDiagram(const MDiagram*)),
this, SLOT(onEndResetDiagram(const MDiagram*)));
connect(m_diagramController, SIGNAL(beginUpdateElement(int,const MDiagram*)),
this, SLOT(onBeginUpdateElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(endUpdateElement(int,const MDiagram*)),
this, SLOT(onEndUpdateElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(beginInsertElement(int,const MDiagram*)),
this, SLOT(onBeginInsertElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(endInsertElement(int,const MDiagram*)),
this, SLOT(onEndInsertElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(beginRemoveElement(int,const MDiagram*)),
this, SLOT(onBeginRemoveElement(int,const MDiagram*)));
connect(m_diagramController, SIGNAL(endRemoveElement(int,const MDiagram*)),
this, SLOT(onEndRemoveElement(int,const MDiagram*)));
}
}
......@@ -299,7 +307,8 @@ void DiagramSceneModel::copyToClipboard()
painter.setRenderHint(QPainter::Antialiasing);
m_graphicsScene->render(&painter,
QRectF(border, border,
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
painter.device()->width() - 2 * border,
painter.device()->height() - 2 * border),
sceneBoundingRect);
painter.end();
mimeData->setImageData(image);
......@@ -326,7 +335,8 @@ void DiagramSceneModel::copyToClipboard()
pdfPainter.begin(&pdfWriter);
m_graphicsScene->render(&pdfPainter,
QRectF(border, border,
pdfPainter.device()->width() - 2 * border, pdfPainter.device()->height() - 2 * border),
pdfPainter.device()->width() - 2 * border,
pdfPainter.device()->height() - 2 * border),
sceneBoundingRect);
pdfPainter.end();
pdfBuffer.close();
......@@ -347,7 +357,8 @@ void DiagramSceneModel::copyToClipboard()
svgPainter.setRenderHint(QPainter::Antialiasing);
m_graphicsScene->render(&svgPainter,
QRectF(border, border,
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
painter.device()->width() - 2 * border,
painter.device()->height() - 2 * border),
sceneBoundingRect);
svgPainter.end();
mimeData->setData(QStringLiteral("image/svg+xml"), svgBuffer.buffer());
......@@ -385,7 +396,8 @@ bool DiagramSceneModel::exportPng(const QString &fileName)
painter.setRenderHint(QPainter::Antialiasing);
m_graphicsScene->render(&painter,
QRectF(border, border,
painter.device()->width() - 2 * border, painter.device()->height() - 2 * border),
painter.device()->width() - 2 * border,
painter.device()->height() - 2 * border),
sceneBoundingRect);
painter.end();
......@@ -417,7 +429,8 @@ void DiagramSceneModel::exportPdf(const QString &fileName)
pdfPainter.begin(&pdfWriter);
m_graphicsScene->render(&pdfPainter,
QRectF(border, border,
pdfPainter.device()->width() - 2 * border, pdfPainter.device()->height() - 2 * border),
pdfPainter.device()->width() - 2 * border,
pdfPainter.device()->height() - 2 * border),
sceneBoundingRect);
pdfPainter.end();
......@@ -474,7 +487,8 @@ void DiagramSceneModel::onDoubleClickedItem(QGraphicsItem *item)
m_diagramSceneController->elementTasks()->openElement(element, m_diagram);
}
QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGraphicsItem *item, CollidingMode collidingMode) const
QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGraphicsItem *item,
CollidingMode collidingMode) const
{
QList<QGraphicsItem *> collidingItems;
......
......@@ -139,7 +139,8 @@ void DiagramSceneModel::CreationVisitor::visitDBoundary(DBoundary *boundary)
m_graphicsItem = new BoundaryItem(boundary, m_diagramSceneModel);
}
DiagramSceneModel::UpdateVisitor::UpdateVisitor(QGraphicsItem *item, DiagramSceneModel *diagramSceneModel, DElement *relatedElement)
DiagramSceneModel::UpdateVisitor::UpdateVisitor(QGraphicsItem *item, DiagramSceneModel *diagramSceneModel,
DElement *relatedElement)
: m_graphicsItem(item),
m_diagramSceneModel(diagramSceneModel),
m_relatedElement(relatedElement)
......@@ -241,7 +242,9 @@ void DiagramSceneModel::UpdateVisitor::visitDRelation(DRelation *relation)
{
QMT_CHECK(m_graphicsItem);
if (m_relatedElement == 0 || m_relatedElement->uid() == relation->endAUid() || m_relatedElement->uid() == relation->endBUid()) {
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_CHECK(relationItem->relation() == relation);
......
......@@ -154,7 +154,8 @@ QSizeF AnnotationItem::minimumSize() const
return calcMinimumGeometry();
}
void AnnotationItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta)
void AnnotationItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect,
const QPointF &topLeftDelta, const QPointF &bottomRightDelta)
{
QPointF newPos = originalPos;
QRectF newRect = originalRect;
......@@ -169,7 +170,8 @@ void AnnotationItem::setPosAndRect(const QPointF &originalPos, const QRectF &ori
}
}
void AnnotationItem::alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight)
void AnnotationItem::alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide,
double rasterWidth, double rasterHeight)
{
Q_UNUSED(adjustHorizontalSide);
Q_UNUSED(adjustVerticalSide);
......
......@@ -78,7 +78,9 @@ void AssociationItem::update(const Style *style)
placeEndLabels(m_arrow->lastLineSegment(), m_endBName, m_endBCardinality, endBItem, m_arrow->endHeadLength());
}
void AssociationItem::updateEndLabels(const DAssociationEnd &end, const DAssociationEnd &otherEnd, QGraphicsSimpleTextItem **endName, QGraphicsSimpleTextItem **endCardinality, const Style *style)
void AssociationItem::updateEndLabels(const DAssociationEnd &end, const DAssociationEnd &otherEnd,
QGraphicsSimpleTextItem **endName, QGraphicsSimpleTextItem **endCardinality,
const Style *style)
{
Q_UNUSED(end);
......@@ -107,7 +109,8 @@ void AssociationItem::updateEndLabels(const DAssociationEnd &end, const DAssocia
}
}
void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *endName, QGraphicsItem *endCardinality, QGraphicsItem *endItem, double headLength)
void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *endName, QGraphicsItem *endCardinality,
QGraphicsItem *endItem, double headLength)
{
const double HEAD_OFFSET = headLength + 6.0;
const double SIDE_OFFSET = 4.0;
......@@ -119,12 +122,14 @@ void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *e
if (endName)
endName->setPos(lineSegment.p1() + headOffset + sideOffset);
if (endCardinality)
endCardinality->setPos(lineSegment.p1() + headOffset - sideOffset - endCardinality->boundingRect().bottomLeft());
endCardinality->setPos(lineSegment.p1() + headOffset - sideOffset
- endCardinality->boundingRect().bottomLeft());
} else if (angle <= -175 || angle >= 175) {
if (endName)
endName->setPos(lineSegment.p1() - headOffset + sideOffset - endName->boundingRect().topRight());
if (endCardinality)
endCardinality->setPos(lineSegment.p1() - headOffset - sideOffset - endCardinality->boundingRect().bottomRight());
endCardinality->setPos(lineSegment.p1() - headOffset
- sideOffset - endCardinality->boundingRect().bottomRight());
} else {
QRectF rect;
if (endCardinality)
......@@ -139,9 +144,12 @@ void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *e
QPointF intersectionPoint;
QLineF intersectionLine;
if (objectItem->intersectShapeWithLine(GeometryUtilities::stretch(lineSegment.translated(pos()), 2.0, 0.0), &intersectionPoint, &intersectionLine)) {
if (!GeometryUtilities::placeRectAtLine(rect, lineSegment, HEAD_OFFSET, SIDE_OFFSET, intersectionLine, &rectPlacement, &alignedSide))
if (objectItem->intersectShapeWithLine(GeometryUtilities::stretch(lineSegment.translated(pos()), 2.0, 0.0),
&intersectionPoint, &intersectionLine)) {
if (!GeometryUtilities::placeRectAtLine(rect, lineSegment, HEAD_OFFSET, SIDE_OFFSET,
intersectionLine, &rectPlacement, &alignedSide)) {
rectPlacement = intersectionPoint;
}
} else {
rectPlacement = lineSegment.p1();
}
......@@ -151,7 +159,8 @@ void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *e
if (endCardinality) {
if (alignedSide == GeometryUtilities::SideRight)
endCardinality->setPos(rectPlacement + QPointF(rect.width() - endCardinality->boundingRect().width(), 0.0));
endCardinality->setPos(rectPlacement
+ QPointF(rect.width() - endCardinality->boundingRect().width(), 0.0));
else
endCardinality->setPos(rectPlacement);
rectPlacement += endCardinality->boundingRect().bottomLeft();
......
......@@ -169,7 +169,8 @@ QSizeF BoundaryItem::minimumSize() const
return calcMinimumGeometry();
}
void BoundaryItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta)
void BoundaryItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta,
const QPointF &bottomRightDelta)
{
QPointF newPos = originalPos;
QRectF newRect = originalRect;
......@@ -182,7 +183,8 @@ void BoundaryItem::setPosAndRect(const QPointF &originalPos, const QRectF &origi
}
}
void BoundaryItem::alignItemSizeToRaster(IResizable::Side adjustHorizontalSide, IResizable::Side adjustVerticalSide, double rasterWidth, double rasterHeight)
void BoundaryItem::alignItemSizeToRaster(IResizable::Side adjustHorizontalSide, IResizable::Side adjustVerticalSide,
double rasterWidth, double rasterHeight)
{
QPointF pos = m_boundary->pos();
QRectF rect = m_boundary->rect();
......
......@@ -363,8 +363,10 @@ QSizeF ClassItem::calcMinimumGeometry() const
double width = 0.0;
double height = 0.0;
if (m_customIcon)
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
if (m_customIcon) {
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(),
CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
}
height += BODY_VERT_BORDER;
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
......
......@@ -261,8 +261,9 @@ QSizeF ComponentItem::calcMinimumGeometry() const
double width = 0.0;
double height = 0.0;
if (m_customIcon)
if (m_customIcon) {
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
}
height += BODY_VERT_BORDER;
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
......
......@@ -158,8 +158,10 @@ QSizeF DiagramItem::calcMinimumGeometry() const
double width = MINIMUM_WIDTH;
double height = 0.0;
if (m_customIcon)
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
if (m_customIcon) {
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(),
CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
}
height += BODY_VERT_BORDER;
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
......
......@@ -210,8 +210,10 @@ QSizeF ItemItem::calcMinimumGeometry() const
double width = 0.0;
double height = 0.0;
if (m_customIcon)
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
if (m_customIcon) {
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(),
CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
}
height += BODY_VERT_BORDER;
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
......
......@@ -102,7 +102,8 @@ QRectF ObjectItem::rect() const
return m_object->rect();
}
void ObjectItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta)
void ObjectItem::setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta,
const QPointF &bottomRightDelta)
{
QPointF newPos = originalPos;
QRectF newRect = originalRect;
......@@ -117,7 +118,8 @@ void ObjectItem::setPosAndRect(const QPointF &originalPos, const QRectF &origina
}
}
void ObjectItem::alignItemSizeToRaster(IResizable::Side adjustHorizontalSide, IResizable::Side adjustVerticalSide, double rasterWidth, double rasterHeight)
void ObjectItem::alignItemSizeToRaster(IResizable::Side adjustHorizontalSide, IResizable::Side adjustVerticalSide,
double rasterWidth, double rasterHeight)
{
QPointF pos = m_object->pos();
QRectF rect = m_object->rect();
......@@ -277,42 +279,51 @@ void ObjectItem::align(IAlignable::AlignType alignType, const QString &identifie
switch (alignType) {
case IAlignable::AlignLeft:
QMT_CHECK(identifier == QStringLiteral("left"));
m_diagramSceneModel->diagramSceneController()->alignLeft(m_object, m_diagramSceneModel->selectedElements(), m_diagramSceneModel->diagram());
m_diagramSceneModel->diagramSceneController()->alignLeft(m_object, m_diagramSceneModel->selectedElements(),
m_diagramSceneModel->diagram());
break;
case IAlignable::AlignRight:
QMT_CHECK(identifier == QStringLiteral("right"));
m_diagramSceneModel->diagramSceneController()->alignRight(m_object, m_diagramSceneModel->selectedElements(), m_diagramSceneModel->diagram());
m_diagramSceneModel->diagramSceneController()->alignRight(m_object, m_diagramSceneModel->selectedElements(),
m_diagramSceneModel->diagram());
break;
case IAlignable::AlignTop:
QMT_CHECK(identifier == QStringLiteral("top"));
m_diagramSceneModel->diagramSceneController()->alignTop(m_object, m_diagramSceneModel->selectedElements(), m_diagramSceneModel->diagram());
m_diagramSceneModel->diagramSceneController()->alignTop(m_object, m_diagramSceneModel->selectedElements(),
m_diagramSceneModel->diagram());
break;
case IAlignable::AlignBottom:
QMT_CHECK(identifier == QStringLiteral("bottom"));
m_diagramSceneModel->diagramSceneController()->alignBottom(m_object, m_diagramSceneModel->selectedElements(), m_diagramSceneModel->diagram());
m_diagramSceneModel->diagramSceneController()->alignBottom(m_object, m_diagramSceneModel->selectedElements(),
m_diagramSceneModel->diagram());
break;
case IAlignable::AlignHcenter:
QMT_CHECK(identifier == QStringLiteral("center"));
m_diagramSceneModel->diagramSceneController()->alignHCenter(m_object, m_diagramSceneModel->selectedElements(), m_diagramSceneModel->diagram());
m_diagramSceneModel->diagramSceneController()->alignHCenter(m_object, m_diagramSceneModel->selectedElements(),
m_diagramSceneModel->diagram());
break;
case IAlignable::AlignVcenter:
QMT_CHECK(identifier == QStringLiteral("center"));
m_diagramSceneModel->diagramSceneController()->alignVCenter(m_object, m_diagramSceneModel->selectedElements(), m_diagramSceneModel->diagram());
m_diagramSceneModel->diagramSceneController()->alignVCenter(m_object, m_diagramSceneModel->selectedElements(),
m_diagramSceneModel->diagram());
break;
case IAlignable::AlignWidth:
QMT_CHECK(identifier == QStringLiteral("width"));
m_diagramSceneModel->diagramSceneController()->alignWidth(m_object, m_diagramSceneModel->selectedElements(),
minimumSize(m_diagramSceneModel->selectedItems()), m_diagramSceneModel->diagram());
minimumSize(m_diagramSceneModel->selectedItems()),
m_diagramSceneModel->diagram());
break;
case IAlignable::AlignHeight:
QMT_CHECK(identifier == QStringLiteral("height"));
m_diagramSceneModel->diagramSceneController()->alignHeight(m_object, m_diagramSceneModel->selectedElements(),
minimumSize(m_diagramSceneModel->selectedItems()), m_diagramSceneModel->diagram());
minimumSize(m_diagramSceneModel->selectedItems()),
m_diagramSceneModel->diagram());
break;
case IAlignable::AlignSize:
QMT_CHECK(identifier == QStringLiteral("size"));
m_diagramSceneModel->diagramSceneController()->alignSize(m_object, m_diagramSceneModel->selectedElements(),
minimumSize(m_diagramSceneModel->selectedItems()), m_diagramSceneModel->diagram());
minimumSize(m_diagramSceneModel->selectedItems()),
m_diagramSceneModel->diagram());
break;
}
}
......@@ -328,7 +339,8 @@ void ObjectItem::updateStereotypeIconDisplay()
m_stereotypeIconDisplay = stereotypeDisplayVisitor.stereotypeIconDisplay();
}
void ObjectItem::updateStereotypes(const QString &stereotypeIconId, StereotypeIcon::Display stereotypeDisplay, const Style *style)
void ObjectItem::updateStereotypes(const QString &stereotypeIconId, StereotypeIcon::Display stereotypeDisplay,
const Style *style)
{
QList<QString> stereotypes = m_object->stereotypes();
if (!stereotypeIconId.isEmpty()
......@@ -360,7 +372,8 @@ void ObjectItem::updateStereotypes(const QString &stereotypeIconId, StereotypeIc
}
}
QSizeF ObjectItem::stereotypeIconMinimumSize(const StereotypeIcon &stereotypeIcon, qreal minimumWidth, qreal minimumHeight) const
QSizeF ObjectItem::stereotypeIconMinimumSize(const StereotypeIcon &stereotypeIcon,
qreal minimumWidth, qreal minimumHeight) const
{
Q_UNUSED(minimumWidth);
......@@ -649,17 +662,21 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
addSeparator = true;
if (addSeparator)
menu.addSeparator();
menu.addAction(new ContextMenuAction(QObject::tr("Remove"), QStringLiteral("remove"), QKeySequence(QKeySequence::Delete), &menu));
menu.addAction(new ContextMenuAction(QObject::tr("Delete"), QStringLiteral("delete"), QKeySequence(Qt::CTRL + Qt::Key_D), &menu));
menu.addAction(new ContextMenuAction(QObject::tr("Remove"), QStringLiteral("remove"),
QKeySequence(QKeySequence::Delete), &menu));
menu.addAction(new ContextMenuAction(QObject::tr("Delete"), QStringLiteral("delete"),
QKeySequence(Qt::CTRL + Qt::Key_D), &menu));
//menu.addAction(new ContextMenuAction(QObject::tr("Select in Model Tree"), QStringLiteral("selectInModelTree"), &menu));
QMenu alignMenu;
alignMenu.setTitle(QObject::tr("Align Objects"));
alignMenu.addAction(new ContextMenuAction(QObject::tr("Align Left"), QStringLiteral("alignLeft"), &alignMenu));
alignMenu.addAction(new ContextMenuAction(QObject::tr("Center Vertically"), QStringLiteral("centerVertically"), &alignMenu));
alignMenu.addAction(new ContextMenuAction(QObject::tr("Center Vertically"), QStringLiteral("centerVertically"),
&alignMenu));
alignMenu.addAction(new ContextMenuAction(QObject::tr("Align Right"), QStringLiteral("alignRight"), &alignMenu));
alignMenu.addSeparator();
alignMenu.addAction(new ContextMenuAction(QObject::tr("Align Top"), QStringLiteral("alignTop"), &alignMenu));
alignMenu.addAction(new ContextMenuAction(QObject::tr("Center Horizontally"), QStringLiteral("centerHorizontally"), &alignMenu));
alignMenu.addAction(new ContextMenuAction(QObject::tr("Center Horizontally"), QStringLiteral("centerHorizontally"),
&alignMenu));
alignMenu.addAction(new ContextMenuAction(QObject::tr("Align Bottom"), QStringLiteral("alignBottom"), &alignMenu));
alignMenu.addSeparator();
alignMenu.addAction(new ContextMenuAction(QObject::tr("Same Width"), QStringLiteral("sameWidth"), &alignMenu));
......
......@@ -227,9 +227,10 @@ PackageItem::ShapeGeometry PackageItem::calcMinimumGeometry() const
double tabHeight = 0.0;
double tabWidth = 0.0;
if (m_customIcon)
return ShapeGeometry(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT), QSizeF(tabWidth, tabHeight));
if (m_customIcon) {
return ShapeGeometry(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH,
CUSTOM_ICON_MINIMUM_AUTO_HEIGHT), QSizeF(tabWidth, tabHeight));
}
double bodyHeight = 0.0;
double bodyWidth = 0.0;
......
......@@ -140,7 +140,8 @@ void LatchController::mouseMoveEventLatching(QGraphicsSceneMouseEvent *event)
foreach (const ILatchable::Latch &palpedLatch, palpedHorizontals) {
foreach (const ILatchable::Latch &latch, horizontals) {
if (palpedLatch.m_latchType == latch.m_latchType) {
// calculate distance and minimal distance with sign because this is needed later to move the objects