2015-08-16 13:11:15 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2015 Jochen Becher
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "classitem.h"
|
|
|
|
|
|
2015-12-26 23:55:59 +01:00
|
|
|
#include "qmt/controller/namecontroller.h"
|
2015-08-16 13:11:15 +02:00
|
|
|
#include "qmt/diagram/dclass.h"
|
|
|
|
|
#include "qmt/diagram_scene/diagramsceneconstants.h"
|
|
|
|
|
#include "qmt/diagram_scene/diagramscenemodel.h"
|
|
|
|
|
#include "qmt/diagram_scene/parts/contextlabelitem.h"
|
|
|
|
|
#include "qmt/diagram_scene/parts/customiconitem.h"
|
2015-12-26 23:55:59 +01:00
|
|
|
#include "qmt/diagram_scene/parts/editabletextitem.h"
|
2015-08-16 13:11:15 +02:00
|
|
|
#include "qmt/diagram_scene/parts/relationstarter.h"
|
|
|
|
|
#include "qmt/diagram_scene/parts/stereotypesitem.h"
|
|
|
|
|
#include "qmt/diagram_scene/parts/templateparameterbox.h"
|
|
|
|
|
#include "qmt/infrastructure/contextmenuaction.h"
|
|
|
|
|
#include "qmt/infrastructure/geometryutilities.h"
|
|
|
|
|
#include "qmt/infrastructure/qmtassert.h"
|
2015-12-26 23:55:59 +01:00
|
|
|
#include "qmt/model/mclass.h"
|
2015-08-16 13:11:15 +02:00
|
|
|
#include "qmt/model/mclassmember.h"
|
2015-12-26 23:55:59 +01:00
|
|
|
#include "qmt/model_controller/modelcontroller.h"
|
2015-08-16 13:11:15 +02:00
|
|
|
#include "qmt/stereotype/stereotypecontroller.h"
|
|
|
|
|
#include "qmt/stereotype/stereotypeicon.h"
|
|
|
|
|
#include "qmt/style/stylecontroller.h"
|
|
|
|
|
#include "qmt/style/style.h"
|
|
|
|
|
#include "qmt/tasks/diagramscenecontroller.h"
|
|
|
|
|
#include "qmt/tasks/ielementtasks.h"
|
|
|
|
|
|
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
|
#include <QGraphicsRectItem>
|
|
|
|
|
#include <QGraphicsSimpleTextItem>
|
|
|
|
|
#include <QGraphicsLineItem>
|
|
|
|
|
#include <QBrush>
|
|
|
|
|
#include <QPen>
|
|
|
|
|
#include <QFont>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
namespace qmt {
|
|
|
|
|
|
|
|
|
|
static const qreal MINIMUM_AUTO_WIDTH = 80.0;
|
|
|
|
|
static const qreal MINIMUM_AUTO_HEIGHT = 60.0;
|
|
|
|
|
static const qreal BODY_VERT_BORDER = 4.0;
|
|
|
|
|
static const qreal BODY_HORIZ_BORDER = 4.0;
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
ClassItem::ClassItem(DClass *klass, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
2015-11-23 22:48:45 +01:00
|
|
|
: ObjectItem(klass, diagramSceneModel, parent)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClassItem::~ClassItem()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClassItem::update()
|
|
|
|
|
{
|
|
|
|
|
prepareGeometryChange();
|
|
|
|
|
|
|
|
|
|
updateStereotypeIconDisplay();
|
|
|
|
|
|
2015-11-21 20:54:19 +01:00
|
|
|
auto diagramClass = dynamic_cast<DClass *>(object());
|
2015-11-04 07:52:44 +01:00
|
|
|
QMT_CHECK(diagramClass);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 22:44:41 +01:00
|
|
|
const Style *style = adaptedStyle(stereotypeIconId());
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 22:44:41 +01:00
|
|
|
if (diagramClass->showAllMembers()) {
|
2015-08-16 13:11:15 +02:00
|
|
|
updateMembers(style);
|
|
|
|
|
} else {
|
2015-11-03 22:30:46 +01:00
|
|
|
m_attributesText.clear();
|
|
|
|
|
m_methodsText.clear();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// custom icon
|
2015-11-04 23:34:44 +01:00
|
|
|
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_customIcon)
|
2015-11-04 22:44:41 +01:00
|
|
|
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
|
|
|
|
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
|
|
|
|
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
|
|
|
|
m_customIcon->setBrush(style->fillBrush());
|
|
|
|
|
m_customIcon->setPen(style->outerLinePen());
|
2015-11-03 22:30:46 +01:00
|
|
|
m_customIcon->setZValue(SHAPE_ZVALUE);
|
|
|
|
|
} else if (m_customIcon) {
|
|
|
|
|
m_customIcon->scene()->removeItem(m_customIcon);
|
|
|
|
|
delete m_customIcon;
|
|
|
|
|
m_customIcon = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// shape
|
2015-11-03 22:30:46 +01:00
|
|
|
if (!m_customIcon) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_shape)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_shape = new QGraphicsRectItem(this);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_shape->setBrush(style->fillBrush());
|
|
|
|
|
m_shape->setPen(style->outerLinePen());
|
2015-11-03 22:30:46 +01:00
|
|
|
m_shape->setZValue(SHAPE_ZVALUE);
|
|
|
|
|
} else if (m_shape){
|
|
|
|
|
m_shape->scene()->removeItem(m_shape);
|
|
|
|
|
delete m_shape;
|
|
|
|
|
m_shape = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stereotypes
|
2015-11-04 22:44:41 +01:00
|
|
|
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), style);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
|
|
|
|
// namespace
|
2015-11-12 20:05:49 +01:00
|
|
|
if (!diagramClass->umlNamespace().isEmpty()) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_namespace)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_namespace = new QGraphicsSimpleTextItem(this);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_namespace->setFont(style->smallFont());
|
|
|
|
|
m_namespace->setBrush(style->textBrush());
|
2015-11-12 20:05:49 +01:00
|
|
|
m_namespace->setText(diagramClass->umlNamespace());
|
2015-11-03 22:30:46 +01:00
|
|
|
} else if (m_namespace) {
|
|
|
|
|
m_namespace->scene()->removeItem(m_namespace);
|
|
|
|
|
delete m_namespace;
|
|
|
|
|
m_namespace = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// class name
|
2015-12-26 23:55:59 +01:00
|
|
|
updateNameItem(style);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
|
|
|
|
// context
|
|
|
|
|
if (showContext()) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_contextLabel)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_contextLabel = new ContextLabelItem(this);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_contextLabel->setFont(style->smallFont());
|
|
|
|
|
m_contextLabel->setBrush(style->textBrush());
|
|
|
|
|
m_contextLabel->setContext(object()->context());
|
2015-11-03 22:30:46 +01:00
|
|
|
} else if (m_contextLabel) {
|
|
|
|
|
m_contextLabel->scene()->removeItem(m_contextLabel);
|
|
|
|
|
delete m_contextLabel;
|
|
|
|
|
m_contextLabel = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes separator
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_shape || !m_attributesText.isEmpty() || !m_methodsText.isEmpty()) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_attributesSeparator)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_attributesSeparator = new QGraphicsLineItem(this);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_attributesSeparator->setPen(style->innerLinePen());
|
2015-11-03 22:30:46 +01:00
|
|
|
m_attributesSeparator->setZValue(SHAPE_DETAILS_ZVALUE);
|
|
|
|
|
} else if (m_attributesSeparator) {
|
|
|
|
|
m_attributesSeparator->scene()->removeItem(m_attributesSeparator);
|
|
|
|
|
delete m_attributesSeparator;
|
|
|
|
|
m_attributesSeparator = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
2015-11-03 22:30:46 +01:00
|
|
|
if (!m_attributesText.isEmpty()) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_attributes)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_attributes = new QGraphicsTextItem(this);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_attributes->setFont(style->normalFont());
|
|
|
|
|
//m_attributes->setBrush(style->textBrush());
|
|
|
|
|
m_attributes->setDefaultTextColor(style->textBrush().color());
|
2015-11-03 22:30:46 +01:00
|
|
|
m_attributes->setHtml(m_attributesText);
|
|
|
|
|
} else if (m_attributes) {
|
|
|
|
|
m_attributes->scene()->removeItem(m_attributes);
|
|
|
|
|
delete m_attributes;
|
|
|
|
|
m_attributes = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// methods separator
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_shape || !m_attributesText.isEmpty() || !m_methodsText.isEmpty()) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_methodsSeparator)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_methodsSeparator = new QGraphicsLineItem(this);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_methodsSeparator->setPen(style->innerLinePen());
|
2015-11-03 22:30:46 +01:00
|
|
|
m_methodsSeparator->setZValue(SHAPE_DETAILS_ZVALUE);
|
|
|
|
|
} else if (m_methodsSeparator) {
|
|
|
|
|
m_methodsSeparator->scene()->removeItem(m_methodsSeparator);
|
|
|
|
|
delete m_methodsSeparator;
|
|
|
|
|
m_methodsSeparator = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// methods
|
2015-11-03 22:30:46 +01:00
|
|
|
if (!m_methodsText.isEmpty()) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_methods)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_methods = new QGraphicsTextItem(this);
|
2015-11-04 22:44:41 +01:00
|
|
|
m_methods->setFont(style->normalFont());
|
|
|
|
|
//m_methods->setBrush(style->textBrush());
|
|
|
|
|
m_methods->setDefaultTextColor(style->textBrush().color());
|
2015-11-03 22:30:46 +01:00
|
|
|
m_methods->setHtml(m_methodsText);
|
|
|
|
|
} else if (m_methods) {
|
|
|
|
|
m_methods->scene()->removeItem(m_methods);
|
|
|
|
|
delete m_methods;
|
|
|
|
|
m_methods = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// template parameters
|
2015-12-26 23:55:59 +01:00
|
|
|
if (templateDisplay() == DClass::TemplateBox && !diagramClass->templateParameters().isEmpty()) {
|
|
|
|
|
// TODO due to a bug in Qt the m_nameItem may get focus back when this item is newly created
|
|
|
|
|
// 1. Select name item of class without template
|
|
|
|
|
// 2. Click into template property (item name loses focus) and enter a letter
|
|
|
|
|
// 3. Template box is created which gives surprisingly focus back to item name
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_templateParameterBox)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_templateParameterBox = new TemplateParameterBox(this);
|
2015-11-04 22:44:41 +01:00
|
|
|
QPen pen = style->outerLinePen();
|
2015-08-16 13:11:15 +02:00
|
|
|
pen.setStyle(Qt::DashLine);
|
2015-11-03 22:30:46 +01:00
|
|
|
m_templateParameterBox->setPen(pen);
|
|
|
|
|
m_templateParameterBox->setBrush(QBrush(Qt::white));
|
2015-11-04 22:44:41 +01:00
|
|
|
m_templateParameterBox->setFont(style->smallFont());
|
|
|
|
|
m_templateParameterBox->setTextBrush(style->textBrush());
|
|
|
|
|
m_templateParameterBox->setTemplateParameters(diagramClass->templateParameters());
|
2015-11-03 22:30:46 +01:00
|
|
|
} else if (m_templateParameterBox) {
|
|
|
|
|
m_templateParameterBox->scene()->removeItem(m_templateParameterBox);
|
|
|
|
|
delete m_templateParameterBox;
|
|
|
|
|
m_templateParameterBox = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-03 22:30:46 +01:00
|
|
|
updateSelectionMarker(m_customIcon);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
|
|
|
|
// relation starters
|
|
|
|
|
if (isFocusSelected()) {
|
2015-11-03 22:30:46 +01:00
|
|
|
if (!m_relationStarter) {
|
2015-11-04 22:44:41 +01:00
|
|
|
m_relationStarter = new RelationStarter(this, diagramSceneModel(), 0);
|
2015-11-03 22:30:46 +01:00
|
|
|
scene()->addItem(m_relationStarter);
|
|
|
|
|
m_relationStarter->setZValue(RELATION_STARTER_ZVALUE);
|
2015-11-04 23:34:44 +01:00
|
|
|
m_relationStarter->addArrow(QLatin1String("inheritance"), ArrowItem::ShaftSolid, ArrowItem::HeadTriangle);
|
|
|
|
|
m_relationStarter->addArrow(QLatin1String("dependency"), ArrowItem::ShaftDashed, ArrowItem::HeadOpen);
|
|
|
|
|
m_relationStarter->addArrow(QLatin1String("association"), ArrowItem::ShaftSolid, ArrowItem::HeadFilledTriangle);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-03 22:30:46 +01:00
|
|
|
} else if (m_relationStarter) {
|
|
|
|
|
scene()->removeItem(m_relationStarter);
|
|
|
|
|
delete m_relationStarter;
|
|
|
|
|
m_relationStarter = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateAlignmentButtons();
|
|
|
|
|
updateGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
bool ClassItem::intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
|
|
|
|
QPolygonF polygon;
|
2015-11-24 07:20:44 +01:00
|
|
|
// TODO if m_customIcon then use that shape + label's shape as intersection path
|
|
|
|
|
QRectF rect = object()->rect();
|
|
|
|
|
rect.translate(object()->pos());
|
|
|
|
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
2015-11-04 07:52:44 +01:00
|
|
|
return GeometryUtilities::intersect(polygon, line, intersectionPoint, intersectionLine);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-04 22:44:41 +01:00
|
|
|
QSizeF ClassItem::minimumSize() const
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
|
|
|
|
return calcMinimumGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 22:44:41 +01:00
|
|
|
QPointF ClassItem::relationStartPos() const
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
|
|
|
|
return pos();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
void ClassItem::relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
2015-11-04 22:44:41 +01:00
|
|
|
DElement *targetElement = diagramSceneModel()->findTopmostElement(toScenePos);
|
2015-11-04 07:52:44 +01:00
|
|
|
if (targetElement) {
|
2015-08-16 13:11:15 +02:00
|
|
|
if (id == QLatin1String("inheritance")) {
|
2015-11-21 20:54:19 +01:00
|
|
|
auto baseClass = dynamic_cast<DClass *>(targetElement);
|
2015-11-04 07:52:44 +01:00
|
|
|
if (baseClass) {
|
2015-11-21 20:54:19 +01:00
|
|
|
auto derivedClass = dynamic_cast<DClass *>(object());
|
2015-11-04 07:52:44 +01:00
|
|
|
QMT_CHECK(derivedClass);
|
2015-11-04 22:44:41 +01:00
|
|
|
diagramSceneModel()->diagramSceneController()->createInheritance(derivedClass, baseClass, intermediatePoints, diagramSceneModel()->diagram());
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
} else if (id == QLatin1String("dependency")) {
|
2015-11-21 20:54:19 +01:00
|
|
|
auto dependantObject = dynamic_cast<DObject *>(targetElement);
|
2015-11-14 16:59:30 +01:00
|
|
|
if (dependantObject)
|
2015-11-04 22:44:41 +01:00
|
|
|
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
2015-08-16 13:11:15 +02:00
|
|
|
} else if (id == QLatin1String("association")) {
|
2015-11-21 20:54:19 +01:00
|
|
|
auto assoziatedClass = dynamic_cast<DClass *>(targetElement);
|
2015-11-04 07:52:44 +01:00
|
|
|
if (assoziatedClass) {
|
2015-11-21 20:54:19 +01:00
|
|
|
auto derivedClass = dynamic_cast<DClass *>(object());
|
2015-11-04 07:52:44 +01:00
|
|
|
QMT_CHECK(derivedClass);
|
2015-11-04 22:44:41 +01:00
|
|
|
diagramSceneModel()->diagramSceneController()->createAssociation(derivedClass, assoziatedClass, intermediatePoints, diagramSceneModel()->diagram());
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ClassItem::extendContextMenu(QMenu *menu)
|
|
|
|
|
{
|
|
|
|
|
bool extended = false;
|
2015-11-04 22:44:41 +01:00
|
|
|
if (diagramSceneModel()->diagramSceneController()->elementTasks()->hasClassDefinition(object(), diagramSceneModel()->diagram())) {
|
2015-08-16 13:11:15 +02:00
|
|
|
menu->addAction(new ContextMenuAction(QObject::tr("Show Definition"), QStringLiteral("showDefinition"), menu));
|
|
|
|
|
extended = true;
|
|
|
|
|
}
|
|
|
|
|
return extended;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ClassItem::handleSelectedContextMenuAction(QAction *action)
|
|
|
|
|
{
|
2015-11-21 20:54:19 +01:00
|
|
|
auto klassAction = dynamic_cast<ContextMenuAction *>(action);
|
2015-11-04 07:52:44 +01:00
|
|
|
if (klassAction) {
|
2015-11-04 22:44:41 +01:00
|
|
|
if (klassAction->id() == QStringLiteral("showDefinition")) {
|
|
|
|
|
diagramSceneModel()->diagramSceneController()->elementTasks()->openClassDefinition(object(), diagramSceneModel()->diagram());
|
2015-08-16 13:11:15 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-26 23:55:59 +01:00
|
|
|
QString ClassItem::buildDisplayName() const
|
|
|
|
|
{
|
|
|
|
|
auto diagramClass = dynamic_cast<DClass *>(object());
|
|
|
|
|
QMT_CHECK(diagramClass);
|
|
|
|
|
|
|
|
|
|
QString name;
|
|
|
|
|
if (templateDisplay() == DClass::TemplateName && !diagramClass->templateParameters().isEmpty()) {
|
|
|
|
|
name = object()->name();
|
|
|
|
|
name += QLatin1Char('<');
|
|
|
|
|
bool first = true;
|
|
|
|
|
foreach (const QString &p, diagramClass->templateParameters()) {
|
|
|
|
|
if (!first)
|
|
|
|
|
name += QLatin1Char(',');
|
|
|
|
|
name += p;
|
|
|
|
|
first = false;
|
|
|
|
|
}
|
|
|
|
|
name += QLatin1Char('>');
|
|
|
|
|
} else {
|
|
|
|
|
name = object()->name();
|
|
|
|
|
}
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClassItem::setFromDisplayName(const QString &displayName)
|
|
|
|
|
{
|
|
|
|
|
if (templateDisplay() == DClass::TemplateName) {
|
|
|
|
|
QString name;
|
|
|
|
|
QStringList templateParameters;
|
|
|
|
|
// 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);
|
|
|
|
|
ModelController *modelController = diagramSceneModel()->diagramSceneController()->modelController();
|
|
|
|
|
MClass *mklass = modelController->findObject<MClass>(diagramClass->modelUid());
|
|
|
|
|
if (mklass && (name != mklass->name() || templateParameters != mklass->templateParameters())) {
|
|
|
|
|
modelController->startUpdateObject(mklass);
|
|
|
|
|
mklass->setName(name);
|
|
|
|
|
mklass->setTemplateParameters(templateParameters);
|
|
|
|
|
modelController->finishUpdateObject(mklass, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ObjectItem::setFromDisplayName(displayName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DClass::TemplateDisplay ClassItem::templateDisplay() const
|
|
|
|
|
{
|
|
|
|
|
auto diagramClass = dynamic_cast<DClass *>(object());
|
|
|
|
|
QMT_CHECK(diagramClass);
|
|
|
|
|
|
|
|
|
|
DClass::TemplateDisplay templateDisplay = diagramClass->templateDisplay();
|
|
|
|
|
if (templateDisplay == DClass::TemplateSmart) {
|
|
|
|
|
if (m_customIcon)
|
|
|
|
|
templateDisplay = DClass::TemplateName;
|
|
|
|
|
else
|
|
|
|
|
templateDisplay = DClass::TemplateBox;
|
|
|
|
|
}
|
|
|
|
|
return templateDisplay;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-16 13:11:15 +02:00
|
|
|
QSizeF ClassItem::calcMinimumGeometry() const
|
|
|
|
|
{
|
|
|
|
|
double width = 0.0;
|
|
|
|
|
double height = 0.0;
|
|
|
|
|
|
2015-11-15 19:11:16 +01:00
|
|
|
if (m_customIcon) {
|
|
|
|
|
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(),
|
|
|
|
|
CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
|
|
|
|
|
}
|
2015-08-16 13:11:15 +02:00
|
|
|
|
|
|
|
|
height += BODY_VERT_BORDER;
|
2015-11-12 18:15:33 +01:00
|
|
|
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
2015-11-04 07:52:44 +01:00
|
|
|
width = std::max(width, stereotypeIconItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
|
|
|
|
height += stereotypeIconItem->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-12 18:15:33 +01:00
|
|
|
if (StereotypesItem *stereotypesItem = this->stereotypesItem()) {
|
2015-11-04 07:52:44 +01:00
|
|
|
width = std::max(width, stereotypesItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
|
|
|
|
height += stereotypesItem->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_namespace) {
|
|
|
|
|
width = std::max(width, m_namespace->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
|
|
|
|
height += m_namespace->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-12-26 23:55:59 +01:00
|
|
|
if (nameItem()) {
|
|
|
|
|
width = std::max(width, nameItem()->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
|
|
|
|
height += nameItem()->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_contextLabel)
|
2015-11-04 22:44:41 +01:00
|
|
|
height += m_contextLabel->height();
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_attributesSeparator)
|
2015-08-16 13:11:15 +02:00
|
|
|
height += 8.0;
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_attributes) {
|
|
|
|
|
width = std::max(width, m_attributes->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
|
|
|
|
height += m_attributes->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_methodsSeparator)
|
2015-08-16 13:11:15 +02:00
|
|
|
height += 8.0;
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_methods) {
|
|
|
|
|
width = std::max(width, m_methods->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
|
|
|
|
height += m_methods->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
height += BODY_VERT_BORDER;
|
|
|
|
|
|
|
|
|
|
return GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClassItem::updateGeometry()
|
|
|
|
|
{
|
|
|
|
|
prepareGeometryChange();
|
|
|
|
|
|
|
|
|
|
// calc width and height
|
|
|
|
|
double width = 0.0;
|
|
|
|
|
double height = 0.0;
|
|
|
|
|
|
|
|
|
|
QSizeF geometry = calcMinimumGeometry();
|
|
|
|
|
width = geometry.width();
|
|
|
|
|
height = geometry.height();
|
|
|
|
|
|
2015-11-12 20:25:36 +01:00
|
|
|
if (object()->isAutoSized()) {
|
2015-11-03 22:30:46 +01:00
|
|
|
if (!m_customIcon) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (width < MINIMUM_AUTO_WIDTH)
|
2015-08-16 13:11:15 +02:00
|
|
|
width = MINIMUM_AUTO_WIDTH;
|
2015-11-14 16:59:30 +01:00
|
|
|
if (height < MINIMUM_AUTO_HEIGHT)
|
2015-08-16 13:11:15 +02:00
|
|
|
height = MINIMUM_AUTO_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2015-11-04 22:44:41 +01:00
|
|
|
QRectF rect = object()->rect();
|
2015-11-14 16:59:30 +01:00
|
|
|
if (rect.width() > width)
|
2015-08-16 13:11:15 +02:00
|
|
|
width = rect.width();
|
2015-11-14 16:59:30 +01:00
|
|
|
if (rect.height() > height)
|
2015-08-16 13:11:15 +02:00
|
|
|
height = rect.height();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// update sizes and positions
|
|
|
|
|
double left = -width / 2.0;
|
|
|
|
|
double right = width / 2.0;
|
|
|
|
|
double top = -height / 2.0;
|
|
|
|
|
//double bottom = height / 2.0;
|
|
|
|
|
double y = top;
|
|
|
|
|
|
2015-11-04 22:44:41 +01:00
|
|
|
setPos(object()->pos());
|
2015-08-16 13:11:15 +02:00
|
|
|
|
|
|
|
|
QRectF rect(left, top, width, height);
|
|
|
|
|
|
|
|
|
|
// the object is updated without calling DiagramController intentionally.
|
|
|
|
|
// attribute rect is not a real attribute stored on DObject but
|
|
|
|
|
// a backup for the graphics item used for manual resized and persistency.
|
2015-11-04 22:44:41 +01:00
|
|
|
object()->setRect(rect);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_customIcon) {
|
|
|
|
|
m_customIcon->setPos(left, top);
|
|
|
|
|
m_customIcon->setActualSize(QSizeF(width, height));
|
2015-08-16 13:11:15 +02:00
|
|
|
y += height;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_shape)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_shape->setRect(rect);
|
2015-08-16 13:11:15 +02:00
|
|
|
|
|
|
|
|
y += BODY_VERT_BORDER;
|
2015-11-12 18:15:33 +01:00
|
|
|
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
2015-11-04 07:52:44 +01:00
|
|
|
stereotypeIconItem->setPos(right - stereotypeIconItem->boundingRect().width() - BODY_HORIZ_BORDER, y);
|
|
|
|
|
y += stereotypeIconItem->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-12 18:15:33 +01:00
|
|
|
if (StereotypesItem *stereotypesItem = this->stereotypesItem()) {
|
2015-11-04 07:52:44 +01:00
|
|
|
stereotypesItem->setPos(-stereotypesItem->boundingRect().width() / 2.0, y);
|
|
|
|
|
y += stereotypesItem->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_namespace) {
|
|
|
|
|
m_namespace->setPos(-m_namespace->boundingRect().width() / 2.0, y);
|
|
|
|
|
y += m_namespace->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-12-26 23:55:59 +01:00
|
|
|
if (nameItem()) {
|
|
|
|
|
nameItem()->setPos(-nameItem()->boundingRect().width() / 2.0, y);
|
|
|
|
|
y += nameItem()->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_contextLabel) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_customIcon)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_contextLabel->resetMaxWidth();
|
2015-11-14 16:59:30 +01:00
|
|
|
else
|
2015-11-03 22:30:46 +01:00
|
|
|
m_contextLabel->setMaxWidth(width - 2 * BODY_HORIZ_BORDER);
|
|
|
|
|
m_contextLabel->setPos(-m_contextLabel->boundingRect().width() / 2.0, y);
|
|
|
|
|
y += m_contextLabel->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_attributesSeparator) {
|
|
|
|
|
m_attributesSeparator->setLine(left, 4.0, right, 4.0);
|
|
|
|
|
m_attributesSeparator->setPos(0, y);
|
2015-08-16 13:11:15 +02:00
|
|
|
y += 8.0;
|
|
|
|
|
}
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_attributes) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_customIcon)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_attributes->setPos(-m_attributes->boundingRect().width() / 2.0, y);
|
2015-11-14 16:59:30 +01:00
|
|
|
else
|
2015-11-03 22:30:46 +01:00
|
|
|
m_attributes->setPos(left + BODY_HORIZ_BORDER, y);
|
|
|
|
|
y += m_attributes->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_methodsSeparator) {
|
|
|
|
|
m_methodsSeparator->setLine(left, 4.0, right, 4.0);
|
|
|
|
|
m_methodsSeparator->setPos(0, y);
|
2015-08-16 13:11:15 +02:00
|
|
|
y += 8.0;
|
|
|
|
|
}
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_methods) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_customIcon)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_methods->setPos(-m_methods->boundingRect().width() / 2.0, y);
|
2015-11-14 16:59:30 +01:00
|
|
|
else
|
2015-11-03 22:30:46 +01:00
|
|
|
m_methods->setPos(left + BODY_HORIZ_BORDER, y);
|
|
|
|
|
y += m_methods->boundingRect().height();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-03 22:30:46 +01:00
|
|
|
if (m_templateParameterBox) {
|
|
|
|
|
m_templateParameterBox->setBreakLines(false);
|
|
|
|
|
double x = right - m_templateParameterBox->boundingRect().width() * 0.8;
|
2015-08-16 13:11:15 +02:00
|
|
|
if (x < 0) {
|
2015-11-03 22:30:46 +01:00
|
|
|
m_templateParameterBox->setBreakLines(true);
|
|
|
|
|
x = right - m_templateParameterBox->boundingRect().width() * 0.8;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-14 16:59:30 +01:00
|
|
|
if (x < 0)
|
2015-08-16 13:11:15 +02:00
|
|
|
x = 0;
|
2015-11-03 22:30:46 +01:00
|
|
|
m_templateParameterBox->setPos(x, top - m_templateParameterBox->boundingRect().height() + BODY_VERT_BORDER);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateSelectionMarkerGeometry(rect);
|
|
|
|
|
|
2015-11-14 16:59:30 +01:00
|
|
|
if (m_relationStarter)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
2015-08-16 13:11:15 +02:00
|
|
|
|
|
|
|
|
updateAlignmentButtonsGeometry(rect);
|
|
|
|
|
updateDepth();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClassItem::updateMembers(const Style *style)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(style)
|
|
|
|
|
|
2015-11-03 22:30:46 +01:00
|
|
|
m_attributesText.clear();
|
|
|
|
|
m_methodsText.clear();
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 23:34:44 +01:00
|
|
|
MClassMember::Visibility attributesVisibility = MClassMember::VisibilityUndefined;
|
|
|
|
|
MClassMember::Visibility methodsVisibility = MClassMember::VisibilityUndefined;
|
2015-11-04 07:52:44 +01:00
|
|
|
QString attributesGroup;
|
|
|
|
|
QString methodsGroup;
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
MClassMember::Visibility *currentVisibility = 0;
|
|
|
|
|
QString *currentGroup = 0;
|
2015-08-16 13:11:15 +02:00
|
|
|
QString *text = 0;
|
|
|
|
|
|
2015-11-21 20:54:19 +01:00
|
|
|
auto dclass = dynamic_cast<DClass *>(object());
|
2015-08-16 13:11:15 +02:00
|
|
|
QMT_CHECK(dclass);
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
// TODO move bool haveIconFonts into class Style?
|
2015-11-04 22:44:41 +01:00
|
|
|
bool haveIconFonts = false; // style->normalFont().family() == QStringLiteral("Modelling");
|
2015-08-16 13:11:15 +02:00
|
|
|
// TODO any reason to show visibility as group instead of per member?
|
2015-11-04 07:52:44 +01:00
|
|
|
bool useGroupVisibility = false;
|
2015-08-16 13:11:15 +02:00
|
|
|
|
2015-11-04 22:44:41 +01:00
|
|
|
foreach (const MClassMember &member, dclass->members()) {
|
|
|
|
|
switch (member.memberType()) {
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::MemberUndefined:
|
2015-08-16 13:11:15 +02:00
|
|
|
QMT_CHECK(false);
|
|
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::MemberAttribute:
|
2015-11-04 07:52:44 +01:00
|
|
|
currentVisibility = &attributesVisibility;
|
|
|
|
|
currentGroup = &attributesGroup;
|
2015-11-03 22:30:46 +01:00
|
|
|
text = &m_attributesText;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::MemberMethod:
|
2015-11-04 07:52:44 +01:00
|
|
|
currentVisibility = &methodsVisibility;
|
|
|
|
|
currentGroup = &methodsGroup;
|
2015-11-03 22:30:46 +01:00
|
|
|
text = &m_methodsText;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!text->isEmpty())
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral("<br/>");
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
bool addNewline = false;
|
|
|
|
|
bool addSpace = false;
|
2015-11-04 22:44:41 +01:00
|
|
|
if (member.visibility() != *currentVisibility) {
|
2015-11-04 07:52:44 +01:00
|
|
|
if (useGroupVisibility) {
|
2015-11-04 23:34:44 +01:00
|
|
|
if (member.visibility() != MClassMember::VisibilityUndefined) {
|
2015-08-16 13:11:15 +02:00
|
|
|
QString vis;
|
2015-11-04 22:44:41 +01:00
|
|
|
switch (member.visibility()) {
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityUndefined:
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityPublic:
|
2015-08-16 13:11:15 +02:00
|
|
|
vis = QStringLiteral("public:");
|
|
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityProtected:
|
2015-08-16 13:11:15 +02:00
|
|
|
vis = QStringLiteral("protected:");
|
|
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityPrivate:
|
2015-08-16 13:11:15 +02:00
|
|
|
vis = QStringLiteral("private:");
|
|
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilitySignals:
|
2015-08-16 13:11:15 +02:00
|
|
|
vis = QStringLiteral("signals:");
|
|
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityPrivateSlots:
|
2015-08-16 13:11:15 +02:00
|
|
|
vis = QStringLiteral("private slots:");
|
|
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityProtectedSlots:
|
2015-08-16 13:11:15 +02:00
|
|
|
vis = QStringLiteral("protected slots:");
|
|
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityPublicSlots:
|
2015-08-16 13:11:15 +02:00
|
|
|
vis = QStringLiteral("public slots:");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
*text += vis;
|
2015-11-04 07:52:44 +01:00
|
|
|
addNewline = true;
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
2015-11-04 22:44:41 +01:00
|
|
|
*currentVisibility = member.visibility();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-04 22:44:41 +01:00
|
|
|
if (member.group() != currentGroup) {
|
2015-11-14 16:59:30 +01:00
|
|
|
if (addSpace)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral(" ");
|
2015-11-04 22:44:41 +01:00
|
|
|
*text += QString(QStringLiteral("[%1]")).arg(member.group());
|
2015-11-04 07:52:44 +01:00
|
|
|
addNewline = true;
|
2015-11-04 22:44:41 +01:00
|
|
|
*currentGroup = member.group();
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-14 16:59:30 +01:00
|
|
|
if (addNewline)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral("<br/>");
|
|
|
|
|
|
2015-11-04 07:52:44 +01:00
|
|
|
addSpace = false;
|
|
|
|
|
bool haveSignal = false;
|
|
|
|
|
bool haveSlot = false;
|
|
|
|
|
if (!useGroupVisibility) {
|
2015-11-04 23:34:44 +01:00
|
|
|
if (member.visibility() != MClassMember::VisibilityUndefined) {
|
2015-08-16 13:11:15 +02:00
|
|
|
QString vis;
|
2015-11-04 22:44:41 +01:00
|
|
|
switch (member.visibility()) {
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityUndefined:
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityPublic:
|
2015-11-04 07:52:44 +01:00
|
|
|
vis = haveIconFonts ? QString(QChar(0xe990)) : QStringLiteral("+");
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityProtected:
|
2015-11-04 07:52:44 +01:00
|
|
|
vis = haveIconFonts ? QString(QChar(0xe98e)) : QStringLiteral("#");
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityPrivate:
|
2015-11-04 07:52:44 +01:00
|
|
|
vis = haveIconFonts ? QString(QChar(0xe98f)) : QStringLiteral("-");
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilitySignals:
|
2015-12-17 09:43:10 +01:00
|
|
|
vis = haveIconFonts ? QString(QChar(0xe994)) : QStringLiteral(">");
|
2015-11-04 07:52:44 +01:00
|
|
|
haveSignal = true;
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityPrivateSlots:
|
2015-11-04 07:52:44 +01:00
|
|
|
vis = haveIconFonts ? QString(QChar(0xe98f)) + QChar(0xe9cb)
|
2015-12-17 09:43:10 +01:00
|
|
|
: QStringLiteral("-$");
|
2015-11-04 07:52:44 +01:00
|
|
|
haveSlot = true;
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityProtectedSlots:
|
2015-11-04 07:52:44 +01:00
|
|
|
vis = haveIconFonts ? QString(QChar(0xe98e)) + QChar(0xe9cb)
|
2015-12-17 09:43:10 +01:00
|
|
|
: QStringLiteral("#$");
|
2015-11-04 07:52:44 +01:00
|
|
|
haveSlot = true;
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
2015-11-04 23:34:44 +01:00
|
|
|
case MClassMember::VisibilityPublicSlots:
|
2015-11-04 07:52:44 +01:00
|
|
|
vis = haveIconFonts ? QString(QChar(0xe990)) + QChar(0xe9cb)
|
2015-12-17 09:43:10 +01:00
|
|
|
: QStringLiteral("+$");
|
2015-11-04 07:52:44 +01:00
|
|
|
haveSlot = true;
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
*text += vis;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-04 23:34:44 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyQsignal && !haveSignal) {
|
2015-12-17 09:43:10 +01:00
|
|
|
*text += haveIconFonts ? QString(QChar(0xe994)) : QStringLiteral(">");
|
2015-11-04 07:52:44 +01:00
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-04 23:34:44 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyQslot && !haveSlot) {
|
2015-11-04 07:52:44 +01:00
|
|
|
*text += haveIconFonts ? QString(QChar(0xe9cb)) : QStringLiteral("$");
|
|
|
|
|
addSpace = true;
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
2015-11-14 16:59:30 +01:00
|
|
|
if (addSpace)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral(" ");
|
2015-11-14 16:59:30 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyQinvokable)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral("invokable ");
|
2015-11-04 22:44:41 +01:00
|
|
|
if (!member.stereotypes().isEmpty()) {
|
|
|
|
|
*text += StereotypesItem::format(member.stereotypes());
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral(" ");
|
|
|
|
|
}
|
2015-12-22 19:58:39 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyStatic)
|
|
|
|
|
*text += QStringLiteral("static ");
|
2015-11-14 16:59:30 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyVirtual)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral("virtual ");
|
2015-12-17 09:43:10 +01:00
|
|
|
*text += member.declaration().toHtmlEscaped();
|
2015-11-14 16:59:30 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyConst)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral(" const");
|
2015-11-14 16:59:30 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyOverride)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral(" override");
|
2015-11-14 16:59:30 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyFinal)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral(" final");
|
2015-11-14 16:59:30 +01:00
|
|
|
if (member.properties() & MClassMember::PropertyAbstract)
|
2015-08-16 13:11:15 +02:00
|
|
|
*text += QStringLiteral(" = 0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-14 16:59:30 +01:00
|
|
|
} // namespace qmt
|