forked from qt-creator/qt-creator
ModelEditor: Apply some source code formatting rules
1. Reduce 2 or more empty lines to a single empty line 2. Remove duplicate access specifiers 3. Remove lots of single empty lines between member declarations 4. Remove braces around single lines 5. List base classes on same line as class declaration 6. Ensure opening brace of class declaration is on next line 7. Add comment to end of namespace block Change-Id: I95e2efa3abea806683e0943d54d6f203ad4af0e4 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -42,7 +42,6 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class ConfigController::ConfigControllerPrivate
|
class ConfigController::ConfigControllerPrivate
|
||||||
|
|||||||
@@ -40,35 +40,24 @@ class StereotypeController;
|
|||||||
class StereotypeIcon;
|
class StereotypeIcon;
|
||||||
class Toolbar;
|
class Toolbar;
|
||||||
|
|
||||||
|
|
||||||
class QMT_EXPORT ConfigController : public QObject
|
class QMT_EXPORT ConfigController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
class ConfigControllerPrivate;
|
class ConfigControllerPrivate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit ConfigController(QObject *parent = 0);
|
explicit ConfigController(QObject *parent = 0);
|
||||||
|
|
||||||
~ConfigController();
|
~ConfigController();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void setStereotypeController(StereotypeController *stereotypeController);
|
void setStereotypeController(StereotypeController *stereotypeController);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void readStereotypeDefinitions(const QString &path);
|
void readStereotypeDefinitions(const QString &path);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onStereotypeIconParsed(const StereotypeIcon &stereotypeIcon);
|
void onStereotypeIconParsed(const StereotypeIcon &stereotypeIcon);
|
||||||
|
|
||||||
void onToolbarParsed(const Toolbar &toolbar);
|
void onToolbarParsed(const Toolbar &toolbar);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ConfigControllerPrivate *d;
|
ConfigControllerPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -38,21 +38,13 @@ namespace qmt {
|
|||||||
class QMT_EXPORT SourcePos
|
class QMT_EXPORT SourcePos
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SourcePos();
|
SourcePos();
|
||||||
|
|
||||||
SourcePos(int sourceId, int lineNumber, int columnNumber = -1);
|
SourcePos(int sourceId, int lineNumber, int columnNumber = -1);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isValid() const { return m_sourceId >= 0 && m_lineNumber >= 0; }
|
bool isValid() const { return m_sourceId >= 0 && m_lineNumber >= 0; }
|
||||||
|
|
||||||
int sourceId() const { return m_sourceId; }
|
int sourceId() const { return m_sourceId; }
|
||||||
|
|
||||||
int lineNumber() const { return m_lineNumber; }
|
int lineNumber() const { return m_lineNumber; }
|
||||||
|
|
||||||
bool hasColumnNumber() const { return m_columnNumber >= 0; }
|
bool hasColumnNumber() const { return m_columnNumber >= 0; }
|
||||||
|
|
||||||
int columnNumber() const { return m_columnNumber; }
|
int columnNumber() const { return m_columnNumber; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -87,26 +87,22 @@ static const int OPERATOR_COMMA = 3;
|
|||||||
static const int OPERATOR_PERIOD = 4;
|
static const int OPERATOR_PERIOD = 4;
|
||||||
static const int OPERATOR_MINUS = 5;
|
static const int OPERATOR_MINUS = 5;
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
QHash<T, U> operator<<(QHash<T, U> hash, QPair<T, U> pair) {
|
QHash<T, U> operator<<(QHash<T, U> hash, QPair<T, U> pair) {
|
||||||
hash.insert(pair.first, pair.second);
|
hash.insert(pair.first, pair.second);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StereotypeDefinitionParserError::StereotypeDefinitionParserError(const QString &errorMsg, const SourcePos &sourcePos)
|
StereotypeDefinitionParserError::StereotypeDefinitionParserError(const QString &errorMsg, const SourcePos &sourcePos)
|
||||||
: Exception(errorMsg),
|
: Exception(errorMsg),
|
||||||
m_sourcePos(sourcePos)
|
m_sourcePos(sourcePos)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StereotypeDefinitionParserError::~StereotypeDefinitionParserError()
|
StereotypeDefinitionParserError::~StereotypeDefinitionParserError()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class StereotypeDefinitionParser::StereotypeDefinitionParserPrivate
|
class StereotypeDefinitionParser::StereotypeDefinitionParserPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -119,7 +115,6 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class StereotypeDefinitionParser::IconCommandParameter
|
class StereotypeDefinitionParser::IconCommandParameter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -133,7 +128,6 @@ public:
|
|||||||
ShapeValueF::Origin m_origin;
|
ShapeValueF::Origin m_origin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
StereotypeDefinitionParser::StereotypeDefinitionParser(QObject *parent) :
|
StereotypeDefinitionParser::StereotypeDefinitionParser(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
d(new StereotypeDefinitionParserPrivate)
|
d(new StereotypeDefinitionParserPrivate)
|
||||||
@@ -204,43 +198,38 @@ void StereotypeDefinitionParser::parseFile()
|
|||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Token token = readNextToken();
|
Token token = readNextToken();
|
||||||
if (token.type() == Token::TokenEndOfInput) {
|
if (token.type() == Token::TokenEndOfInput)
|
||||||
break;
|
break;
|
||||||
} else if (token.type() != Token::TokenKeyword || token.subtype() == KEYWORD_ICON) {
|
else if (token.type() != Token::TokenKeyword || token.subtype() == KEYWORD_ICON)
|
||||||
parseIcon();
|
parseIcon();
|
||||||
} else if (token.type() != Token::TokenKeyword || token.subtype() == KEYWORD_TOOLBAR) {
|
else if (token.type() != Token::TokenKeyword || token.subtype() == KEYWORD_TOOLBAR)
|
||||||
parseToolbar();
|
parseToolbar();
|
||||||
} else {
|
else
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected 'icon' or 'toolbar'."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected 'icon' or 'toolbar'."), token.sourcePos());
|
||||||
}
|
|
||||||
token = d->m_scanner->read();
|
token = d->m_scanner->read();
|
||||||
if (token.type() == Token::TokenOperator && token.subtype() == OPERATOR_PERIOD) {
|
if (token.type() == Token::TokenOperator && token.subtype() == OPERATOR_PERIOD)
|
||||||
break;
|
break;
|
||||||
} else if (token.type() != Token::TokenOperator || token.subtype() != OPERATOR_SEMICOLON) {
|
else if (token.type() != Token::TokenOperator || token.subtype() != OPERATOR_SEMICOLON)
|
||||||
d->m_scanner->unread(token);
|
d->m_scanner->unread(token);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDefinitionParser::parseIcon()
|
void StereotypeDefinitionParser::parseIcon()
|
||||||
{
|
{
|
||||||
Token token = d->m_scanner->read();
|
Token token = d->m_scanner->read();
|
||||||
if (token.type() != Token::TokenIdentifier && token.type() != Token::TokenKeyword) {
|
if (token.type() != Token::TokenIdentifier && token.type() != Token::TokenKeyword)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected identifier."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected identifier."), token.sourcePos());
|
||||||
}
|
|
||||||
QString id = token.text();
|
QString id = token.text();
|
||||||
StereotypeIcon stereotypeIcon;
|
StereotypeIcon stereotypeIcon;
|
||||||
stereotypeIcon.setId(id);
|
stereotypeIcon.setId(id);
|
||||||
parseIconProperties(&stereotypeIcon);
|
parseIconProperties(&stereotypeIcon);
|
||||||
token = readNextToken();
|
token = readNextToken();
|
||||||
if (token.type() != Token::TokenKeyword || token.subtype() != KEYWORD_BEGIN) {
|
if (token.type() != Token::TokenKeyword || token.subtype() != KEYWORD_BEGIN)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'begin'."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'begin'."), token.sourcePos());
|
||||||
}
|
|
||||||
parseIconCommands(&stereotypeIcon);
|
parseIconCommands(&stereotypeIcon);
|
||||||
token = readNextToken();
|
token = readNextToken();
|
||||||
if (token.type() != Token::TokenKeyword || token.subtype() != KEYWORD_END) {
|
if (token.type() != Token::TokenKeyword || token.subtype() != KEYWORD_END)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'end'."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'end'."), token.sourcePos());
|
||||||
}
|
|
||||||
emit iconParsed(stereotypeIcon);
|
emit iconParsed(stereotypeIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,9 +260,8 @@ void StereotypeDefinitionParser::parseIconProperties(StereotypeIcon *stereotypeI
|
|||||||
<< qMakePair(QString(QStringLiteral("diagram")), StereotypeIcon::ElementDiagram)
|
<< qMakePair(QString(QStringLiteral("diagram")), StereotypeIcon::ElementDiagram)
|
||||||
<< qMakePair(QString(QStringLiteral("item")), StereotypeIcon::ElementItem);
|
<< qMakePair(QString(QStringLiteral("item")), StereotypeIcon::ElementItem);
|
||||||
QString elementName = identifier.toLower();
|
QString elementName = identifier.toLower();
|
||||||
if (!elementNames.contains(elementName)) {
|
if (!elementNames.contains(elementName))
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for element.")).arg(identifier), token.sourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for element.")).arg(identifier), token.sourcePos());
|
||||||
}
|
|
||||||
elements.insert(elementNames.value(elementName));
|
elements.insert(elementNames.value(elementName));
|
||||||
}
|
}
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
@@ -369,22 +357,19 @@ void StereotypeDefinitionParser::parseIconProperties(StereotypeIcon *stereotypeI
|
|||||||
void StereotypeDefinitionParser::parseToolbar()
|
void StereotypeDefinitionParser::parseToolbar()
|
||||||
{
|
{
|
||||||
Token token = d->m_scanner->read();
|
Token token = d->m_scanner->read();
|
||||||
if (token.type() != Token::TokenIdentifier && token.type() != Token::TokenKeyword) {
|
if (token.type() != Token::TokenIdentifier && token.type() != Token::TokenKeyword)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected identifier."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected identifier."), token.sourcePos());
|
||||||
}
|
|
||||||
QString id = token.text();
|
QString id = token.text();
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
toolbar.setId(id);
|
toolbar.setId(id);
|
||||||
parseToolbarProperties(&toolbar);
|
parseToolbarProperties(&toolbar);
|
||||||
token = readNextToken();
|
token = readNextToken();
|
||||||
if (token.type() != Token::TokenKeyword || token.subtype() != KEYWORD_BEGIN) {
|
if (token.type() != Token::TokenKeyword || token.subtype() != KEYWORD_BEGIN)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'begin'."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'begin'."), token.sourcePos());
|
||||||
}
|
|
||||||
parseToolbarCommands(&toolbar);
|
parseToolbarCommands(&toolbar);
|
||||||
token = readNextToken();
|
token = readNextToken();
|
||||||
if (token.type() != Token::TokenKeyword || token.subtype() != KEYWORD_END) {
|
if (token.type() != Token::TokenKeyword || token.subtype() != KEYWORD_END)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'end'."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected token 'end'."), token.sourcePos());
|
||||||
}
|
|
||||||
emit toolbarParsed(toolbar);
|
emit toolbarParsed(toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,22 +549,20 @@ QList<ShapeValueF> StereotypeDefinitionParser::parseIconCommandParameters(const
|
|||||||
QList<ShapeValueF> values;
|
QList<ShapeValueF> values;
|
||||||
Token token;
|
Token token;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (values.count() <= parameters.count()) {
|
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 {
|
else
|
||||||
values << ShapeValueF(parseFloatExpression());
|
values << ShapeValueF(parseFloatExpression());
|
||||||
}
|
|
||||||
token = d->m_scanner->read();
|
token = d->m_scanner->read();
|
||||||
if (token.type() != Token::TokenOperator || token.subtype() != OPERATOR_COMMA) {
|
if (token.type() != Token::TokenOperator || token.subtype() != OPERATOR_COMMA) {
|
||||||
d->m_scanner->unread(token);
|
d->m_scanner->unread(token);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (values.count() < parameters.count()) {
|
if (values.count() < parameters.count())
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("More parameters expected."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("More parameters expected."), token.sourcePos());
|
||||||
} else if (values.count() > parameters.count()) {
|
else if (values.count() > parameters.count())
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Too many parameters given."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Too many parameters given."), token.sourcePos());
|
||||||
}
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,13 +590,11 @@ void StereotypeDefinitionParser::parseToolbarCommands(Toolbar *toolbar)
|
|||||||
<< QStringLiteral("annotation")
|
<< QStringLiteral("annotation")
|
||||||
<< QStringLiteral("boundary");
|
<< QStringLiteral("boundary");
|
||||||
QString elementName = element.toLower();
|
QString elementName = element.toLower();
|
||||||
if (!elementNames.contains(elementName)) {
|
if (!elementNames.contains(elementName))
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for element.")).arg(element), token.sourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Unexpected value \"%1\" for element.")).arg(element), token.sourcePos());
|
||||||
}
|
|
||||||
QString stereotype;
|
QString stereotype;
|
||||||
if (nextIsComma()) {
|
if (nextIsComma())
|
||||||
stereotype = parseStringExpression();
|
stereotype = parseStringExpression();
|
||||||
}
|
|
||||||
tools.append(Toolbar::Tool(toolName, element, stereotype));
|
tools.append(Toolbar::Tool(toolName, element, stereotype));
|
||||||
expectSemicolonOrEndOfLine();
|
expectSemicolonOrEndOfLine();
|
||||||
break;
|
break;
|
||||||
@@ -635,9 +616,8 @@ void StereotypeDefinitionParser::parseToolbarCommands(Toolbar *toolbar)
|
|||||||
QString StereotypeDefinitionParser::parseStringExpression()
|
QString StereotypeDefinitionParser::parseStringExpression()
|
||||||
{
|
{
|
||||||
Token token = d->m_scanner->read();
|
Token token = d->m_scanner->read();
|
||||||
if (token.type() != Token::TokenString) {
|
if (token.type() != Token::TokenString)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected string constant."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected string constant."), token.sourcePos());
|
||||||
}
|
|
||||||
return token.text();
|
return token.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,9 +664,8 @@ int StereotypeDefinitionParser::parseIntExpression()
|
|||||||
QString StereotypeDefinitionParser::parseIdentifierExpression()
|
QString StereotypeDefinitionParser::parseIdentifierExpression()
|
||||||
{
|
{
|
||||||
Token token = d->m_scanner->read();
|
Token token = d->m_scanner->read();
|
||||||
if (token.type() != Token::TokenIdentifier && token.type() != Token::TokenKeyword) {
|
if (token.type() != Token::TokenIdentifier && token.type() != Token::TokenKeyword)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected identifier."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected identifier."), token.sourcePos());
|
||||||
}
|
|
||||||
return token.text();
|
return token.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,11 +674,10 @@ bool StereotypeDefinitionParser::parseBoolExpression()
|
|||||||
Token token = d->m_scanner->read();
|
Token token = d->m_scanner->read();
|
||||||
if (token.type() == Token::TokenIdentifier) {
|
if (token.type() == Token::TokenIdentifier) {
|
||||||
QString value = token.text().toLower();
|
QString value = token.text().toLower();
|
||||||
if (value == QStringLiteral("yes") || value == QStringLiteral("true")) {
|
if (value == QStringLiteral("yes") || value == QStringLiteral("true"))
|
||||||
return true;
|
return true;
|
||||||
} else if (value == QStringLiteral("no") || value == QStringLiteral("false")) {
|
else if (value == QStringLiteral("no") || value == QStringLiteral("false"))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected 'yes', 'no', 'true' or 'false'."), token.sourcePos());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected 'yes', 'no', 'true' or 'false'."), token.sourcePos());
|
||||||
}
|
}
|
||||||
@@ -723,26 +701,23 @@ Token StereotypeDefinitionParser::readNextToken()
|
|||||||
Token token;
|
Token token;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
token = d->m_scanner->read();
|
token = d->m_scanner->read();
|
||||||
if (token.type() != Token::TokenEndOfLine) {
|
if (token.type() != Token::TokenEndOfLine)
|
||||||
return token;
|
return token;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal StereotypeDefinitionParser::expectAbsoluteValue(const ShapeValueF &value, const SourcePos &sourcePos)
|
qreal StereotypeDefinitionParser::expectAbsoluteValue(const ShapeValueF &value, const SourcePos &sourcePos)
|
||||||
{
|
{
|
||||||
if (value.unit() != ShapeValueF::UnitAbsolute || value.origin() != ShapeValueF::OriginSmart) {
|
if (value.unit() != ShapeValueF::UnitAbsolute || value.origin() != ShapeValueF::OriginSmart)
|
||||||
throw StereotypeDefinitionParserError(QStringLiteral("Expected absolute value"), sourcePos);
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected absolute value"), sourcePos);
|
||||||
}
|
|
||||||
return value.value();
|
return value.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDefinitionParser::expectSemicolonOrEndOfLine()
|
void StereotypeDefinitionParser::expectSemicolonOrEndOfLine()
|
||||||
{
|
{
|
||||||
Token token = d->m_scanner->read();
|
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());
|
throw StereotypeDefinitionParserError(QStringLiteral("Expected ';' or end-of-line."), token.sourcePos());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StereotypeDefinitionParser::nextIsComma()
|
bool StereotypeDefinitionParser::nextIsComma()
|
||||||
@@ -758,9 +733,8 @@ bool StereotypeDefinitionParser::nextIsComma()
|
|||||||
void StereotypeDefinitionParser::expectOperator(int op, const QString &opName)
|
void StereotypeDefinitionParser::expectOperator(int op, const QString &opName)
|
||||||
{
|
{
|
||||||
Token token = d->m_scanner->read();
|
Token token = d->m_scanner->read();
|
||||||
if (token.type() != Token::TokenOperator || token.subtype() != op) {
|
if (token.type() != Token::TokenOperator || token.subtype() != op)
|
||||||
throw StereotypeDefinitionParserError(QString(QStringLiteral("Expected '%1'.")).arg(opName), token.sourcePos());
|
throw StereotypeDefinitionParserError(QString(QStringLiteral("Expected '%1'.")).arg(opName), token.sourcePos());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereotypeDefinitionParser::expectComma()
|
void StereotypeDefinitionParser::expectComma()
|
||||||
@@ -773,4 +747,4 @@ void StereotypeDefinitionParser::expectColon()
|
|||||||
expectOperator(OPERATOR_COLON, QStringLiteral(":"));
|
expectOperator(OPERATOR_COLON, QStringLiteral(":"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
#include "sourcepos.h"
|
#include "sourcepos.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class ITextSource;
|
class ITextSource;
|
||||||
@@ -45,111 +44,74 @@ class StereotypeIcon;
|
|||||||
class Toolbar;
|
class Toolbar;
|
||||||
class ShapeValueF;
|
class ShapeValueF;
|
||||||
|
|
||||||
class QMT_EXPORT StereotypeDefinitionParserError :
|
class QMT_EXPORT StereotypeDefinitionParserError : public Exception
|
||||||
public Exception
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
StereotypeDefinitionParserError(const QString &errorMsg, const SourcePos &sourcePos);
|
StereotypeDefinitionParserError(const QString &errorMsg, const SourcePos &sourcePos);
|
||||||
|
|
||||||
~StereotypeDefinitionParserError();
|
~StereotypeDefinitionParserError();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
SourcePos sourcePos() const { return m_sourcePos; }
|
SourcePos sourcePos() const { return m_sourcePos; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SourcePos m_sourcePos;
|
SourcePos m_sourcePos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class QMT_EXPORT StereotypeDefinitionParser : public QObject
|
class QMT_EXPORT StereotypeDefinitionParser : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
class StereotypeDefinitionParserPrivate;
|
class StereotypeDefinitionParserPrivate;
|
||||||
|
|
||||||
class IconCommandParameter;
|
class IconCommandParameter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit StereotypeDefinitionParser(QObject *parent = 0);
|
explicit StereotypeDefinitionParser(QObject *parent = 0);
|
||||||
|
|
||||||
~StereotypeDefinitionParser();
|
~StereotypeDefinitionParser();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void iconParsed(const StereotypeIcon &stereotypeIcon);
|
void iconParsed(const StereotypeIcon &stereotypeIcon);
|
||||||
|
|
||||||
void toolbarParsed(const Toolbar &toolbar);
|
void toolbarParsed(const Toolbar &toolbar);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void parse(ITextSource *source);
|
void parse(ITextSource *source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void parseFile();
|
void parseFile();
|
||||||
|
|
||||||
void parseIcon();
|
void parseIcon();
|
||||||
|
|
||||||
void parseIconProperties(StereotypeIcon *stereotypeIcon);
|
void parseIconProperties(StereotypeIcon *stereotypeIcon);
|
||||||
|
|
||||||
void parseToolbar();
|
void parseToolbar();
|
||||||
|
|
||||||
void parseToolbarProperties(Toolbar *toolbar);
|
void parseToolbarProperties(Toolbar *toolbar);
|
||||||
|
|
||||||
QString parseStringProperty();
|
QString parseStringProperty();
|
||||||
|
|
||||||
int parseIntProperty();
|
int parseIntProperty();
|
||||||
|
|
||||||
qreal parseFloatProperty();
|
qreal parseFloatProperty();
|
||||||
|
|
||||||
QString parseIdentifierProperty();
|
QString parseIdentifierProperty();
|
||||||
|
|
||||||
QList<QString> parseIdentifierListProperty();
|
QList<QString> parseIdentifierListProperty();
|
||||||
|
|
||||||
bool parseBoolProperty();
|
bool parseBoolProperty();
|
||||||
|
|
||||||
QColor parseColorProperty();
|
QColor parseColorProperty();
|
||||||
|
|
||||||
void parseIconCommands(StereotypeIcon *stereotypeIcon);
|
void parseIconCommands(StereotypeIcon *stereotypeIcon);
|
||||||
|
|
||||||
QList<ShapeValueF> parseIconCommandParameters(const QList<IconCommandParameter> ¶meters);
|
QList<ShapeValueF> parseIconCommandParameters(const QList<IconCommandParameter> ¶meters);
|
||||||
|
|
||||||
void parseToolbarCommands(Toolbar *toolbar);
|
void parseToolbarCommands(Toolbar *toolbar);
|
||||||
|
|
||||||
QString parseStringExpression();
|
QString parseStringExpression();
|
||||||
|
|
||||||
qreal parseFloatExpression();
|
qreal parseFloatExpression();
|
||||||
|
|
||||||
int parseIntExpression();
|
int parseIntExpression();
|
||||||
|
|
||||||
QString parseIdentifierExpression();
|
QString parseIdentifierExpression();
|
||||||
|
|
||||||
bool parseBoolExpression();
|
bool parseBoolExpression();
|
||||||
|
|
||||||
QColor parseColorExpression();
|
QColor parseColorExpression();
|
||||||
|
|
||||||
Token readNextToken();
|
Token readNextToken();
|
||||||
|
|
||||||
qreal expectAbsoluteValue(const ShapeValueF &value, const SourcePos &sourcePos);
|
qreal expectAbsoluteValue(const ShapeValueF &value, const SourcePos &sourcePos);
|
||||||
|
|
||||||
void expectSemicolonOrEndOfLine();
|
void expectSemicolonOrEndOfLine();
|
||||||
|
|
||||||
bool nextIsComma();
|
bool nextIsComma();
|
||||||
|
|
||||||
void expectOperator(int op, const QString &opName);
|
void expectOperator(int op, const QString &opName);
|
||||||
|
|
||||||
void expectComma();
|
void expectComma();
|
||||||
|
|
||||||
void expectColon();
|
void expectColon();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
StereotypeDefinitionParserPrivate *d;
|
StereotypeDefinitionParserPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_STEREOTYPEDEFINITIONPARSER_H
|
#endif // QMT_STEREOTYPEDEFINITIONPARSER_H
|
||||||
|
|||||||
@@ -67,9 +67,8 @@ SourceChar StringTextSource::readNextChar()
|
|||||||
QMT_CHECK(m_lineNumber >= 0);
|
QMT_CHECK(m_lineNumber >= 0);
|
||||||
QMT_CHECK(m_columnNumber >= 0);
|
QMT_CHECK(m_columnNumber >= 0);
|
||||||
|
|
||||||
if (m_index >= m_text.length()) {
|
if (m_index >= m_text.length())
|
||||||
return SourceChar(QChar(), SourcePos(m_sourceId, m_lineNumber, m_columnNumber));
|
return SourceChar(QChar(), SourcePos(m_sourceId, m_lineNumber, m_columnNumber));
|
||||||
}
|
|
||||||
|
|
||||||
SourcePos pos(m_sourceId, m_lineNumber, m_columnNumber);
|
SourcePos pos(m_sourceId, m_lineNumber, m_columnNumber);
|
||||||
QChar ch(m_text.at(m_index));
|
QChar ch(m_text.at(m_index));
|
||||||
|
|||||||
@@ -37,37 +37,25 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT StringTextSource :
|
class QMT_EXPORT StringTextSource : public ITextSource
|
||||||
public ITextSource
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
StringTextSource();
|
StringTextSource();
|
||||||
~StringTextSource();
|
~StringTextSource();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
|
||||||
int sourceId() const { return m_sourceId; }
|
int sourceId() const { return m_sourceId; }
|
||||||
|
|
||||||
void setSourceId(int sourceId);
|
void setSourceId(int sourceId);
|
||||||
|
|
||||||
// ITextSource interface
|
// ITextSource interface
|
||||||
public:
|
|
||||||
|
|
||||||
SourceChar readNextChar();
|
SourceChar readNextChar();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString m_text;
|
QString m_text;
|
||||||
|
|
||||||
int m_sourceId;
|
int m_sourceId;
|
||||||
|
|
||||||
int m_index;
|
int m_index;
|
||||||
|
|
||||||
int m_lineNumber;
|
int m_lineNumber;
|
||||||
|
|
||||||
int m_columnNumber;
|
int m_columnNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -88,9 +88,8 @@ TextScanner::~TextScanner()
|
|||||||
void TextScanner::setKeywords(const QList<QPair<QString, int> > &keywords)
|
void TextScanner::setKeywords(const QList<QPair<QString, int> > &keywords)
|
||||||
{
|
{
|
||||||
d->m_keywordToSubtypeMap.clear();
|
d->m_keywordToSubtypeMap.clear();
|
||||||
foreach (const DefTuple &tuple, keywords) {
|
foreach (const DefTuple &tuple, keywords)
|
||||||
d->m_keywordToSubtypeMap.insert(tuple.first.toLower(), tuple.second);
|
d->m_keywordToSubtypeMap.insert(tuple.first.toLower(), tuple.second);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextScanner::setOperators(const QList<QPair<QString, int> > &operators)
|
void TextScanner::setOperators(const QList<QPair<QString, int> > &operators)
|
||||||
@@ -102,13 +101,11 @@ void TextScanner::setOperators(const QList<QPair<QString, int> > &operators)
|
|||||||
foreach (const DefTuple &tuple, operators) {
|
foreach (const DefTuple &tuple, operators) {
|
||||||
QString op = tuple.first;
|
QString op = tuple.first;
|
||||||
d->m_operatorToSubtypeMap.insert(op, tuple.second);
|
d->m_operatorToSubtypeMap.insert(op, tuple.second);
|
||||||
if (op.length() > d->m_maxOperatorLength) {
|
if (op.length() > d->m_maxOperatorLength)
|
||||||
d->m_maxOperatorLength = op.length();
|
d->m_maxOperatorLength = op.length();
|
||||||
}
|
|
||||||
d->m_operatorFirstCharsSet.insert(op.at(0));
|
d->m_operatorFirstCharsSet.insert(op.at(0));
|
||||||
foreach (const QChar ch, op) {
|
foreach (const QChar ch, op)
|
||||||
d->m_operatorCharsSet.insert(ch);
|
d->m_operatorCharsSet.insert(ch);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,28 +121,26 @@ SourcePos TextScanner::sourcePos() const
|
|||||||
|
|
||||||
Token TextScanner::read()
|
Token TextScanner::read()
|
||||||
{
|
{
|
||||||
if (!d->m_unreadTokens.isEmpty()) {
|
if (!d->m_unreadTokens.isEmpty())
|
||||||
return d->m_unreadTokens.pop();
|
return d->m_unreadTokens.pop();
|
||||||
}
|
|
||||||
skipWhitespaces();
|
skipWhitespaces();
|
||||||
SourceChar sourceChar = readChar();
|
SourceChar sourceChar = readChar();
|
||||||
if (sourceChar.ch == QLatin1Char('\'') || sourceChar.ch == QLatin1Char('\"')) {
|
if (sourceChar.ch == QLatin1Char('\'') || sourceChar.ch == QLatin1Char('\"'))
|
||||||
return scanString(sourceChar);
|
return scanString(sourceChar);
|
||||||
} else if (sourceChar.ch.isDigit()) {
|
else if (sourceChar.ch.isDigit())
|
||||||
return scanNumber(sourceChar);
|
return scanNumber(sourceChar);
|
||||||
} else if (sourceChar.ch.isLetter() || sourceChar.ch == QLatin1Char('_')) {
|
else if (sourceChar.ch.isLetter() || sourceChar.ch == QLatin1Char('_'))
|
||||||
return scanIdentifier(sourceChar);
|
return scanIdentifier(sourceChar);
|
||||||
} else if (sourceChar.ch == QLatin1Char('#')) {
|
else if (sourceChar.ch == QLatin1Char('#'))
|
||||||
return scanColorIdentifier(sourceChar);
|
return scanColorIdentifier(sourceChar);
|
||||||
} else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn) {
|
else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn)
|
||||||
return Token(Token::TokenEndOfLine, QString(), sourceChar.pos);
|
return Token(Token::TokenEndOfLine, QString(), sourceChar.pos);
|
||||||
} else if (sourceChar.ch.isNull()) {
|
else if (sourceChar.ch.isNull())
|
||||||
return Token(Token::TokenEndOfInput, QString(), sourceChar.pos);
|
return Token(Token::TokenEndOfInput, QString(), sourceChar.pos);
|
||||||
} else if (d->m_operatorFirstCharsSet.contains(sourceChar.ch)) {
|
else if (d->m_operatorFirstCharsSet.contains(sourceChar.ch))
|
||||||
return scanOperator(sourceChar);
|
return scanOperator(sourceChar);
|
||||||
} else {
|
else
|
||||||
throw TextScannerError(QStringLiteral("Unexpected character."), sourceChar.pos);
|
throw TextScannerError(QStringLiteral("Unexpected character."), sourceChar.pos);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextScanner::unread(const Token &token)
|
void TextScanner::unread(const Token &token)
|
||||||
@@ -156,11 +151,10 @@ void TextScanner::unread(const Token &token)
|
|||||||
SourceChar TextScanner::readChar()
|
SourceChar TextScanner::readChar()
|
||||||
{
|
{
|
||||||
SourceChar ch;
|
SourceChar ch;
|
||||||
if (!d->m_unreadSourceChars.isEmpty()) {
|
if (!d->m_unreadSourceChars.isEmpty())
|
||||||
ch = d->m_unreadSourceChars.pop();
|
ch = d->m_unreadSourceChars.pop();
|
||||||
} else {
|
else
|
||||||
ch = d->m_source->readNextChar();
|
ch = d->m_source->readNextChar();
|
||||||
}
|
|
||||||
d->m_lastSourcePos = ch.pos;
|
d->m_lastSourcePos = ch.pos;
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
@@ -179,9 +173,8 @@ void TextScanner::skipWhitespaces()
|
|||||||
if (secondSourceChar.ch == QLatin1Char('/')) {
|
if (secondSourceChar.ch == QLatin1Char('/')) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
SourceChar commentChar = readChar();
|
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;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unreadChar(secondSourceChar);
|
unreadChar(secondSourceChar);
|
||||||
@@ -203,19 +196,18 @@ Token TextScanner::scanString(const SourceChar &delimiterChar)
|
|||||||
return Token(Token::TokenString, text, delimiterChar.pos);
|
return Token(Token::TokenString, text, delimiterChar.pos);
|
||||||
} else if (sourceChar.ch == QLatin1Char('\\')) {
|
} else if (sourceChar.ch == QLatin1Char('\\')) {
|
||||||
sourceChar = readChar();
|
sourceChar = readChar();
|
||||||
if (sourceChar.ch == QLatin1Char('n')) {
|
if (sourceChar.ch == QLatin1Char('n'))
|
||||||
text += QLatin1Char('\n');
|
text += QLatin1Char('\n');
|
||||||
} else if (sourceChar.ch == QLatin1Char('\\')) {
|
else if (sourceChar.ch == QLatin1Char('\\'))
|
||||||
text += QLatin1Char('\\');
|
text += QLatin1Char('\\');
|
||||||
} else if (sourceChar.ch == QLatin1Char('t')) {
|
else if (sourceChar.ch == QLatin1Char('t'))
|
||||||
text += QLatin1Char('\t');
|
text += QLatin1Char('\t');
|
||||||
} else if (sourceChar.ch == QLatin1Char('\"')) {
|
else if (sourceChar.ch == QLatin1Char('\"'))
|
||||||
text += QLatin1Char('\"');
|
text += QLatin1Char('\"');
|
||||||
} else if (sourceChar.ch == QLatin1Char('\'')) {
|
else if (sourceChar.ch == QLatin1Char('\''))
|
||||||
text += QLatin1Char('\'');
|
text += QLatin1Char('\'');
|
||||||
} else {
|
else
|
||||||
throw TextScannerError(QStringLiteral("Unexpected character after '\\' in string constant."), sourceChar.pos);
|
throw TextScannerError(QStringLiteral("Unexpected character after '\\' in string constant."), sourceChar.pos);
|
||||||
}
|
|
||||||
} else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn) {
|
} else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn) {
|
||||||
throw TextScannerError(QStringLiteral("Unexpected end of line in string constant."), sourceChar.pos);
|
throw TextScannerError(QStringLiteral("Unexpected end of line in string constant."), sourceChar.pos);
|
||||||
} else {
|
} else {
|
||||||
@@ -230,18 +222,16 @@ Token TextScanner::scanNumber(const SourceChar &firstDigit)
|
|||||||
SourceChar sourceChar;
|
SourceChar sourceChar;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
sourceChar = readChar();
|
sourceChar = readChar();
|
||||||
if (!sourceChar.ch.isDigit()) {
|
if (!sourceChar.ch.isDigit())
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
text += sourceChar.ch;
|
text += sourceChar.ch;
|
||||||
}
|
}
|
||||||
if (sourceChar.ch == QLatin1Char('.')) {
|
if (sourceChar.ch == QLatin1Char('.')) {
|
||||||
text += sourceChar.ch;
|
text += sourceChar.ch;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
sourceChar = readChar();
|
sourceChar = readChar();
|
||||||
if (!sourceChar.ch.isDigit()) {
|
if (!sourceChar.ch.isDigit())
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
text += sourceChar.ch;
|
text += sourceChar.ch;
|
||||||
}
|
}
|
||||||
unreadChar(sourceChar);
|
unreadChar(sourceChar);
|
||||||
@@ -261,9 +251,8 @@ Token TextScanner::scanIdentifier(const SourceChar &firstChar)
|
|||||||
if (!sourceChar.ch.isLetterOrNumber() && sourceChar.ch != QLatin1Char('_')) {
|
if (!sourceChar.ch.isLetterOrNumber() && sourceChar.ch != QLatin1Char('_')) {
|
||||||
unreadChar(sourceChar);
|
unreadChar(sourceChar);
|
||||||
QString keyword = text.toLower();
|
QString keyword = text.toLower();
|
||||||
if (d->m_keywordToSubtypeMap.contains(keyword)) {
|
if (d->m_keywordToSubtypeMap.contains(keyword))
|
||||||
return Token(Token::TokenKeyword, d->m_keywordToSubtypeMap.value(keyword), text, firstChar.pos);
|
return Token(Token::TokenKeyword, d->m_keywordToSubtypeMap.value(keyword), text, firstChar.pos);
|
||||||
}
|
|
||||||
return Token(Token::TokenIdentifier, text, firstChar.pos);
|
return Token(Token::TokenIdentifier, text, firstChar.pos);
|
||||||
}
|
}
|
||||||
text += sourceChar.ch;
|
text += sourceChar.ch;
|
||||||
|
|||||||
@@ -43,75 +43,47 @@ class ITextSource;
|
|||||||
class SourceChar;
|
class SourceChar;
|
||||||
class Token;
|
class Token;
|
||||||
|
|
||||||
class QMT_EXPORT TextScannerError :
|
class QMT_EXPORT TextScannerError : public Exception
|
||||||
public Exception
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TextScannerError(const QString &errorMsg, const SourcePos &sourcePos);
|
TextScannerError(const QString &errorMsg, const SourcePos &sourcePos);
|
||||||
|
|
||||||
~TextScannerError();
|
~TextScannerError();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
SourcePos sourcePos() const { return m_sourcePos; }
|
SourcePos sourcePos() const { return m_sourcePos; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SourcePos m_sourcePos;
|
SourcePos m_sourcePos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class QMT_EXPORT TextScanner : public QObject
|
class QMT_EXPORT TextScanner : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
class TextScannerPrivate;
|
class TextScannerPrivate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TextScanner(QObject *parent = 0);
|
explicit TextScanner(QObject *parent = 0);
|
||||||
|
|
||||||
~TextScanner();
|
~TextScanner();
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void setKeywords(const QList<QPair<QString, int> > &keywords);
|
void setKeywords(const QList<QPair<QString, int> > &keywords);
|
||||||
|
|
||||||
void setOperators(const QList<QPair<QString, int> > &operators);
|
void setOperators(const QList<QPair<QString, int> > &operators);
|
||||||
|
|
||||||
void setSource(ITextSource *textSource);
|
void setSource(ITextSource *textSource);
|
||||||
|
|
||||||
SourcePos sourcePos() const;
|
SourcePos sourcePos() const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Token read();
|
Token read();
|
||||||
|
|
||||||
void unread(const Token &token);
|
void unread(const Token &token);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SourceChar readChar();
|
SourceChar readChar();
|
||||||
|
|
||||||
void unreadChar(const SourceChar &sourceChar);
|
void unreadChar(const SourceChar &sourceChar);
|
||||||
|
|
||||||
void skipWhitespaces();
|
void skipWhitespaces();
|
||||||
|
|
||||||
Token scanString(const SourceChar &delimiterChar);
|
Token scanString(const SourceChar &delimiterChar);
|
||||||
|
|
||||||
Token scanNumber(const SourceChar &firstDigit);
|
Token scanNumber(const SourceChar &firstDigit);
|
||||||
|
|
||||||
Token scanIdentifier(const SourceChar &firstChar);
|
Token scanIdentifier(const SourceChar &firstChar);
|
||||||
|
|
||||||
Token scanColorIdentifier(const SourceChar &firstChar);
|
Token scanColorIdentifier(const SourceChar &firstChar);
|
||||||
|
|
||||||
Token scanOperator(const SourceChar &firstChar);
|
Token scanOperator(const SourceChar &firstChar);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
TextScannerPrivate *d;
|
TextScannerPrivate *d;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace qmt
|
} // namespace qmt
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class SourceChar
|
class SourceChar
|
||||||
@@ -55,13 +54,11 @@ public:
|
|||||||
class ITextSource
|
class ITextSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~ITextSource() { }
|
virtual ~ITextSource() { }
|
||||||
|
|
||||||
virtual SourceChar readNextChar() = 0;
|
virtual SourceChar readNextChar() = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_TEXTSOURCE_H
|
#endif // QMT_TEXTSOURCE_H
|
||||||
|
|||||||
11
src/libs/3rdparty/modeling/qmt/config/token.h
vendored
11
src/libs/3rdparty/modeling/qmt/config/token.h
vendored
@@ -40,7 +40,6 @@ namespace qmt {
|
|||||||
class Token
|
class Token
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
TokenUndefined,
|
TokenUndefined,
|
||||||
TokenEndOfInput,
|
TokenEndOfInput,
|
||||||
@@ -54,28 +53,18 @@ public:
|
|||||||
TokenColor
|
TokenColor
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
Token();
|
Token();
|
||||||
Token(Type type, const QString &text, const SourcePos &sourcePos);
|
Token(Type type, const QString &text, const SourcePos &sourcePos);
|
||||||
Token(Type type, int subtype, const QString &text, const SourcePos &sourcePos);
|
Token(Type type, int subtype, const QString &text, const SourcePos &sourcePos);
|
||||||
~Token();
|
~Token();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Type type() const { return m_type; }
|
Type type() const { return m_type; }
|
||||||
|
|
||||||
void setType(Type type);
|
void setType(Type type);
|
||||||
|
|
||||||
int subtype() const { return m_subtype; }
|
int subtype() const { return m_subtype; }
|
||||||
|
|
||||||
void setSubtype(int subtype);
|
void setSubtype(int subtype);
|
||||||
|
|
||||||
QString text() const { return m_text; }
|
QString text() const { return m_text; }
|
||||||
|
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
|
||||||
SourcePos sourcePos() const { return m_sourcePos; }
|
SourcePos sourcePos() const { return m_sourcePos; }
|
||||||
|
|
||||||
void setSourcePos(const SourcePos &sourcePos);
|
void setSourcePos(const SourcePos &sourcePos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ template<class T>
|
|||||||
class Container
|
class Container
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Container() { }
|
Container() { }
|
||||||
|
|
||||||
Container(const Container<T> &rhs)
|
Container(const Container<T> &rhs)
|
||||||
: m_elements(rhs.m_elements)
|
: m_elements(rhs.m_elements)
|
||||||
{
|
{
|
||||||
@@ -49,14 +47,11 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~Container()
|
~Container()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_elements);
|
qDeleteAll(m_elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Container &operator=(const Container<T> &rhs)
|
Container &operator=(const Container<T> &rhs)
|
||||||
{
|
{
|
||||||
if (this != &rhs) {
|
if (this != &rhs) {
|
||||||
@@ -67,12 +62,8 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isEmpty() const { return m_elements.empty(); }
|
bool isEmpty() const { return m_elements.empty(); }
|
||||||
|
|
||||||
int size() const { return m_elements.size(); }
|
int size() const { return m_elements.size(); }
|
||||||
|
|
||||||
QList<T *> elements() const { return m_elements; }
|
QList<T *> elements() const { return m_elements; }
|
||||||
|
|
||||||
QList<T *> takeElements() const
|
QList<T *> takeElements() const
|
||||||
@@ -100,10 +91,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
mutable QList<T *> m_elements;
|
mutable QList<T *> m_elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_CONTAINER_H
|
#endif // QMT_CONTAINER_H
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ NameController::NameController(QObject *parent)
|
|||||||
|
|
||||||
NameController::~NameController()
|
NameController::~NameController()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NameController::convertFileNameToElementName(const QString &fileName)
|
QString NameController::convertFileNameToElementName(const QString &fileName)
|
||||||
@@ -116,11 +115,10 @@ QString NameController::calcRelativePath(const QString &absoluteFileName, const
|
|||||||
} else if (i >= absoluteFileName.size()) {
|
} else if (i >= absoluteFileName.size()) {
|
||||||
// absoluteFileName is a substring of anchor path.
|
// absoluteFileName is a substring of anchor path.
|
||||||
if (slashIndex == i - 1) {
|
if (slashIndex == i - 1) {
|
||||||
if (secondLastSlashIndex < 0) {
|
if (secondLastSlashIndex < 0)
|
||||||
relativePath = absoluteFileName;
|
relativePath = absoluteFileName;
|
||||||
} else {
|
else
|
||||||
relativePath = absoluteFileName.mid(secondLastSlashIndex + 1);
|
relativePath = absoluteFileName.mid(secondLastSlashIndex + 1);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
relativePath = absoluteFileName.mid(slashIndex + 1);
|
relativePath = absoluteFileName.mid(slashIndex + 1);
|
||||||
}
|
}
|
||||||
@@ -135,9 +133,8 @@ QString NameController::calcElementNameSearchId(const QString &elementName)
|
|||||||
{
|
{
|
||||||
QString searchId;
|
QString searchId;
|
||||||
foreach (const QChar &c, elementName) {
|
foreach (const QChar &c, elementName) {
|
||||||
if (c.isLetterOrNumber()) {
|
if (c.isLetterOrNumber())
|
||||||
searchId += c.toLower();
|
searchId += c.toLower();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return searchId;
|
return searchId;
|
||||||
}
|
}
|
||||||
@@ -148,9 +145,8 @@ QList<QString> NameController::buildElementsPath(const QString &filePath, bool i
|
|||||||
|
|
||||||
QStringList splitted = filePath.split(QStringLiteral("/"));
|
QStringList splitted = filePath.split(QStringLiteral("/"));
|
||||||
QStringList::const_iterator splittedEnd = splitted.end();
|
QStringList::const_iterator splittedEnd = splitted.end();
|
||||||
if (ignoreLastFilePathPart || splitted.last().isEmpty()) {
|
if (ignoreLastFilePathPart || splitted.last().isEmpty())
|
||||||
splittedEnd = --splittedEnd;
|
splittedEnd = --splittedEnd;
|
||||||
}
|
|
||||||
for (QStringList::const_iterator it = splitted.cbegin(); it != splittedEnd; ++it) {
|
for (QStringList::const_iterator it = splitted.cbegin(); it != splittedEnd; ++it) {
|
||||||
QString packageName = qmt::NameController::convertFileNameToElementName(*it);
|
QString packageName = qmt::NameController::convertFileNameToElementName(*it);
|
||||||
relativeElements.append(packageName);
|
relativeElements.append(packageName);
|
||||||
@@ -158,5 +154,4 @@ QList<QString> NameController::buildElementsPath(const QString &filePath, bool i
|
|||||||
return relativeElements;
|
return relativeElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace qmt
|
||||||
}
|
|
||||||
|
|||||||
@@ -39,32 +39,22 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT NameController :
|
class QMT_EXPORT NameController : public QObject
|
||||||
public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NameController(QObject *parent = 0);
|
NameController(QObject *parent = 0);
|
||||||
|
|
||||||
~NameController();
|
~NameController();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static QString convertFileNameToElementName(const QString &fileName);
|
static QString convertFileNameToElementName(const QString &fileName);
|
||||||
|
|
||||||
static QString convertElementNameToBaseFileName(const QString &elementName);
|
static QString convertElementNameToBaseFileName(const QString &elementName);
|
||||||
|
|
||||||
static QString calcRelativePath(const QString &absoluteFileName, const QString &anchorPath);
|
static QString calcRelativePath(const QString &absoluteFileName, const QString &anchorPath);
|
||||||
|
|
||||||
static QString calcElementNameSearchId(const QString &elementName);
|
static QString calcElementNameSearchId(const QString &elementName);
|
||||||
|
|
||||||
static QList<QString> buildElementsPath(const QString &filePath, bool ignoreLastFilePathPart);
|
static QList<QString> buildElementsPath(const QString &filePath, bool ignoreLastFilePathPart);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_NAMECONTROLLER_H
|
#endif // QMT_NAMECONTROLLER_H
|
||||||
|
|||||||
@@ -42,28 +42,19 @@ protected:
|
|||||||
References() { }
|
References() { }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~References() { }
|
~References() { }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isEmpty() const { return m_elements.empty(); }
|
bool isEmpty() const { return m_elements.empty(); }
|
||||||
|
|
||||||
int size() const { return m_elements.size(); }
|
int size() const { return m_elements.size(); }
|
||||||
|
|
||||||
QList<T *> elements() const { return m_elements; }
|
QList<T *> elements() const { return m_elements; }
|
||||||
|
|
||||||
void setElements(const QList<T *> &elements) { m_elements = elements; }
|
void setElements(const QList<T *> &elements) { m_elements = elements; }
|
||||||
|
|
||||||
void clear() { m_elements.clear(); }
|
void clear() { m_elements.clear(); }
|
||||||
|
|
||||||
void append(T *element) { m_elements.append(element); }
|
void append(T *element) { m_elements.append(element); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QList<T *> m_elements;
|
QList<T *> m_elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_REFERENCES_H
|
#endif // QMT_REFERENCES_H
|
||||||
|
|||||||
@@ -60,4 +60,4 @@ void Selection::append(const Uid &elementKey, const Uid &ownerKey)
|
|||||||
append(Index(elementKey, ownerKey));
|
append(Index(elementKey, ownerKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -35,15 +35,14 @@
|
|||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT Selection
|
class QMT_EXPORT Selection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class Index {
|
class Index
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Index(const Uid &elementKey, const Uid &ownerKey)
|
Index(const Uid &elementKey, const Uid &ownerKey)
|
||||||
: m_elementKey(elementKey),
|
: m_elementKey(elementKey),
|
||||||
m_ownerKey(ownerKey)
|
m_ownerKey(ownerKey)
|
||||||
@@ -51,46 +50,31 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Uid elementKey() const { return m_elementKey; }
|
Uid elementKey() const { return m_elementKey; }
|
||||||
|
|
||||||
Uid ownerKey() const { return m_ownerKey; }
|
Uid ownerKey() const { return m_ownerKey; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Uid m_elementKey;
|
Uid m_elementKey;
|
||||||
|
|
||||||
Uid m_ownerKey;
|
Uid m_ownerKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Selection();
|
Selection();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~Selection();
|
~Selection();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isEmpty() const { return m_indices.isEmpty(); }
|
bool isEmpty() const { return m_indices.isEmpty(); }
|
||||||
|
|
||||||
QList<Index> indices() const { return m_indices; }
|
QList<Index> indices() const { return m_indices; }
|
||||||
|
|
||||||
void setIndices(const QList<Index> &indices);
|
void setIndices(const QList<Index> &indices);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void append(const Index &index);
|
void append(const Index &index);
|
||||||
|
|
||||||
void append(const Uid &elementKey, const Uid &ownerKey);
|
void append(const Uid &elementKey, const Uid &ownerKey);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QList<Index> m_indices;
|
QList<Index> m_indices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
|
|
||||||
#endif // QMT_SELECTION_H
|
#endif // QMT_SELECTION_H
|
||||||
|
|||||||
@@ -58,12 +58,10 @@ void UndoCommand::setDoNotMerge(bool doNotMerge)
|
|||||||
bool UndoCommand::mergeWith(const QUndoCommand *other)
|
bool UndoCommand::mergeWith(const QUndoCommand *other)
|
||||||
{
|
{
|
||||||
const UndoCommand *otherCommand = dynamic_cast<const UndoCommand *>(other);
|
const UndoCommand *otherCommand = dynamic_cast<const UndoCommand *>(other);
|
||||||
if (!otherCommand) {
|
if (!otherCommand)
|
||||||
return false;
|
return false;
|
||||||
}
|
if (otherCommand->m_doNotMerge)
|
||||||
if (otherCommand->m_doNotMerge) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return mergeWith(otherCommand);
|
return mergeWith(otherCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,4 +84,4 @@ void UndoCommand::redo()
|
|||||||
m_canRedo = false;
|
m_canRedo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -34,42 +34,29 @@
|
|||||||
#include <QUndoCommand>
|
#include <QUndoCommand>
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT UndoCommand :
|
class QMT_EXPORT UndoCommand : public QUndoCommand
|
||||||
public QUndoCommand
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit UndoCommand(const QString &text);
|
explicit UndoCommand(const QString &text);
|
||||||
|
|
||||||
~UndoCommand();
|
~UndoCommand();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool canRedo() const { return m_canRedo; }
|
bool canRedo() const { return m_canRedo; }
|
||||||
|
|
||||||
int id() const;
|
int id() const;
|
||||||
|
|
||||||
void setDoNotMerge(bool doNotMerge);
|
void setDoNotMerge(bool doNotMerge);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool mergeWith(const QUndoCommand *other);
|
bool mergeWith(const QUndoCommand *other);
|
||||||
|
|
||||||
virtual bool mergeWith(const UndoCommand *other);
|
virtual bool mergeWith(const UndoCommand *other);
|
||||||
|
|
||||||
void undo();
|
void undo();
|
||||||
|
|
||||||
void redo();
|
void redo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_canRedo;
|
bool m_canRedo;
|
||||||
|
|
||||||
bool m_doNotMerge;
|
bool m_doNotMerge;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_UNDOCOMMAND_H
|
#endif // QMT_UNDOCOMMAND_H
|
||||||
|
|||||||
@@ -74,4 +74,4 @@ void UndoController::doNotMerge()
|
|||||||
m_doNotMerge = true;
|
m_doNotMerge = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -38,51 +38,34 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class UndoCommand;
|
class UndoCommand;
|
||||||
|
|
||||||
|
class QMT_EXPORT UndoController : public QObject
|
||||||
class QMT_EXPORT UndoController :
|
|
||||||
public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit UndoController(QObject *parent = 0);
|
explicit UndoController(QObject *parent = 0);
|
||||||
|
|
||||||
~UndoController();
|
~UndoController();
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QUndoStack *undoStack() const { return m_undoStack; }
|
QUndoStack *undoStack() const { return m_undoStack; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void push(UndoCommand *cmd);
|
void push(UndoCommand *cmd);
|
||||||
|
|
||||||
void beginMergeSequence(const QString &text);
|
void beginMergeSequence(const QString &text);
|
||||||
|
|
||||||
void endMergeSequence();
|
void endMergeSequence();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void doNotMerge();
|
void doNotMerge();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
|
|
||||||
bool m_doNotMerge;
|
bool m_doNotMerge;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_UNDOCONTROLLER_H
|
#endif // QMT_UNDOCONTROLLER_H
|
||||||
|
|||||||
@@ -104,4 +104,4 @@ void DAnnotation::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDAnnotation(this);
|
visitor->visitDAnnotation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -38,11 +38,9 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DAnnotation :
|
class QMT_EXPORT DAnnotation : public DElement
|
||||||
public DElement
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum VisualRole {
|
enum VisualRole {
|
||||||
RoleNormal,
|
RoleNormal,
|
||||||
RoleTitle,
|
RoleTitle,
|
||||||
@@ -52,62 +50,35 @@ public:
|
|||||||
RoleFootnote
|
RoleFootnote
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DAnnotation();
|
DAnnotation();
|
||||||
|
|
||||||
DAnnotation(const DAnnotation &);
|
DAnnotation(const DAnnotation &);
|
||||||
|
|
||||||
~DAnnotation();
|
~DAnnotation();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DAnnotation &operator=(const DAnnotation &);
|
DAnnotation &operator=(const DAnnotation &);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Uid modelUid() const { return Uid::invalidUid(); }
|
Uid modelUid() const { return Uid::invalidUid(); }
|
||||||
|
|
||||||
QString text() const { return m_text; }
|
QString text() const { return m_text; }
|
||||||
|
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
|
||||||
QPointF pos() const { return m_pos; }
|
QPointF pos() const { return m_pos; }
|
||||||
|
|
||||||
void setPos(const QPointF &pos);
|
void setPos(const QPointF &pos);
|
||||||
|
|
||||||
QRectF rect() const { return m_rect; }
|
QRectF rect() const { return m_rect; }
|
||||||
|
|
||||||
void setRect(const QRectF &rect);
|
void setRect(const QRectF &rect);
|
||||||
|
|
||||||
VisualRole visualRole() const { return m_visualRole; }
|
VisualRole visualRole() const { return m_visualRole; }
|
||||||
|
|
||||||
void setVisualRole(VisualRole visualRole);
|
void setVisualRole(VisualRole visualRole);
|
||||||
|
|
||||||
bool isAutoSized() const { return m_isAutoSized; }
|
bool isAutoSized() const { return m_isAutoSized; }
|
||||||
|
|
||||||
void setAutoSized(bool autoSized);
|
void setAutoSized(bool autoSized);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString m_text;
|
QString m_text;
|
||||||
|
|
||||||
QPointF m_pos;
|
QPointF m_pos;
|
||||||
|
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
|
|
||||||
VisualRole m_visualRole;
|
VisualRole m_visualRole;
|
||||||
|
|
||||||
bool m_isAutoSized;
|
bool m_isAutoSized;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DANNOTATION_H
|
#endif // QMT_DANNOTATION_H
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DAssociationEnd::DAssociationEnd()
|
DAssociationEnd::DAssociationEnd()
|
||||||
@@ -68,9 +67,8 @@ void DAssociationEnd::setKind(MAssociationEnd::Kind kind)
|
|||||||
|
|
||||||
bool operator==(const DAssociationEnd &lhs, const DAssociationEnd &rhs)
|
bool operator==(const DAssociationEnd &lhs, const DAssociationEnd &rhs)
|
||||||
{
|
{
|
||||||
if (&lhs == &rhs) {
|
if (&lhs == &rhs)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return lhs.name() == rhs.name()
|
return lhs.name() == rhs.name()
|
||||||
&& lhs.cardinality() == rhs.cardinality()
|
&& lhs.cardinality() == rhs.cardinality()
|
||||||
&& lhs.kind() == rhs.kind()
|
&& lhs.kind() == rhs.kind()
|
||||||
@@ -82,8 +80,6 @@ bool operator!=(const DAssociationEnd &lhs, const DAssociationEnd &rhs)
|
|||||||
return !operator==(lhs, rhs);
|
return !operator==(lhs, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DAssociation::DAssociation()
|
DAssociation::DAssociation()
|
||||||
: m_associationClassUid(Uid::invalidUid())
|
: m_associationClassUid(Uid::invalidUid())
|
||||||
{
|
{
|
||||||
@@ -118,4 +114,4 @@ void DAssociation::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDAssociation(this);
|
visitor->visitDAssociation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -35,88 +35,56 @@
|
|||||||
|
|
||||||
#include "qmt/model/massociation.h"
|
#include "qmt/model/massociation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DAssociationEnd
|
class QMT_EXPORT DAssociationEnd
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DAssociationEnd();
|
DAssociationEnd();
|
||||||
|
|
||||||
~DAssociationEnd();
|
~DAssociationEnd();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
|
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
QString cardinality() const { return m_cardinality; }
|
QString cardinality() const { return m_cardinality; }
|
||||||
|
|
||||||
void setCardinatlity(const QString &cardinality);
|
void setCardinatlity(const QString &cardinality);
|
||||||
|
|
||||||
MAssociationEnd::Kind kind() const { return m_kind; }
|
MAssociationEnd::Kind kind() const { return m_kind; }
|
||||||
|
|
||||||
void setKind(MAssociationEnd::Kind kind);
|
void setKind(MAssociationEnd::Kind kind);
|
||||||
|
|
||||||
bool isNavigable() const { return m_isNavigable; }
|
bool isNavigable() const { return m_isNavigable; }
|
||||||
|
|
||||||
void setNavigable(bool navigable);
|
void setNavigable(bool navigable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
QString m_cardinality;
|
QString m_cardinality;
|
||||||
|
|
||||||
MAssociationEnd::Kind m_kind;
|
MAssociationEnd::Kind m_kind;
|
||||||
|
|
||||||
bool m_isNavigable;
|
bool m_isNavigable;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const DAssociationEnd &lhs, const DAssociationEnd &rhs);
|
bool operator==(const DAssociationEnd &lhs, const DAssociationEnd &rhs);
|
||||||
|
|
||||||
bool operator!=(const DAssociationEnd &lhs, const DAssociationEnd &rhs);
|
bool operator!=(const DAssociationEnd &lhs, const DAssociationEnd &rhs);
|
||||||
|
|
||||||
|
class QMT_EXPORT DAssociation : public DRelation
|
||||||
class QMT_EXPORT DAssociation :
|
|
||||||
public DRelation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DAssociation();
|
DAssociation();
|
||||||
|
|
||||||
~DAssociation();
|
~DAssociation();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DAssociationEnd endA() const { return m_endA; }
|
DAssociationEnd endA() const { return m_endA; }
|
||||||
|
|
||||||
void setEndA(const DAssociationEnd &endA);
|
void setEndA(const DAssociationEnd &endA);
|
||||||
|
|
||||||
DAssociationEnd endB() const { return m_endB; }
|
DAssociationEnd endB() const { return m_endB; }
|
||||||
|
|
||||||
void setEndB(const DAssociationEnd &endB);
|
void setEndB(const DAssociationEnd &endB);
|
||||||
|
|
||||||
Uid assoicationClassUid() const { return m_associationClassUid; }
|
Uid assoicationClassUid() const { return m_associationClassUid; }
|
||||||
|
|
||||||
void setAssociationClassUid(const Uid &uid);
|
void setAssociationClassUid(const Uid &uid);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DAssociationEnd m_endA;
|
DAssociationEnd m_endA;
|
||||||
|
|
||||||
DAssociationEnd m_endB;
|
DAssociationEnd m_endB;
|
||||||
|
|
||||||
Uid m_associationClassUid;
|
Uid m_associationClassUid;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DASSOCIATION_H
|
#endif // QMT_DASSOCIATION_H
|
||||||
|
|||||||
@@ -88,4 +88,4 @@ void DBoundary::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDBoundary(this);
|
visitor->visitDBoundary(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -36,55 +36,34 @@
|
|||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DBoundary :
|
class QMT_EXPORT DBoundary : public DElement
|
||||||
public DElement
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DBoundary();
|
DBoundary();
|
||||||
|
|
||||||
DBoundary(const DBoundary &rhs);
|
DBoundary(const DBoundary &rhs);
|
||||||
|
|
||||||
~DBoundary();
|
~DBoundary();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DBoundary &operator=(const DBoundary &rhs);
|
DBoundary &operator=(const DBoundary &rhs);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Uid modelUid() const { return Uid::invalidUid(); }
|
Uid modelUid() const { return Uid::invalidUid(); }
|
||||||
|
|
||||||
QString text() const { return m_text; }
|
QString text() const { return m_text; }
|
||||||
|
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
|
||||||
QPointF pos() const { return m_pos; }
|
QPointF pos() const { return m_pos; }
|
||||||
|
|
||||||
void setPos(const QPointF &pos);
|
void setPos(const QPointF &pos);
|
||||||
|
|
||||||
QRectF rect() const { return m_rect; }
|
QRectF rect() const { return m_rect; }
|
||||||
|
|
||||||
void setRect(const QRectF &rect);
|
void setRect(const QRectF &rect);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString m_text;
|
QString m_text;
|
||||||
|
|
||||||
QPointF m_pos;
|
QPointF m_pos;
|
||||||
|
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DBOUNDARY_H
|
#endif // QMT_DBOUNDARY_H
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DClass::DClass()
|
DClass::DClass()
|
||||||
@@ -82,4 +81,4 @@ void DClass::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDClass(this);
|
visitor->visitDClass(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
30
src/libs/3rdparty/modeling/qmt/diagram/dclass.h
vendored
30
src/libs/3rdparty/modeling/qmt/diagram/dclass.h
vendored
@@ -36,70 +36,44 @@
|
|||||||
|
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DClass :
|
class QMT_EXPORT DClass : public DObject
|
||||||
public DObject
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum TemplateDisplay {
|
enum TemplateDisplay {
|
||||||
TemplateSmart,
|
TemplateSmart,
|
||||||
TemplateBox,
|
TemplateBox,
|
||||||
TemplateName
|
TemplateName
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
DClass();
|
DClass();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QString umlNamespace() const { return m_umlNamespace; }
|
QString umlNamespace() const { return m_umlNamespace; }
|
||||||
|
|
||||||
void setUmlNamespace(const QString ¨Namespace);
|
void setUmlNamespace(const QString ¨Namespace);
|
||||||
|
|
||||||
QList<QString> templateParameters() const { return m_templateParameters; }
|
QList<QString> templateParameters() const { return m_templateParameters; }
|
||||||
|
|
||||||
void setTemplateParameters(const QList<QString> &templateParameters);
|
void setTemplateParameters(const QList<QString> &templateParameters);
|
||||||
|
|
||||||
QList<MClassMember> members() const { return m_members; }
|
QList<MClassMember> members() const { return m_members; }
|
||||||
|
|
||||||
void setMembers(const QList<MClassMember> &members);
|
void setMembers(const QList<MClassMember> &members);
|
||||||
|
|
||||||
QSet<Uid> visibleMembers() const { return m_visibleMembers; }
|
QSet<Uid> visibleMembers() const { return m_visibleMembers; }
|
||||||
|
|
||||||
void setVisibleMembers(const QSet<Uid> &visibleMembers);
|
void setVisibleMembers(const QSet<Uid> &visibleMembers);
|
||||||
|
|
||||||
TemplateDisplay templateDisplay() const { return m_templateDisplay; }
|
TemplateDisplay templateDisplay() const { return m_templateDisplay; }
|
||||||
|
|
||||||
void setTemplateDisplay(TemplateDisplay templateDisplay);
|
void setTemplateDisplay(TemplateDisplay templateDisplay);
|
||||||
|
|
||||||
bool showAllMembers() const { return m_showAllMembers; }
|
bool showAllMembers() const { return m_showAllMembers; }
|
||||||
|
|
||||||
void setShowAllMembers(bool showAllMembers);
|
void setShowAllMembers(bool showAllMembers);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString m_umlNamespace;
|
QString m_umlNamespace;
|
||||||
|
|
||||||
QList<QString> m_templateParameters;
|
QList<QString> m_templateParameters;
|
||||||
|
|
||||||
QList<MClassMember> m_members;
|
QList<MClassMember> m_members;
|
||||||
|
|
||||||
QSet<Uid> m_visibleMembers;
|
QSet<Uid> m_visibleMembers;
|
||||||
|
|
||||||
TemplateDisplay m_templateDisplay;
|
TemplateDisplay m_templateDisplay;
|
||||||
|
|
||||||
bool m_showAllMembers;
|
bool m_showAllMembers;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DCLASS_H
|
#endif // QMT_DCLASS_H
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DComponent::DComponent()
|
DComponent::DComponent()
|
||||||
@@ -57,4 +56,4 @@ void DComponent::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDComponent(this);
|
visitor->visitDComponent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -33,32 +33,23 @@
|
|||||||
|
|
||||||
#include "dobject.h"
|
#include "dobject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DComponent :
|
class QMT_EXPORT DComponent : public DObject
|
||||||
public DObject
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DComponent();
|
DComponent();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isPlainShape() const { return m_isPlainShape; }
|
bool isPlainShape() const { return m_isPlainShape; }
|
||||||
|
|
||||||
void setPlainShape(bool planeShape);
|
void setPlainShape(bool planeShape);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_isPlainShape;
|
bool m_isPlainShape;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DCOMPONENT_H
|
#endif // QMT_DCOMPONENT_H
|
||||||
|
|||||||
@@ -47,39 +47,26 @@ class DAssociation;
|
|||||||
class DAnnotation;
|
class DAnnotation;
|
||||||
class DBoundary;
|
class DBoundary;
|
||||||
|
|
||||||
|
|
||||||
class DConstVisitor
|
class DConstVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~DConstVisitor() { }
|
virtual ~DConstVisitor() { }
|
||||||
|
|
||||||
virtual void visitDElement(const DElement *element) = 0;
|
virtual void visitDElement(const DElement *element) = 0;
|
||||||
|
|
||||||
virtual void visitDObject(const DObject *object) = 0;
|
virtual void visitDObject(const DObject *object) = 0;
|
||||||
|
|
||||||
virtual void visitDPackage(const DPackage *package) = 0;
|
virtual void visitDPackage(const DPackage *package) = 0;
|
||||||
|
|
||||||
virtual void visitDClass(const DClass *klass) = 0;
|
virtual void visitDClass(const DClass *klass) = 0;
|
||||||
|
|
||||||
virtual void visitDComponent(const DComponent *component) = 0;
|
virtual void visitDComponent(const DComponent *component) = 0;
|
||||||
|
|
||||||
virtual void visitDDiagram(const DDiagram *diagram) = 0;
|
virtual void visitDDiagram(const DDiagram *diagram) = 0;
|
||||||
|
|
||||||
virtual void visitDItem(const DItem *item) = 0;
|
virtual void visitDItem(const DItem *item) = 0;
|
||||||
|
|
||||||
virtual void visitDRelation(const DRelation *relation) = 0;
|
virtual void visitDRelation(const DRelation *relation) = 0;
|
||||||
|
|
||||||
virtual void visitDInheritance(const DInheritance *inheritance) = 0;
|
virtual void visitDInheritance(const DInheritance *inheritance) = 0;
|
||||||
|
|
||||||
virtual void visitDDependency(const DDependency *dependency) = 0;
|
virtual void visitDDependency(const DDependency *dependency) = 0;
|
||||||
|
|
||||||
virtual void visitDAssociation(const DAssociation *association) = 0;
|
virtual void visitDAssociation(const DAssociation *association) = 0;
|
||||||
|
|
||||||
virtual void visitDAnnotation(const DAnnotation *annotation) = 0;
|
virtual void visitDAnnotation(const DAnnotation *annotation) = 0;
|
||||||
|
|
||||||
virtual void visitDBoundary(const DBoundary *boundary) = 0;
|
virtual void visitDBoundary(const DBoundary *boundary) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DCONSTVISITOR_H
|
#endif // QMT_DCONSTVISITOR_H
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DDependency::DDependency()
|
DDependency::DDependency()
|
||||||
@@ -80,4 +79,4 @@ void DDependency::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDDependency(this);
|
visitor->visitDDependency(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -35,46 +35,30 @@
|
|||||||
|
|
||||||
#include "qmt/model/mdependency.h"
|
#include "qmt/model/mdependency.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DObject;
|
class DObject;
|
||||||
|
|
||||||
|
class QMT_EXPORT DDependency : public DRelation
|
||||||
class QMT_EXPORT DDependency :
|
|
||||||
public DRelation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DDependency();
|
DDependency();
|
||||||
|
|
||||||
~DDependency();
|
~DDependency();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Uid source() const;
|
Uid source() const;
|
||||||
|
|
||||||
void setSource(const Uid &source);
|
void setSource(const Uid &source);
|
||||||
|
|
||||||
Uid target() const;
|
Uid target() const;
|
||||||
|
|
||||||
void setTarget(const Uid &target);
|
void setTarget(const Uid &target);
|
||||||
|
|
||||||
MDependency::Direction direction() const { return m_direction; }
|
MDependency::Direction direction() const { return m_direction; }
|
||||||
|
|
||||||
void setDirection(MDependency::Direction direction);
|
void setDirection(MDependency::Direction direction);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MDependency::Direction m_direction;
|
MDependency::Direction m_direction;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DDEPENDENCY_H
|
#endif // QMT_DDEPENDENCY_H
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DDiagram::DDiagram()
|
DDiagram::DDiagram()
|
||||||
@@ -50,4 +49,4 @@ void DDiagram::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDDiagram(this);
|
visitor->visitDDiagram(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -35,20 +35,15 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DDiagram :
|
class QMT_EXPORT DDiagram : public DObject
|
||||||
public DObject
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DDiagram();
|
DDiagram();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DDIAGRAM_H
|
#endif // QMT_DDIAGRAM_H
|
||||||
|
|||||||
@@ -33,14 +33,12 @@
|
|||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DElement::DElement()
|
DElement::DElement()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DElement::~DElement()
|
DElement::~DElement()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -65,4 +63,4 @@ void DElement::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDElement(this);
|
visitor->visitDElement(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -35,40 +35,29 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DVisitor;
|
class DVisitor;
|
||||||
class DConstVisitor;
|
class DConstVisitor;
|
||||||
|
|
||||||
|
|
||||||
class QMT_EXPORT DElement
|
class QMT_EXPORT DElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DElement();
|
DElement();
|
||||||
|
|
||||||
virtual ~DElement();
|
virtual ~DElement();
|
||||||
|
|
||||||
public:
|
|
||||||
Uid uid() const { return m_uid; }
|
Uid uid() const { return m_uid; }
|
||||||
|
|
||||||
void setUid(const Uid &uid);
|
void setUid(const Uid &uid);
|
||||||
|
|
||||||
void renewUid();
|
void renewUid();
|
||||||
|
|
||||||
virtual Uid modelUid() const = 0;
|
virtual Uid modelUid() const = 0;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Uid m_uid;
|
Uid m_uid;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DELEMENT_H
|
#endif // QMT_DELEMENT_H
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DInheritance::DInheritance()
|
DInheritance::DInheritance()
|
||||||
@@ -72,4 +71,4 @@ void DInheritance::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDInheritance(this);
|
visitor->visitDInheritance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -33,36 +33,24 @@
|
|||||||
|
|
||||||
#include "drelation.h"
|
#include "drelation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DClass;
|
class DClass;
|
||||||
|
|
||||||
|
class QMT_EXPORT DInheritance : public DRelation
|
||||||
class QMT_EXPORT DInheritance :
|
|
||||||
public DRelation
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DInheritance();
|
DInheritance();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Uid derived() const;
|
Uid derived() const;
|
||||||
|
|
||||||
void setDerived(const Uid &derived);
|
void setDerived(const Uid &derived);
|
||||||
|
|
||||||
Uid base() const;
|
Uid base() const;
|
||||||
|
|
||||||
void setBase(const Uid &base);
|
void setBase(const Uid &base);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DINHERITANCE_H
|
#endif // QMT_DINHERITANCE_H
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DItem::DItem()
|
DItem::DItem()
|
||||||
|
|||||||
20
src/libs/3rdparty/modeling/qmt/diagram/ditem.h
vendored
20
src/libs/3rdparty/modeling/qmt/diagram/ditem.h
vendored
@@ -33,46 +33,28 @@
|
|||||||
|
|
||||||
#include "dobject.h"
|
#include "dobject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DItem :
|
class QMT_EXPORT DItem : public DObject
|
||||||
public DObject
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DItem();
|
DItem();
|
||||||
|
|
||||||
~DItem();
|
~DItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QString variety() const { return m_variety; }
|
QString variety() const { return m_variety; }
|
||||||
|
|
||||||
void setVariety(const QString &variety);
|
void setVariety(const QString &variety);
|
||||||
|
|
||||||
QString shape() const { return m_shape; }
|
QString shape() const { return m_shape; }
|
||||||
|
|
||||||
void setShape(const QString &shape);
|
void setShape(const QString &shape);
|
||||||
|
|
||||||
bool isShapeEditable() const { return m_isShapeEditable; }
|
bool isShapeEditable() const { return m_isShapeEditable; }
|
||||||
|
|
||||||
void setShapeEditable(bool shapeEditable);
|
void setShapeEditable(bool shapeEditable);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString m_variety;
|
QString m_variety;
|
||||||
|
|
||||||
QString m_shape;
|
QString m_shape;
|
||||||
|
|
||||||
bool m_isShapeEditable;
|
bool m_isShapeEditable;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace qmt
|
} // namespace qmt
|
||||||
|
|||||||
@@ -158,4 +158,4 @@ void DObject::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDObject(this);
|
visitor->visitDObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
53
src/libs/3rdparty/modeling/qmt/diagram/dobject.h
vendored
53
src/libs/3rdparty/modeling/qmt/diagram/dobject.h
vendored
@@ -39,17 +39,13 @@
|
|||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class MObject;
|
class MObject;
|
||||||
|
|
||||||
|
class QMT_EXPORT DObject : public DElement
|
||||||
class QMT_EXPORT DObject :
|
|
||||||
public DElement
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum VisualPrimaryRole {
|
enum VisualPrimaryRole {
|
||||||
PrimaryRoleNormal,
|
PrimaryRoleNormal,
|
||||||
DeprecatedPrimaryRoleLighter,
|
DeprecatedPrimaryRoleLighter,
|
||||||
@@ -79,100 +75,55 @@ public:
|
|||||||
StereotypeSmart
|
StereotypeSmart
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
DObject();
|
DObject();
|
||||||
|
|
||||||
DObject(const DObject &);
|
DObject(const DObject &);
|
||||||
|
|
||||||
~DObject();
|
~DObject();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DObject &operator=(const DObject &rhs);
|
DObject &operator=(const DObject &rhs);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Uid modelUid() const { return m_modelUid; }
|
Uid modelUid() const { return m_modelUid; }
|
||||||
|
|
||||||
void setModelUid(const Uid &uid);
|
void setModelUid(const Uid &uid);
|
||||||
|
|
||||||
QList<QString> stereotypes() const { return m_stereotypes; }
|
QList<QString> stereotypes() const { return m_stereotypes; }
|
||||||
|
|
||||||
void setStereotypes(const QList<QString> &stereotypes);
|
void setStereotypes(const QList<QString> &stereotypes);
|
||||||
|
|
||||||
QString context() const { return m_context; }
|
QString context() const { return m_context; }
|
||||||
|
|
||||||
void setContext(const QString &context);
|
void setContext(const QString &context);
|
||||||
|
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
|
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
QPointF pos() const { return m_pos; }
|
QPointF pos() const { return m_pos; }
|
||||||
|
|
||||||
void setPos(const QPointF &pos);
|
void setPos(const QPointF &pos);
|
||||||
|
|
||||||
QRectF rect() const { return m_rect; }
|
QRectF rect() const { return m_rect; }
|
||||||
|
|
||||||
void setRect(const QRectF &rect);
|
void setRect(const QRectF &rect);
|
||||||
|
|
||||||
int depth() const { return m_depth; }
|
int depth() const { return m_depth; }
|
||||||
|
|
||||||
void setDepth(int depth);
|
void setDepth(int depth);
|
||||||
|
|
||||||
VisualPrimaryRole visualPrimaryRole() const { return m_visualPrimaryRole; }
|
VisualPrimaryRole visualPrimaryRole() const { return m_visualPrimaryRole; }
|
||||||
|
|
||||||
void setVisualPrimaryRole(VisualPrimaryRole visualPrimaryRole);
|
void setVisualPrimaryRole(VisualPrimaryRole visualPrimaryRole);
|
||||||
|
|
||||||
VisualSecondaryRole visualSecondaryRole() const { return m_visualSecondaryRole; }
|
VisualSecondaryRole visualSecondaryRole() const { return m_visualSecondaryRole; }
|
||||||
|
|
||||||
void setVisualSecondaryRole(VisualSecondaryRole visualSecondaryRole);
|
void setVisualSecondaryRole(VisualSecondaryRole visualSecondaryRole);
|
||||||
|
|
||||||
StereotypeDisplay stereotypeDisplay() const { return m_stereotypeDisplay; }
|
StereotypeDisplay stereotypeDisplay() const { return m_stereotypeDisplay; }
|
||||||
|
|
||||||
void setStereotypeDisplay(StereotypeDisplay stereotypeDisplay);
|
void setStereotypeDisplay(StereotypeDisplay stereotypeDisplay);
|
||||||
|
|
||||||
bool isAutoSized() const { return m_isAutoSized; }
|
bool isAutoSized() const { return m_isAutoSized; }
|
||||||
|
|
||||||
void setAutoSized(bool autoSized);
|
void setAutoSized(bool autoSized);
|
||||||
|
|
||||||
bool isVisualEmphasized() const { return m_isVisualEmphasized; }
|
bool isVisualEmphasized() const { return m_isVisualEmphasized; }
|
||||||
|
|
||||||
void setVisualEmphasized(bool visualEmphasized);
|
void setVisualEmphasized(bool visualEmphasized);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Uid m_modelUid;
|
Uid m_modelUid;
|
||||||
|
|
||||||
QList<QString> m_stereotypes;
|
QList<QString> m_stereotypes;
|
||||||
|
|
||||||
QString m_context;
|
QString m_context;
|
||||||
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
QPointF m_pos;
|
QPointF m_pos;
|
||||||
|
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
|
|
||||||
int m_depth;
|
int m_depth;
|
||||||
|
|
||||||
VisualPrimaryRole m_visualPrimaryRole;
|
VisualPrimaryRole m_visualPrimaryRole;
|
||||||
|
|
||||||
VisualSecondaryRole m_visualSecondaryRole;
|
VisualSecondaryRole m_visualSecondaryRole;
|
||||||
|
|
||||||
StereotypeDisplay m_stereotypeDisplay;
|
StereotypeDisplay m_stereotypeDisplay;
|
||||||
|
|
||||||
bool m_isAutoSized;
|
bool m_isAutoSized;
|
||||||
|
|
||||||
bool m_isVisualEmphasized;
|
bool m_isVisualEmphasized;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DOBJECT_H
|
#endif // QMT_DOBJECT_H
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DPackage::DPackage()
|
DPackage::DPackage()
|
||||||
@@ -50,4 +49,4 @@ void DPackage::accept(DConstVisitor *visitor) const
|
|||||||
visitor->visitDPackage(this);
|
visitor->visitDPackage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -35,20 +35,15 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DPackage :
|
class QMT_EXPORT DPackage : public DObject
|
||||||
public DObject
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DPackage();
|
DPackage();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void accept(DVisitor *visitor);
|
virtual void accept(DVisitor *visitor);
|
||||||
|
|
||||||
virtual void accept(DConstVisitor *visitor) const;
|
virtual void accept(DConstVisitor *visitor) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DPACKAGE_H
|
#endif // QMT_DPACKAGE_H
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "dvisitor.h"
|
#include "dvisitor.h"
|
||||||
#include "dconstvisitor.h"
|
#include "dconstvisitor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DRelation::IntermediatePoint::IntermediatePoint(const QPointF &pos)
|
DRelation::IntermediatePoint::IntermediatePoint(const QPointF &pos)
|
||||||
@@ -51,7 +50,6 @@ bool operator==(const DRelation::IntermediatePoint &lhs, const DRelation::Interm
|
|||||||
return lhs.pos() == rhs.pos();
|
return lhs.pos() == rhs.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DRelation::DRelation()
|
DRelation::DRelation()
|
||||||
: DElement(),
|
: DElement(),
|
||||||
m_modelUid(Uid::invalidUid()),
|
m_modelUid(Uid::invalidUid()),
|
||||||
@@ -94,4 +92,4 @@ void DRelation::setIntermediatePoints(const QList<DRelation::IntermediatePoint>
|
|||||||
m_intermediatePoints = intermediatePoints;
|
m_intermediatePoints = intermediatePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -36,84 +36,53 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
|
|
||||||
class DObject;
|
class DObject;
|
||||||
|
|
||||||
|
class QMT_EXPORT DRelation : public DElement
|
||||||
class QMT_EXPORT DRelation :
|
|
||||||
public DElement
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
class IntermediatePoint
|
||||||
class IntermediatePoint {
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit IntermediatePoint(const QPointF &pos = QPointF());
|
explicit IntermediatePoint(const QPointF &pos = QPointF());
|
||||||
|
|
||||||
QPointF pos() const { return m_pos; }
|
QPointF pos() const { return m_pos; }
|
||||||
|
|
||||||
void setPos(const QPointF &pos);
|
void setPos(const QPointF &pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF m_pos;
|
QPointF m_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
DRelation();
|
DRelation();
|
||||||
|
|
||||||
~DRelation();
|
~DRelation();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Uid modelUid() const { return m_modelUid; }
|
Uid modelUid() const { return m_modelUid; }
|
||||||
|
|
||||||
void setModelUid(const Uid &uid);
|
void setModelUid(const Uid &uid);
|
||||||
|
|
||||||
QList<QString> stereotypes() const { return m_stereotypes; }
|
QList<QString> stereotypes() const { return m_stereotypes; }
|
||||||
|
|
||||||
void setStereotypes(const QList<QString> &stereotypes);
|
void setStereotypes(const QList<QString> &stereotypes);
|
||||||
|
|
||||||
Uid endAUid() const { return m_endAUid; }
|
Uid endAUid() const { return m_endAUid; }
|
||||||
|
|
||||||
void setEndAUid(const Uid &uid);
|
void setEndAUid(const Uid &uid);
|
||||||
|
|
||||||
Uid endBUid() const { return m_endBUid; }
|
Uid endBUid() const { return m_endBUid; }
|
||||||
|
|
||||||
void setEndBUid(const Uid &uid);
|
void setEndBUid(const Uid &uid);
|
||||||
|
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
|
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
QList<IntermediatePoint> intermediatePoints() const { return m_intermediatePoints; }
|
QList<IntermediatePoint> intermediatePoints() const { return m_intermediatePoints; }
|
||||||
|
|
||||||
void setIntermediatePoints(const QList<IntermediatePoint> &intermediatePoints);
|
void setIntermediatePoints(const QList<IntermediatePoint> &intermediatePoints);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Uid m_modelUid;
|
Uid m_modelUid;
|
||||||
|
|
||||||
QList<QString> m_stereotypes;
|
QList<QString> m_stereotypes;
|
||||||
|
|
||||||
Uid m_endAUid;
|
Uid m_endAUid;
|
||||||
|
|
||||||
Uid m_endBUid;
|
Uid m_endBUid;
|
||||||
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
QList<IntermediatePoint> m_intermediatePoints;
|
QList<IntermediatePoint> m_intermediatePoints;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const DRelation::IntermediatePoint &lhs, const DRelation::IntermediatePoint &rhs);
|
bool operator==(const DRelation::IntermediatePoint &lhs, const DRelation::IntermediatePoint &rhs);
|
||||||
|
|
||||||
inline bool operator!=(const DRelation::IntermediatePoint &lhs, const DRelation::IntermediatePoint &rhs) { return !(lhs == rhs); }
|
inline bool operator!=(const DRelation::IntermediatePoint &lhs, const DRelation::IntermediatePoint &rhs) { return !(lhs == rhs); }
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
|
|
||||||
#endif // QMT_DRELATION_H
|
#endif // QMT_DRELATION_H
|
||||||
|
|||||||
@@ -53,32 +53,20 @@ public:
|
|||||||
virtual ~DVisitor() { }
|
virtual ~DVisitor() { }
|
||||||
|
|
||||||
virtual void visitDElement(DElement *element) = 0;
|
virtual void visitDElement(DElement *element) = 0;
|
||||||
|
|
||||||
virtual void visitDObject(DObject *object) = 0;
|
virtual void visitDObject(DObject *object) = 0;
|
||||||
|
|
||||||
virtual void visitDPackage(DPackage *package) = 0;
|
virtual void visitDPackage(DPackage *package) = 0;
|
||||||
|
|
||||||
virtual void visitDClass(DClass *klass) = 0;
|
virtual void visitDClass(DClass *klass) = 0;
|
||||||
|
|
||||||
virtual void visitDComponent(DComponent *component) = 0;
|
virtual void visitDComponent(DComponent *component) = 0;
|
||||||
|
|
||||||
virtual void visitDDiagram(DDiagram *diagram) = 0;
|
virtual void visitDDiagram(DDiagram *diagram) = 0;
|
||||||
|
|
||||||
virtual void visitDItem(DItem *item) = 0;
|
virtual void visitDItem(DItem *item) = 0;
|
||||||
|
|
||||||
virtual void visitDRelation(DRelation *relation) = 0;
|
virtual void visitDRelation(DRelation *relation) = 0;
|
||||||
|
|
||||||
virtual void visitDInheritance(DInheritance *inheritance) = 0;
|
virtual void visitDInheritance(DInheritance *inheritance) = 0;
|
||||||
|
|
||||||
virtual void visitDDependency(DDependency *dependency) = 0;
|
virtual void visitDDependency(DDependency *dependency) = 0;
|
||||||
|
|
||||||
virtual void visitDAssociation(DAssociation *association) = 0;
|
virtual void visitDAssociation(DAssociation *association) = 0;
|
||||||
|
|
||||||
virtual void visitDAnnotation(DAnnotation *annotation) = 0;
|
virtual void visitDAnnotation(DAnnotation *annotation) = 0;
|
||||||
|
|
||||||
virtual void visitDBoundary(DBoundary *boundary) = 0;
|
virtual void visitDBoundary(DBoundary *boundary) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DVISITOR_H
|
#endif // QMT_DVISITOR_H
|
||||||
|
|||||||
@@ -45,10 +45,8 @@
|
|||||||
#include "qmt/diagram/dboundary.h"
|
#include "qmt/diagram/dboundary.h"
|
||||||
#include "qmt/infrastructure/qmtassert.h"
|
#include "qmt/infrastructure/qmtassert.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
|
|
||||||
DCloneVisitor::DCloneVisitor()
|
DCloneVisitor::DCloneVisitor()
|
||||||
: m_cloned(0)
|
: m_cloned(0)
|
||||||
{
|
{
|
||||||
@@ -68,41 +66,36 @@ void DCloneVisitor::visitDObject(const DObject *object)
|
|||||||
|
|
||||||
void DCloneVisitor::visitDPackage(const DPackage *package)
|
void DCloneVisitor::visitDPackage(const DPackage *package)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DPackage(*package);
|
m_cloned = new DPackage(*package);
|
||||||
}
|
|
||||||
visitDObject(package);
|
visitDObject(package);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneVisitor::visitDClass(const DClass *klass)
|
void DCloneVisitor::visitDClass(const DClass *klass)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DClass(*klass);
|
m_cloned = new DClass(*klass);
|
||||||
}
|
|
||||||
visitDObject(klass);
|
visitDObject(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneVisitor::visitDComponent(const DComponent *component)
|
void DCloneVisitor::visitDComponent(const DComponent *component)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DComponent(*component);
|
m_cloned = new DComponent(*component);
|
||||||
}
|
|
||||||
visitDObject(component);
|
visitDObject(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneVisitor::visitDDiagram(const DDiagram *diagram)
|
void DCloneVisitor::visitDDiagram(const DDiagram *diagram)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DDiagram(*diagram);
|
m_cloned = new DDiagram(*diagram);
|
||||||
}
|
|
||||||
visitDObject(diagram);
|
visitDObject(diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneVisitor::visitDItem(const DItem *item)
|
void DCloneVisitor::visitDItem(const DItem *item)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DItem(*item);
|
m_cloned = new DItem(*item);
|
||||||
}
|
|
||||||
visitDObject(item);
|
visitDObject(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -115,45 +108,39 @@ void DCloneVisitor::visitDRelation(const DRelation *relation)
|
|||||||
|
|
||||||
void DCloneVisitor::visitDInheritance(const DInheritance *inheritance)
|
void DCloneVisitor::visitDInheritance(const DInheritance *inheritance)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DInheritance(*inheritance);
|
m_cloned = new DInheritance(*inheritance);
|
||||||
}
|
|
||||||
visitDRelation(inheritance);
|
visitDRelation(inheritance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneVisitor::visitDDependency(const DDependency *dependency)
|
void DCloneVisitor::visitDDependency(const DDependency *dependency)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DDependency(*dependency);
|
m_cloned = new DDependency(*dependency);
|
||||||
}
|
|
||||||
visitDRelation(dependency);
|
visitDRelation(dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneVisitor::visitDAssociation(const DAssociation *association)
|
void DCloneVisitor::visitDAssociation(const DAssociation *association)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DAssociation(*association);
|
m_cloned = new DAssociation(*association);
|
||||||
}
|
|
||||||
visitDRelation(association);
|
visitDRelation(association);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneVisitor::visitDAnnotation(const DAnnotation *annotation)
|
void DCloneVisitor::visitDAnnotation(const DAnnotation *annotation)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DAnnotation(*annotation);
|
m_cloned = new DAnnotation(*annotation);
|
||||||
}
|
|
||||||
visitDElement(annotation);
|
visitDElement(annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneVisitor::visitDBoundary(const DBoundary *boundary)
|
void DCloneVisitor::visitDBoundary(const DBoundary *boundary)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DBoundary(*boundary);
|
m_cloned = new DBoundary(*boundary);
|
||||||
}
|
|
||||||
visitDElement(boundary);
|
visitDElement(boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DCloneDeepVisitor::DCloneDeepVisitor()
|
DCloneDeepVisitor::DCloneDeepVisitor()
|
||||||
: m_cloned(0)
|
: m_cloned(0)
|
||||||
{
|
{
|
||||||
@@ -173,41 +160,36 @@ void DCloneDeepVisitor::visitDObject(const DObject *object)
|
|||||||
|
|
||||||
void DCloneDeepVisitor::visitDPackage(const DPackage *package)
|
void DCloneDeepVisitor::visitDPackage(const DPackage *package)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DPackage(*package);
|
m_cloned = new DPackage(*package);
|
||||||
}
|
|
||||||
visitDObject(package);
|
visitDObject(package);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneDeepVisitor::visitDClass(const DClass *klass)
|
void DCloneDeepVisitor::visitDClass(const DClass *klass)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DClass(*klass);
|
m_cloned = new DClass(*klass);
|
||||||
}
|
|
||||||
visitDObject(klass);
|
visitDObject(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneDeepVisitor::visitDComponent(const DComponent *component)
|
void DCloneDeepVisitor::visitDComponent(const DComponent *component)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DComponent(*component);
|
m_cloned = new DComponent(*component);
|
||||||
}
|
|
||||||
visitDObject(component);
|
visitDObject(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneDeepVisitor::visitDDiagram(const DDiagram *diagram)
|
void DCloneDeepVisitor::visitDDiagram(const DDiagram *diagram)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DDiagram(*diagram);
|
m_cloned = new DDiagram(*diagram);
|
||||||
}
|
|
||||||
visitDObject(diagram);
|
visitDObject(diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneDeepVisitor::visitDItem(const DItem *item)
|
void DCloneDeepVisitor::visitDItem(const DItem *item)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DItem(*item);
|
m_cloned = new DItem(*item);
|
||||||
}
|
|
||||||
visitDObject(item);
|
visitDObject(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,42 +201,37 @@ void DCloneDeepVisitor::visitDRelation(const DRelation *relation)
|
|||||||
|
|
||||||
void DCloneDeepVisitor::visitDInheritance(const DInheritance *inheritance)
|
void DCloneDeepVisitor::visitDInheritance(const DInheritance *inheritance)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DInheritance(*inheritance);
|
m_cloned = new DInheritance(*inheritance);
|
||||||
}
|
|
||||||
visitDRelation(inheritance);
|
visitDRelation(inheritance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneDeepVisitor::visitDDependency(const DDependency *dependency)
|
void DCloneDeepVisitor::visitDDependency(const DDependency *dependency)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DDependency(*dependency);
|
m_cloned = new DDependency(*dependency);
|
||||||
}
|
|
||||||
visitDRelation(dependency);
|
visitDRelation(dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneDeepVisitor::visitDAssociation(const DAssociation *association)
|
void DCloneDeepVisitor::visitDAssociation(const DAssociation *association)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DAssociation(*association);
|
m_cloned = new DAssociation(*association);
|
||||||
}
|
|
||||||
visitDRelation(association);
|
visitDRelation(association);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneDeepVisitor::visitDAnnotation(const DAnnotation *annotation)
|
void DCloneDeepVisitor::visitDAnnotation(const DAnnotation *annotation)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DAnnotation(*annotation);
|
m_cloned = new DAnnotation(*annotation);
|
||||||
}
|
|
||||||
visitDElement(annotation);
|
visitDElement(annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCloneDeepVisitor::visitDBoundary(const DBoundary *boundary)
|
void DCloneDeepVisitor::visitDBoundary(const DBoundary *boundary)
|
||||||
{
|
{
|
||||||
if (!m_cloned) {
|
if (!m_cloned)
|
||||||
m_cloned = new DBoundary(*boundary);
|
m_cloned = new DBoundary(*boundary);
|
||||||
}
|
|
||||||
visitDElement(boundary);
|
visitDElement(boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -34,91 +34,58 @@
|
|||||||
#include "qmt/diagram/dconstvisitor.h"
|
#include "qmt/diagram/dconstvisitor.h"
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
#include <qglobal.h>
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DCloneVisitor :
|
class QMT_EXPORT DCloneVisitor : public DConstVisitor
|
||||||
public DConstVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DCloneVisitor();
|
DCloneVisitor();
|
||||||
|
|
||||||
public:
|
|
||||||
DElement *cloned() const { return m_cloned; }
|
DElement *cloned() const { return m_cloned; }
|
||||||
|
|
||||||
void visitDElement(const DElement *element);
|
void visitDElement(const DElement *element);
|
||||||
|
|
||||||
void visitDObject(const DObject *object);
|
void visitDObject(const DObject *object);
|
||||||
|
|
||||||
void visitDPackage(const DPackage *package);
|
void visitDPackage(const DPackage *package);
|
||||||
|
|
||||||
void visitDClass(const DClass *klass);
|
void visitDClass(const DClass *klass);
|
||||||
|
|
||||||
void visitDComponent(const DComponent *component);
|
void visitDComponent(const DComponent *component);
|
||||||
|
|
||||||
void visitDDiagram(const DDiagram *diagram);
|
void visitDDiagram(const DDiagram *diagram);
|
||||||
|
|
||||||
void visitDItem(const DItem *item);
|
void visitDItem(const DItem *item);
|
||||||
|
|
||||||
void visitDRelation(const DRelation *relation);
|
void visitDRelation(const DRelation *relation);
|
||||||
|
|
||||||
void visitDInheritance(const DInheritance *inheritance);
|
void visitDInheritance(const DInheritance *inheritance);
|
||||||
|
|
||||||
void visitDDependency(const DDependency *dependency);
|
void visitDDependency(const DDependency *dependency);
|
||||||
|
|
||||||
void visitDAssociation(const DAssociation *association);
|
void visitDAssociation(const DAssociation *association);
|
||||||
|
|
||||||
void visitDAnnotation(const DAnnotation *annotation);
|
void visitDAnnotation(const DAnnotation *annotation);
|
||||||
|
|
||||||
void visitDBoundary(const DBoundary *boundary);
|
void visitDBoundary(const DBoundary *boundary);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DElement *m_cloned;
|
DElement *m_cloned;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QMT_EXPORT DCloneDeepVisitor : public DConstVisitor
|
||||||
class QMT_EXPORT DCloneDeepVisitor :
|
|
||||||
public DConstVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DCloneDeepVisitor();
|
DCloneDeepVisitor();
|
||||||
|
|
||||||
public:
|
|
||||||
DElement *cloned() const { return m_cloned; }
|
DElement *cloned() const { return m_cloned; }
|
||||||
|
|
||||||
void visitDElement(const DElement *element);
|
void visitDElement(const DElement *element);
|
||||||
|
|
||||||
void visitDObject(const DObject *object);
|
void visitDObject(const DObject *object);
|
||||||
|
|
||||||
void visitDPackage(const DPackage *package);
|
void visitDPackage(const DPackage *package);
|
||||||
|
|
||||||
void visitDClass(const DClass *klass);
|
void visitDClass(const DClass *klass);
|
||||||
|
|
||||||
void visitDComponent(const DComponent *component);
|
void visitDComponent(const DComponent *component);
|
||||||
|
|
||||||
void visitDDiagram(const DDiagram *diagram);
|
void visitDDiagram(const DDiagram *diagram);
|
||||||
|
|
||||||
void visitDItem(const DItem *item);
|
void visitDItem(const DItem *item);
|
||||||
|
|
||||||
void visitDRelation(const DRelation *relation);
|
void visitDRelation(const DRelation *relation);
|
||||||
|
|
||||||
void visitDInheritance(const DInheritance *inheritance);
|
void visitDInheritance(const DInheritance *inheritance);
|
||||||
|
|
||||||
void visitDDependency(const DDependency *dependency);
|
void visitDDependency(const DDependency *dependency);
|
||||||
|
|
||||||
void visitDAssociation(const DAssociation *association);
|
void visitDAssociation(const DAssociation *association);
|
||||||
|
|
||||||
void visitDAnnotation(const DAnnotation *annotation);
|
void visitDAnnotation(const DAnnotation *annotation);
|
||||||
|
|
||||||
void visitDBoundary(const DBoundary *boundary);
|
void visitDBoundary(const DBoundary *boundary);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DElement *m_cloned;
|
DElement *m_cloned;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DCLONEVISITOR_H
|
#endif // QMT_DCLONEVISITOR_H
|
||||||
|
|||||||
@@ -34,14 +34,12 @@
|
|||||||
#include "qmt/controller/container.h"
|
#include "qmt/controller/container.h"
|
||||||
#include "qmt/diagram/delement.h"
|
#include "qmt/diagram/delement.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DContainer :
|
class QMT_EXPORT DContainer : public Container<DElement>
|
||||||
public Container<DElement>
|
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DCONTAINER_H
|
#endif // QMT_DCONTAINER_H
|
||||||
|
|||||||
@@ -55,7 +55,6 @@
|
|||||||
#include "qmt/model/mdependency.h"
|
#include "qmt/model/mdependency.h"
|
||||||
#include "qmt/model/minheritance.h"
|
#include "qmt/model/minheritance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DFactory::DFactory()
|
DFactory::DFactory()
|
||||||
@@ -155,4 +154,4 @@ void DFactory::visitMAssociation(const MAssociation *association)
|
|||||||
visitMRelation(association);
|
visitMRelation(association);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -34,53 +34,34 @@
|
|||||||
#include "qmt/model/mconstvisitor.h"
|
#include "qmt/model/mconstvisitor.h"
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
#include <qglobal.h>
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DElement;
|
class DElement;
|
||||||
|
|
||||||
class QMT_EXPORT DFactory :
|
class QMT_EXPORT DFactory : public MConstVisitor
|
||||||
public MConstVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DFactory();
|
DFactory();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DElement *product() const { return m_product; }
|
DElement *product() const { return m_product; }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void visitMElement(const MElement *element);
|
void visitMElement(const MElement *element);
|
||||||
|
|
||||||
void visitMObject(const MObject *object);
|
void visitMObject(const MObject *object);
|
||||||
|
|
||||||
void visitMPackage(const MPackage *package);
|
void visitMPackage(const MPackage *package);
|
||||||
|
|
||||||
void visitMClass(const MClass *klass);
|
void visitMClass(const MClass *klass);
|
||||||
|
|
||||||
void visitMComponent(const MComponent *component);
|
void visitMComponent(const MComponent *component);
|
||||||
|
|
||||||
void visitMDiagram(const MDiagram *diagram);
|
void visitMDiagram(const MDiagram *diagram);
|
||||||
|
|
||||||
void visitMCanvasDiagram(const MCanvasDiagram *diagram);
|
void visitMCanvasDiagram(const MCanvasDiagram *diagram);
|
||||||
|
|
||||||
void visitMItem(const MItem *item);
|
void visitMItem(const MItem *item);
|
||||||
|
|
||||||
void visitMRelation(const MRelation *relation);
|
void visitMRelation(const MRelation *relation);
|
||||||
|
|
||||||
void visitMDependency(const MDependency *dependency);
|
void visitMDependency(const MDependency *dependency);
|
||||||
|
|
||||||
void visitMInheritance(const MInheritance *inheritance);
|
void visitMInheritance(const MInheritance *inheritance);
|
||||||
|
|
||||||
void visitMAssociation(const MAssociation *association);
|
void visitMAssociation(const MAssociation *association);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DElement *m_product;
|
DElement *m_product;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DFACTORY_H
|
#endif // QMT_DFACTORY_H
|
||||||
|
|||||||
@@ -169,4 +169,4 @@ void DFlatAssignmentVisitor::visitDBoundary(const DBoundary *boundary)
|
|||||||
target->setRect(boundary->rect());
|
target->setRect(boundary->rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -34,49 +34,31 @@
|
|||||||
#include "qmt/diagram/dconstvisitor.h"
|
#include "qmt/diagram/dconstvisitor.h"
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DFlatAssignmentVisitor :
|
class QMT_EXPORT DFlatAssignmentVisitor : public DConstVisitor
|
||||||
public DConstVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DFlatAssignmentVisitor(DElement *target);
|
DFlatAssignmentVisitor(DElement *target);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void visitDElement(const DElement *element);
|
void visitDElement(const DElement *element);
|
||||||
|
|
||||||
void visitDObject(const DObject *object);
|
void visitDObject(const DObject *object);
|
||||||
|
|
||||||
void visitDPackage(const DPackage *package);
|
void visitDPackage(const DPackage *package);
|
||||||
|
|
||||||
void visitDClass(const DClass *klass);
|
void visitDClass(const DClass *klass);
|
||||||
|
|
||||||
void visitDComponent(const DComponent *component);
|
void visitDComponent(const DComponent *component);
|
||||||
|
|
||||||
void visitDDiagram(const DDiagram *diagram);
|
void visitDDiagram(const DDiagram *diagram);
|
||||||
|
|
||||||
void visitDItem(const DItem *item);
|
void visitDItem(const DItem *item);
|
||||||
|
|
||||||
void visitDRelation(const DRelation *relation);
|
void visitDRelation(const DRelation *relation);
|
||||||
|
|
||||||
void visitDInheritance(const DInheritance *inheritance);
|
void visitDInheritance(const DInheritance *inheritance);
|
||||||
|
|
||||||
void visitDDependency(const DDependency *dependency);
|
void visitDDependency(const DDependency *dependency);
|
||||||
|
|
||||||
void visitDAssociation(const DAssociation *association);
|
void visitDAssociation(const DAssociation *association);
|
||||||
|
|
||||||
void visitDAnnotation(const DAnnotation *annotation);
|
void visitDAnnotation(const DAnnotation *annotation);
|
||||||
|
|
||||||
void visitDBoundary(const DBoundary *boundary);
|
void visitDBoundary(const DBoundary *boundary);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DElement *m_target;
|
DElement *m_target;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DFLATASSIGNMENTVISITOR_H
|
#endif // QMT_DFLATASSIGNMENTVISITOR_H
|
||||||
|
|||||||
@@ -51,7 +51,6 @@
|
|||||||
#include "qmt/model/mdiagram.h"
|
#include "qmt/model/mdiagram.h"
|
||||||
#include "qmt/model/mrelation.h"
|
#include "qmt/model/mrelation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DiagramController::Clone
|
class DiagramController::Clone
|
||||||
@@ -69,11 +68,9 @@ DiagramController::Clone::Clone()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class DiagramController::DiagramUndoCommand :
|
class DiagramController::DiagramUndoCommand : public UndoCommand
|
||||||
public UndoCommand
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DiagramUndoCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &text)
|
DiagramUndoCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &text)
|
||||||
: UndoCommand(text),
|
: UndoCommand(text),
|
||||||
m_diagramController(diagramController),
|
m_diagramController(diagramController),
|
||||||
@@ -82,7 +79,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DiagramController *diagramController() const
|
DiagramController *diagramController() const
|
||||||
{
|
{
|
||||||
return m_diagramController;
|
return m_diagramController;
|
||||||
@@ -98,15 +94,11 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DiagramController *m_diagramController;
|
DiagramController *m_diagramController;
|
||||||
|
|
||||||
Uid m_diagramKey;
|
Uid m_diagramKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DiagramController::UpdateElementCommand : public DiagramUndoCommand
|
||||||
class DiagramController::UpdateElementCommand :
|
|
||||||
public DiagramUndoCommand
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UpdateElementCommand(DiagramController *diagramController, const Uid &diagramKey, DElement *element,
|
UpdateElementCommand(DiagramController *diagramController, const Uid &diagramKey, DElement *element,
|
||||||
@@ -127,12 +119,10 @@ public:
|
|||||||
bool mergeWith(const UndoCommand *other)
|
bool mergeWith(const UndoCommand *other)
|
||||||
{
|
{
|
||||||
const UpdateElementCommand *otherUpdateCommand = dynamic_cast<const UpdateElementCommand *>(other);
|
const UpdateElementCommand *otherUpdateCommand = dynamic_cast<const UpdateElementCommand *>(other);
|
||||||
if (!otherUpdateCommand) {
|
if (!otherUpdateCommand)
|
||||||
return false;
|
return false;
|
||||||
}
|
if (diagramKey() != otherUpdateCommand->diagramKey())
|
||||||
if (diagramKey() != otherUpdateCommand->diagramKey()) {
|
|
||||||
return false;
|
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) {
|
|| m_updateAction != otherUpdateCommand->m_updateAction) {
|
||||||
return false;
|
return false;
|
||||||
@@ -189,16 +179,11 @@ private:
|
|||||||
diagramController->diagramModified(diagram);
|
diagramController->diagramModified(diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DiagramController::UpdateAction m_updateAction;
|
DiagramController::UpdateAction m_updateAction;
|
||||||
|
|
||||||
QHash<Uid, DElement *> m_clonedElements;
|
QHash<Uid, DElement *> m_clonedElements;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DiagramController::AbstractAddRemCommand : public DiagramUndoCommand
|
||||||
class DiagramController::AbstractAddRemCommand :
|
|
||||||
public DiagramUndoCommand
|
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
AbstractAddRemCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
AbstractAddRemCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
||||||
@@ -208,9 +193,8 @@ protected:
|
|||||||
|
|
||||||
~AbstractAddRemCommand()
|
~AbstractAddRemCommand()
|
||||||
{
|
{
|
||||||
foreach (const Clone &clone, m_clonedElements) {
|
foreach (const Clone &clone, m_clonedElements)
|
||||||
delete clone.m_clonedElement;
|
delete clone.m_clonedElement;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove()
|
void remove()
|
||||||
@@ -233,9 +217,8 @@ protected:
|
|||||||
emit diagramController->endRemoveElement(clone.m_indexOfElement, diagram);
|
emit diagramController->endRemoveElement(clone.m_indexOfElement, diagram);
|
||||||
removed = true;
|
removed = true;
|
||||||
}
|
}
|
||||||
if (removed) {
|
if (removed)
|
||||||
diagramController->diagramModified(diagram);
|
diagramController->diagramModified(diagram);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert()
|
void insert()
|
||||||
@@ -253,19 +236,14 @@ protected:
|
|||||||
emit diagramController->endInsertElement(clone.m_indexOfElement, diagram);
|
emit diagramController->endInsertElement(clone.m_indexOfElement, diagram);
|
||||||
inserted = true;
|
inserted = true;
|
||||||
}
|
}
|
||||||
if (inserted) {
|
if (inserted)
|
||||||
diagramController->diagramModified(diagram);
|
diagramController->diagramModified(diagram);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
QList<Clone> m_clonedElements;
|
QList<Clone> m_clonedElements;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiagramController::AddElementsCommand :
|
class DiagramController::AddElementsCommand : public AbstractAddRemCommand
|
||||||
public AbstractAddRemCommand
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AddElementsCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
AddElementsCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
||||||
@@ -296,9 +274,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DiagramController::RemoveElementsCommand : public AbstractAddRemCommand
|
||||||
class DiagramController::RemoveElementsCommand :
|
|
||||||
public AbstractAddRemCommand
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RemoveElementsCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
RemoveElementsCommand(DiagramController *diagramController, const Uid &diagramKey, const QString &commandLabel)
|
||||||
@@ -336,12 +312,9 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DiagramController::FindDiagramsVisitor : public MChildrenVisitor
|
||||||
class DiagramController::FindDiagramsVisitor :
|
|
||||||
public MChildrenVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FindDiagramsVisitor(QList<MDiagram *> *allDiagrams)
|
FindDiagramsVisitor(QList<MDiagram *> *allDiagrams)
|
||||||
: m_allDiagrams(allDiagrams)
|
: m_allDiagrams(allDiagrams)
|
||||||
{
|
{
|
||||||
@@ -354,11 +327,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QList<MDiagram *> *m_allDiagrams;
|
QList<MDiagram *> *m_allDiagrams;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DiagramController::DiagramController(QObject *parent)
|
DiagramController::DiagramController(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_modelController(0),
|
m_modelController(0),
|
||||||
@@ -456,9 +427,8 @@ DElement *DiagramController::findDelegate(const MElement *modelElement, const MD
|
|||||||
{
|
{
|
||||||
// PERFORM use map to increase performance
|
// PERFORM use map to increase performance
|
||||||
foreach (DElement *diagramElement, diagram->diagramElements()) {
|
foreach (DElement *diagramElement, diagram->diagramElements()) {
|
||||||
if (diagramElement->modelUid().isValid() && diagramElement->modelUid() == modelElement->uid()) {
|
if (diagramElement->modelUid().isValid() && diagramElement->modelUid() == modelElement->uid())
|
||||||
return diagramElement;
|
return diagramElement;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -466,20 +436,17 @@ DElement *DiagramController::findDelegate(const MElement *modelElement, const MD
|
|||||||
void DiagramController::startUpdateElement(DElement *element, MDiagram *diagram, UpdateAction updateAction)
|
void DiagramController::startUpdateElement(DElement *element, MDiagram *diagram, UpdateAction updateAction)
|
||||||
{
|
{
|
||||||
emit beginUpdateElement(diagram->diagramElements().indexOf(element), diagram);
|
emit beginUpdateElement(diagram->diagramElements().indexOf(element), diagram);
|
||||||
if (m_undoController) {
|
if (m_undoController)
|
||||||
m_undoController->push(new UpdateElementCommand(this, diagram->uid(), element, updateAction));
|
m_undoController->push(new UpdateElementCommand(this, diagram->uid(), element, updateAction));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::finishUpdateElement(DElement *element, MDiagram *diagram, bool cancelled)
|
void DiagramController::finishUpdateElement(DElement *element, MDiagram *diagram, bool cancelled)
|
||||||
{
|
{
|
||||||
if (!cancelled) {
|
if (!cancelled)
|
||||||
updateElementFromModel(element, diagram, false);
|
updateElementFromModel(element, diagram, false);
|
||||||
}
|
|
||||||
emit endUpdateElement(diagram->diagramElements().indexOf(element), diagram);
|
emit endUpdateElement(diagram->diagramElements().indexOf(element), diagram);
|
||||||
if (!cancelled) {
|
if (!cancelled)
|
||||||
diagramModified(diagram);
|
diagramModified(diagram);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::breakUndoChain()
|
void DiagramController::breakUndoChain()
|
||||||
@@ -528,13 +495,11 @@ void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagr
|
|||||||
// fix all keys referencing between pasting elements
|
// fix all keys referencing between pasting elements
|
||||||
foreach(DElement *clonedElement, clonedElements) {
|
foreach(DElement *clonedElement, clonedElements) {
|
||||||
DRelation *relation = dynamic_cast<DRelation *>(clonedElement);
|
DRelation *relation = dynamic_cast<DRelation *>(clonedElement);
|
||||||
if (relation) {
|
if (relation)
|
||||||
updateRelationKeys(relation, renewedKeys);
|
updateRelationKeys(relation, renewedKeys);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (m_undoController) {
|
if (m_undoController)
|
||||||
m_undoController->beginMergeSequence(tr("Paste"));
|
m_undoController->beginMergeSequence(tr("Paste"));
|
||||||
}
|
|
||||||
// insert all elements
|
// insert all elements
|
||||||
bool added = false;
|
bool added = false;
|
||||||
foreach (DElement *clonedElement, clonedElements) {
|
foreach (DElement *clonedElement, clonedElements) {
|
||||||
@@ -566,12 +531,10 @@ void DiagramController::pasteElements(const DContainer &diagramContainer, MDiagr
|
|||||||
added = true;
|
added = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (added) {
|
if (added)
|
||||||
diagramModified(diagram);
|
diagramModified(diagram);
|
||||||
}
|
if (m_undoController)
|
||||||
if (m_undoController) {
|
|
||||||
m_undoController->endMergeSequence();
|
m_undoController->endMergeSequence();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram)
|
void DiagramController::deleteElements(const DSelection &diagramSelection, MDiagram *diagram)
|
||||||
@@ -593,15 +556,13 @@ void DiagramController::onEndResetModel()
|
|||||||
foreach (DElement *element, diagram->diagramElements()) {
|
foreach (DElement *element, diagram->diagramElements()) {
|
||||||
if (element->modelUid().isValid()) {
|
if (element->modelUid().isValid()) {
|
||||||
MElement *modelElement = m_modelController->findElement(element->modelUid());
|
MElement *modelElement = m_modelController->findElement(element->modelUid());
|
||||||
if (!modelElement) {
|
if (!modelElement)
|
||||||
removeElement(element, diagram);
|
removeElement(element, diagram);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update all remaining elements from model
|
// update all remaining elements from model
|
||||||
foreach (DElement *element, diagram->diagramElements()) {
|
foreach (DElement *element, diagram->diagramElements())
|
||||||
updateElementFromModel(element, diagram, false);
|
updateElementFromModel(element, diagram, false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
emit endResetAllDiagrams();
|
emit endResetAllDiagrams();
|
||||||
}
|
}
|
||||||
@@ -629,9 +590,8 @@ void DiagramController::onEndUpdateObject(int row, const MObject *parent)
|
|||||||
foreach (DElement *diagramElement, diagram->diagramElements()) {
|
foreach (DElement *diagramElement, diagram->diagramElements()) {
|
||||||
if (diagramElement->modelUid().isValid()) {
|
if (diagramElement->modelUid().isValid()) {
|
||||||
MObject *mobject = m_modelController->findObject(diagramElement->modelUid());
|
MObject *mobject = m_modelController->findObject(diagramElement->modelUid());
|
||||||
if (mobject && mobject->owner() == modelPackage) {
|
if (mobject && mobject->owner() == modelPackage)
|
||||||
updateElementFromModel(diagramElement, diagram, true);
|
updateElementFromModel(diagramElement, diagram, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -673,7 +633,6 @@ void DiagramController::onBeginMoveObject(int formerRow, const MObject *formerOw
|
|||||||
{
|
{
|
||||||
Q_UNUSED(formerRow);
|
Q_UNUSED(formerRow);
|
||||||
Q_UNUSED(formerOwner);
|
Q_UNUSED(formerOwner);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::onEndMoveObject(int row, const MObject *owner)
|
void DiagramController::onEndMoveObject(int row, const MObject *owner)
|
||||||
@@ -686,9 +645,8 @@ void DiagramController::onEndMoveObject(int row, const MObject *owner)
|
|||||||
MDiagram *modelDiagram = dynamic_cast<MDiagram *>(modelObject);
|
MDiagram *modelDiagram = dynamic_cast<MDiagram *>(modelObject);
|
||||||
if (modelDiagram) {
|
if (modelDiagram) {
|
||||||
emit beginResetDiagram(modelDiagram);
|
emit beginResetDiagram(modelDiagram);
|
||||||
foreach (DElement *diagramElement, modelDiagram->diagramElements()) {
|
foreach (DElement *diagramElement, modelDiagram->diagramElements())
|
||||||
updateElementFromModel(diagramElement, modelDiagram, false);
|
updateElementFromModel(diagramElement, modelDiagram, false);
|
||||||
}
|
|
||||||
emit endResetDiagram(modelDiagram);
|
emit endResetDiagram(modelDiagram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -744,12 +702,10 @@ void DiagramController::deleteElements(const DSelection &diagramSelection, MDiag
|
|||||||
QMT_CHECK(diagram);
|
QMT_CHECK(diagram);
|
||||||
|
|
||||||
DReferences simplifiedSelection = simplify(diagramSelection, diagram);
|
DReferences simplifiedSelection = simplify(diagramSelection, diagram);
|
||||||
if (simplifiedSelection.elements().isEmpty()) {
|
if (simplifiedSelection.elements().isEmpty())
|
||||||
return;
|
return;
|
||||||
}
|
if (m_undoController)
|
||||||
if (m_undoController) {
|
|
||||||
m_undoController->beginMergeSequence(commandLabel);
|
m_undoController->beginMergeSequence(commandLabel);
|
||||||
}
|
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
foreach (DElement *element, simplifiedSelection.elements()) {
|
foreach (DElement *element, simplifiedSelection.elements()) {
|
||||||
// element may have been deleted indirectly by predecessor element in loop
|
// element may have been deleted indirectly by predecessor element in loop
|
||||||
@@ -767,21 +723,18 @@ void DiagramController::deleteElements(const DSelection &diagramSelection, MDiag
|
|||||||
removed = true;
|
removed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (removed) {
|
if (removed)
|
||||||
diagramModified(diagram);
|
diagramModified(diagram);
|
||||||
}
|
if (m_undoController)
|
||||||
if (m_undoController) {
|
|
||||||
m_undoController->endMergeSequence();
|
m_undoController->endMergeSequence();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DElement *DiagramController::findElementOnAnyDiagram(const Uid &uid)
|
DElement *DiagramController::findElementOnAnyDiagram(const Uid &uid)
|
||||||
{
|
{
|
||||||
foreach (MDiagram *diagram, m_allDiagrams) {
|
foreach (MDiagram *diagram, m_allDiagrams) {
|
||||||
DElement *element = findElement(uid, diagram);
|
DElement *element = findElement(uid, diagram);
|
||||||
if (element) {
|
if (element)
|
||||||
return element;
|
return element;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -790,20 +743,17 @@ void DiagramController::removeObjects(MObject *modelObject)
|
|||||||
{
|
{
|
||||||
foreach (MDiagram *diagram, m_allDiagrams) {
|
foreach (MDiagram *diagram, m_allDiagrams) {
|
||||||
DElement *diagramElement = findDelegate(modelObject, diagram);
|
DElement *diagramElement = findDelegate(modelObject, diagram);
|
||||||
if (diagramElement) {
|
if (diagramElement)
|
||||||
removeElement(diagramElement, diagram);
|
removeElement(diagramElement, diagram);
|
||||||
}
|
|
||||||
foreach (const Handle<MRelation> &relation, modelObject->relations()) {
|
foreach (const Handle<MRelation> &relation, modelObject->relations()) {
|
||||||
DElement *diagramElement = findDelegate(relation.target(), diagram);
|
DElement *diagramElement = findDelegate(relation.target(), diagram);
|
||||||
if (diagramElement) {
|
if (diagramElement)
|
||||||
removeElement(diagramElement, diagram);
|
removeElement(diagramElement, diagram);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (const Handle<MObject> &object, modelObject->children()) {
|
foreach (const Handle<MObject> &object, modelObject->children()) {
|
||||||
if (object.hasTarget()) {
|
if (object.hasTarget())
|
||||||
removeObjects(object.target());
|
removeObjects(object.target());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (MDiagram *diagram = dynamic_cast<MDiagram *>(modelObject)) {
|
if (MDiagram *diagram = dynamic_cast<MDiagram *>(modelObject)) {
|
||||||
emit diagramAboutToBeRemoved(diagram);
|
emit diagramAboutToBeRemoved(diagram);
|
||||||
@@ -822,9 +772,8 @@ void DiagramController::removeRelations(MRelation *modelRelation)
|
|||||||
{
|
{
|
||||||
foreach (MDiagram *diagram, m_allDiagrams) {
|
foreach (MDiagram *diagram, m_allDiagrams) {
|
||||||
DElement *diagramElement = findDelegate(modelRelation, diagram);
|
DElement *diagramElement = findDelegate(modelRelation, diagram);
|
||||||
if (diagramElement) {
|
if (diagramElement)
|
||||||
removeElement(diagramElement, diagram);
|
removeElement(diagramElement, diagram);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -834,9 +783,8 @@ void DiagramController::removeRelations(DElement *element, MDiagram *diagram)
|
|||||||
if (diagramObject) {
|
if (diagramObject) {
|
||||||
foreach (DElement *diagramElement, diagram->diagramElements()) {
|
foreach (DElement *diagramElement, diagram->diagramElements()) {
|
||||||
if (DRelation *diagramRelation = dynamic_cast<DRelation *>(diagramElement)) {
|
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);
|
removeElement(diagramRelation, diagram);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -861,20 +809,17 @@ void DiagramController::renewElementKey(DElement *element, QHash<Uid, Uid> *rene
|
|||||||
void DiagramController::updateRelationKeys(DRelation *relation, const QHash<Uid, Uid> &renewedKeys)
|
void DiagramController::updateRelationKeys(DRelation *relation, const QHash<Uid, Uid> &renewedKeys)
|
||||||
{
|
{
|
||||||
Uid newEndAKey = renewedKeys.value(relation->endAUid(), Uid::invalidUid());
|
Uid newEndAKey = renewedKeys.value(relation->endAUid(), Uid::invalidUid());
|
||||||
if (newEndAKey.isValid()) {
|
if (newEndAKey.isValid())
|
||||||
relation->setEndAUid(newEndAKey);
|
relation->setEndAUid(newEndAKey);
|
||||||
}
|
|
||||||
Uid newEndBKey = renewedKeys.value(relation->endBUid(), Uid::invalidUid());
|
Uid newEndBKey = renewedKeys.value(relation->endBUid(), Uid::invalidUid());
|
||||||
if (newEndBKey.isValid()) {
|
if (newEndBKey.isValid())
|
||||||
relation->setEndBUid(newEndBKey);
|
relation->setEndBUid(newEndBKey);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramController::updateElementFromModel(DElement *element, const MDiagram *diagram, bool emitUpdateSignal)
|
void DiagramController::updateElementFromModel(DElement *element, const MDiagram *diagram, bool emitUpdateSignal)
|
||||||
{
|
{
|
||||||
if (!element->modelUid().isValid()) {
|
if (!element->modelUid().isValid())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
DUpdateVisitor visitor(element, diagram);
|
DUpdateVisitor visitor(element, diagram);
|
||||||
|
|
||||||
@@ -908,27 +853,24 @@ DReferences DiagramController::simplify(const DSelection &diagramSelection, cons
|
|||||||
DReferences references;
|
DReferences references;
|
||||||
foreach (const DSelection::Index &index, diagramSelection.indices()) {
|
foreach (const DSelection::Index &index, diagramSelection.indices()) {
|
||||||
DElement *element = findElement(index.elementKey(), diagram);
|
DElement *element = findElement(index.elementKey(), diagram);
|
||||||
if (element) {
|
if (element)
|
||||||
references.append(element);
|
references.append(element);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return references;
|
return references;
|
||||||
}
|
}
|
||||||
|
|
||||||
MElement *DiagramController::delegatedElement(const DElement *element) const
|
MElement *DiagramController::delegatedElement(const DElement *element) const
|
||||||
{
|
{
|
||||||
if (!element->modelUid().isValid()) {
|
if (!element->modelUid().isValid())
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
return m_modelController->findElement(element->modelUid());
|
return m_modelController->findElement(element->modelUid());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramController::isDelegatedElementOnDiagram(const DElement *element, const MDiagram *diagram) const
|
bool DiagramController::isDelegatedElementOnDiagram(const DElement *element, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
MElement *modelElement = delegatedElement(element);
|
MElement *modelElement = delegatedElement(element);
|
||||||
if (!modelElement) {
|
if (!modelElement)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return hasDelegate(modelElement, diagram);
|
return hasDelegate(modelElement, diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -946,4 +888,4 @@ void DiagramController::updateAllDiagramsList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -36,33 +36,25 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class UndoController;
|
class UndoController;
|
||||||
|
|
||||||
class ModelController;
|
class ModelController;
|
||||||
|
|
||||||
class MElement;
|
class MElement;
|
||||||
class MObject;
|
class MObject;
|
||||||
class MDiagram;
|
class MDiagram;
|
||||||
class MRelation;
|
class MRelation;
|
||||||
|
|
||||||
class DSelection;
|
class DSelection;
|
||||||
class DContainer;
|
class DContainer;
|
||||||
class DReferences;
|
class DReferences;
|
||||||
|
|
||||||
class DElement;
|
class DElement;
|
||||||
class DRelation;
|
class DRelation;
|
||||||
|
|
||||||
|
class QMT_EXPORT DiagramController : public QObject
|
||||||
class QMT_EXPORT DiagramController :
|
|
||||||
public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum UpdateAction {
|
enum UpdateAction {
|
||||||
UpdateGeometry, // update only position and size of element
|
UpdateGeometry, // update only position and size of element
|
||||||
UpdateMajor, // a major update of the element which will create a separate undo command
|
UpdateMajor, // a major update of the element which will create a separate undo command
|
||||||
@@ -70,9 +62,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class Clone;
|
class Clone;
|
||||||
|
|
||||||
class DiagramUndoCommand;
|
class DiagramUndoCommand;
|
||||||
class UpdateElementCommand;
|
class UpdateElementCommand;
|
||||||
class AbstractAddRemCommand;
|
class AbstractAddRemCommand;
|
||||||
@@ -81,66 +71,42 @@ private:
|
|||||||
class FindDiagramsVisitor;
|
class FindDiagramsVisitor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit DiagramController(QObject *parent = 0);
|
explicit DiagramController(QObject *parent = 0);
|
||||||
|
|
||||||
~DiagramController();
|
~DiagramController();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void beginResetAllDiagrams();
|
void beginResetAllDiagrams();
|
||||||
|
|
||||||
void endResetAllDiagrams();
|
void endResetAllDiagrams();
|
||||||
|
|
||||||
void beginResetDiagram(const MDiagram *diagram);
|
void beginResetDiagram(const MDiagram *diagram);
|
||||||
|
|
||||||
void endResetDiagram(const MDiagram *diagram);
|
void endResetDiagram(const MDiagram *diagram);
|
||||||
|
|
||||||
void beginUpdateElement(int row, const MDiagram *diagram);
|
void beginUpdateElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void endUpdateElement(int row, const MDiagram *diagram);
|
void endUpdateElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void beginInsertElement(int row, const MDiagram *diagram);
|
void beginInsertElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void endInsertElement(int row, const MDiagram *diagram);
|
void endInsertElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void beginRemoveElement(int row, const MDiagram *diagram);
|
void beginRemoveElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void endRemoveElement(int row, const MDiagram *diagram);
|
void endRemoveElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void modified(const MDiagram *diagram);
|
void modified(const MDiagram *diagram);
|
||||||
|
|
||||||
void diagramAboutToBeRemoved(const MDiagram *diagram);
|
void diagramAboutToBeRemoved(const MDiagram *diagram);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ModelController *modelController() const { return m_modelController; }
|
ModelController *modelController() const { return m_modelController; }
|
||||||
|
|
||||||
void setModelController(ModelController *modelController);
|
void setModelController(ModelController *modelController);
|
||||||
|
|
||||||
UndoController *undoController() const { return m_undoController; }
|
UndoController *undoController() const { return m_undoController; }
|
||||||
|
|
||||||
void setUndoController(UndoController *undoController);
|
void setUndoController(UndoController *undoController);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MDiagram *findDiagram(const Uid &diagramKey) const;
|
MDiagram *findDiagram(const Uid &diagramKey) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void addElement(DElement *element, MDiagram *diagram);
|
void addElement(DElement *element, MDiagram *diagram);
|
||||||
|
|
||||||
void removeElement(DElement *element, MDiagram *diagram);
|
void removeElement(DElement *element, MDiagram *diagram);
|
||||||
|
|
||||||
DElement *findElement(const Uid &key, const MDiagram *diagram) const;
|
DElement *findElement(const Uid &key, const MDiagram *diagram) const;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T *findElement(const Uid &key, const MDiagram *diagram) const { return dynamic_cast<T *>(findElement(key, diagram)); }
|
T *findElement(const Uid &key, const MDiagram *diagram) const { return dynamic_cast<T *>(findElement(key, diagram)); }
|
||||||
|
|
||||||
bool hasDelegate(const MElement *modelElement, const MDiagram *diagram) const;
|
bool hasDelegate(const MElement *modelElement, const MDiagram *diagram) const;
|
||||||
|
|
||||||
DElement *findDelegate(const MElement *modelElement, const MDiagram *diagram) const;
|
DElement *findDelegate(const MElement *modelElement, const MDiagram *diagram) const;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T *findDelegate(const MElement *modelElement, const MDiagram *diagram) const
|
T *findDelegate(const MElement *modelElement, const MDiagram *diagram) const
|
||||||
{
|
{
|
||||||
@@ -148,71 +114,44 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void startUpdateElement(DElement *element, MDiagram *diagram, UpdateAction updateAction);
|
void startUpdateElement(DElement *element, MDiagram *diagram, UpdateAction updateAction);
|
||||||
|
|
||||||
void finishUpdateElement(DElement *element, MDiagram *diagram, bool cancelled);
|
void finishUpdateElement(DElement *element, MDiagram *diagram, bool cancelled);
|
||||||
|
|
||||||
void breakUndoChain();
|
void breakUndoChain();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DContainer cutElements(const DSelection &diagramSelection, MDiagram *diagram);
|
DContainer cutElements(const DSelection &diagramSelection, MDiagram *diagram);
|
||||||
|
|
||||||
DContainer copyElements(const DSelection &diagramSelection, const MDiagram *diagram);
|
DContainer copyElements(const DSelection &diagramSelection, const MDiagram *diagram);
|
||||||
|
|
||||||
void pasteElements(const DContainer &diagramContainer, MDiagram *diagram);
|
void pasteElements(const DContainer &diagramContainer, MDiagram *diagram);
|
||||||
|
|
||||||
void deleteElements(const DSelection &diagramSelection, MDiagram *diagram);
|
void deleteElements(const DSelection &diagramSelection, MDiagram *diagram);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onBeginResetModel();
|
void onBeginResetModel();
|
||||||
|
|
||||||
void onEndResetModel();
|
void onEndResetModel();
|
||||||
|
|
||||||
void onBeginUpdateObject(int row, const MObject *parent);
|
void onBeginUpdateObject(int row, const MObject *parent);
|
||||||
|
|
||||||
void onEndUpdateObject(int row, const MObject *parent);
|
void onEndUpdateObject(int row, const MObject *parent);
|
||||||
|
|
||||||
void onBeginInsertObject(int row, const MObject *owner);
|
void onBeginInsertObject(int row, const MObject *owner);
|
||||||
|
|
||||||
void onEndInsertObject(int row, const MObject *owner);
|
void onEndInsertObject(int row, const MObject *owner);
|
||||||
|
|
||||||
void onBeginRemoveObject(int row, const MObject *parent);
|
void onBeginRemoveObject(int row, const MObject *parent);
|
||||||
|
|
||||||
void onEndRemoveObject(int row, const MObject *parent);
|
void onEndRemoveObject(int row, const MObject *parent);
|
||||||
|
|
||||||
void onBeginMoveObject(int formerRow, const MObject *formerOwner);
|
void onBeginMoveObject(int formerRow, const MObject *formerOwner);
|
||||||
|
|
||||||
void onEndMoveObject(int row, const MObject *owner);
|
void onEndMoveObject(int row, const MObject *owner);
|
||||||
|
|
||||||
void onBeginUpdateRelation(int row, const MObject *owner);
|
void onBeginUpdateRelation(int row, const MObject *owner);
|
||||||
|
|
||||||
void onEndUpdateRelation(int row, const MObject *owner);
|
void onEndUpdateRelation(int row, const MObject *owner);
|
||||||
|
|
||||||
void onBeginRemoveRelation(int row, const MObject *owner);
|
void onBeginRemoveRelation(int row, const MObject *owner);
|
||||||
|
|
||||||
void onEndRemoveRelation(int row, const MObject *owner);
|
void onEndRemoveRelation(int row, const MObject *owner);
|
||||||
|
|
||||||
void onBeginMoveRelation(int formerRow, const MObject *formerOwner);
|
void onBeginMoveRelation(int formerRow, const MObject *formerOwner);
|
||||||
|
|
||||||
void onEndMoveRelation(int row, const MObject *owner);
|
void onEndMoveRelation(int row, const MObject *owner);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void deleteElements(const DSelection &diagramSelection, MDiagram *diagram, const QString &commandLabel);
|
void deleteElements(const DSelection &diagramSelection, MDiagram *diagram, const QString &commandLabel);
|
||||||
|
|
||||||
DElement *findElementOnAnyDiagram(const Uid &uid);
|
DElement *findElementOnAnyDiagram(const Uid &uid);
|
||||||
|
|
||||||
void removeObjects(MObject *modelObject);
|
void removeObjects(MObject *modelObject);
|
||||||
|
|
||||||
void removeRelations(MRelation *modelRelation);
|
void removeRelations(MRelation *modelRelation);
|
||||||
|
|
||||||
void removeRelations(DElement *element, MDiagram *diagram);
|
void removeRelations(DElement *element, MDiagram *diagram);
|
||||||
|
|
||||||
void renewElementKey(DElement *element, QHash<Uid, Uid> *renewedKeys);
|
void renewElementKey(DElement *element, QHash<Uid, Uid> *renewedKeys);
|
||||||
|
|
||||||
void updateRelationKeys(DRelation *relation, const QHash<Uid, Uid> &renewedKeys);
|
void updateRelationKeys(DRelation *relation, const QHash<Uid, Uid> &renewedKeys);
|
||||||
|
|
||||||
void updateElementFromModel(DElement *element, const MDiagram *diagram, bool emitUpdateSignal);
|
void updateElementFromModel(DElement *element, const MDiagram *diagram, bool emitUpdateSignal);
|
||||||
|
|
||||||
void diagramModified(MDiagram *diagram);
|
void diagramModified(MDiagram *diagram);
|
||||||
@@ -220,22 +159,16 @@ private:
|
|||||||
DReferences simplify(const DSelection &diagramSelection, const MDiagram *diagram);
|
DReferences simplify(const DSelection &diagramSelection, const MDiagram *diagram);
|
||||||
|
|
||||||
MElement *delegatedElement(const DElement *element) const;
|
MElement *delegatedElement(const DElement *element) const;
|
||||||
|
|
||||||
bool isDelegatedElementOnDiagram(const DElement *element, const MDiagram *diagram) const;
|
bool isDelegatedElementOnDiagram(const DElement *element, const MDiagram *diagram) const;
|
||||||
|
|
||||||
bool areRelationEndsOnDiagram(const DRelation *relation, const MDiagram *diagram) const;
|
bool areRelationEndsOnDiagram(const DRelation *relation, const MDiagram *diagram) const;
|
||||||
|
|
||||||
void updateAllDiagramsList();
|
void updateAllDiagramsList();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
ModelController *m_modelController;
|
ModelController *m_modelController;
|
||||||
|
|
||||||
UndoController *m_undoController;
|
UndoController *m_undoController;
|
||||||
|
|
||||||
QList<MDiagram *> m_allDiagrams;
|
QList<MDiagram *> m_allDiagrams;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // DIAGRAMCONTROLLER_H
|
#endif // DIAGRAMCONTROLLER_H
|
||||||
|
|||||||
@@ -34,16 +34,14 @@
|
|||||||
#include "qmt/controller/references.h"
|
#include "qmt/controller/references.h"
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DElement;
|
class DElement;
|
||||||
|
|
||||||
class QMT_EXPORT DReferences :
|
class QMT_EXPORT DReferences : public References<DElement>
|
||||||
public References<DElement>
|
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DREFERENCES_H
|
#endif // QMT_DREFERENCES_H
|
||||||
|
|||||||
@@ -34,14 +34,12 @@
|
|||||||
#include "qmt/controller/selection.h"
|
#include "qmt/controller/selection.h"
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DSelection :
|
class QMT_EXPORT DSelection : public Selection
|
||||||
public Selection
|
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DSELECTION_H
|
#endif // QMT_DSELECTION_H
|
||||||
|
|||||||
@@ -51,7 +51,6 @@
|
|||||||
#include "qmt/model/mdependency.h"
|
#include "qmt/model/mdependency.h"
|
||||||
#include "qmt/model/minheritance.h"
|
#include "qmt/model/minheritance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DUpdateVisitor::DUpdateVisitor(DElement *target, const MDiagram *diagram, bool checkNeedsUpdate)
|
DUpdateVisitor::DUpdateVisitor(DElement *target, const MDiagram *diagram, bool checkNeedsUpdate)
|
||||||
@@ -79,23 +78,19 @@ void DUpdateVisitor::visitMObject(const MObject *object)
|
|||||||
{
|
{
|
||||||
DObject *dobject = dynamic_cast<DObject *>(m_target);
|
DObject *dobject = dynamic_cast<DObject *>(m_target);
|
||||||
QMT_CHECK(dobject);
|
QMT_CHECK(dobject);
|
||||||
if (isUpdating(object->stereotypes() != dobject->stereotypes())) {
|
if (isUpdating(object->stereotypes() != dobject->stereotypes()))
|
||||||
dobject->setStereotypes(object->stereotypes());
|
dobject->setStereotypes(object->stereotypes());
|
||||||
}
|
|
||||||
const MObject *objectOwner = object->owner();
|
const MObject *objectOwner = object->owner();
|
||||||
const MObject *diagramOwner = m_diagram->owner();
|
const MObject *diagramOwner = m_diagram->owner();
|
||||||
if (objectOwner && diagramOwner && objectOwner->uid() != diagramOwner->uid()) {
|
if (objectOwner && diagramOwner && objectOwner->uid() != diagramOwner->uid()) {
|
||||||
if (isUpdating(objectOwner->name() != dobject->context())) {
|
if (isUpdating(objectOwner->name() != dobject->context()))
|
||||||
dobject->setContext(objectOwner->name());
|
dobject->setContext(objectOwner->name());
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (isUpdating(!dobject->context().isEmpty())) {
|
if (isUpdating(!dobject->context().isEmpty()))
|
||||||
dobject->setContext(QString());
|
dobject->setContext(QString());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isUpdating(object->name() != dobject->name())) {
|
if (isUpdating(object->name() != dobject->name()))
|
||||||
dobject->setName(object->name());
|
dobject->setName(object->name());
|
||||||
}
|
|
||||||
// TODO unlikely that this is called for all objects if hierarchy is modified
|
// TODO unlikely that this is called for all objects if hierarchy is modified
|
||||||
// PERFORM remove loop
|
// PERFORM remove loop
|
||||||
int depth = 1;
|
int depth = 1;
|
||||||
@@ -104,9 +99,8 @@ void DUpdateVisitor::visitMObject(const MObject *object)
|
|||||||
owner = owner->owner();
|
owner = owner->owner();
|
||||||
depth += 1;
|
depth += 1;
|
||||||
}
|
}
|
||||||
if (isUpdating(depth != dobject->depth())) {
|
if (isUpdating(depth != dobject->depth()))
|
||||||
dobject->setDepth(depth);
|
dobject->setDepth(depth);
|
||||||
}
|
|
||||||
visitMElement(object);
|
visitMElement(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,15 +113,12 @@ void DUpdateVisitor::visitMClass(const MClass *klass)
|
|||||||
{
|
{
|
||||||
DClass *dclass = dynamic_cast<DClass *>(m_target);
|
DClass *dclass = dynamic_cast<DClass *>(m_target);
|
||||||
QMT_CHECK(dclass);
|
QMT_CHECK(dclass);
|
||||||
if (isUpdating(klass->umlNamespace() != dclass->umlNamespace())) {
|
if (isUpdating(klass->umlNamespace() != dclass->umlNamespace()))
|
||||||
dclass->setUmlNamespace(klass->umlNamespace());
|
dclass->setUmlNamespace(klass->umlNamespace());
|
||||||
}
|
if (isUpdating(klass->templateParameters() != dclass->templateParameters()))
|
||||||
if (isUpdating(klass->templateParameters() != dclass->templateParameters())) {
|
|
||||||
dclass->setTemplateParameters(klass->templateParameters());
|
dclass->setTemplateParameters(klass->templateParameters());
|
||||||
}
|
if (isUpdating(klass->members() != dclass->members()))
|
||||||
if (isUpdating(klass->members() != dclass->members())) {
|
|
||||||
dclass->setMembers(klass->members());
|
dclass->setMembers(klass->members());
|
||||||
}
|
|
||||||
visitMObject(klass);
|
visitMObject(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,12 +141,10 @@ void DUpdateVisitor::visitMItem(const MItem *item)
|
|||||||
{
|
{
|
||||||
DItem *ditem = dynamic_cast<DItem *>(m_target);
|
DItem *ditem = dynamic_cast<DItem *>(m_target);
|
||||||
QMT_CHECK(ditem);
|
QMT_CHECK(ditem);
|
||||||
if (isUpdating(item->isShapeEditable() != ditem->isShapeEditable())) {
|
if (isUpdating(item->isShapeEditable() != ditem->isShapeEditable()))
|
||||||
ditem->setShapeEditable(item->isShapeEditable());
|
ditem->setShapeEditable(item->isShapeEditable());
|
||||||
}
|
if (isUpdating(item->variety() != ditem->variety()))
|
||||||
if (isUpdating(item->variety() != ditem->variety())) {
|
|
||||||
ditem->setVariety(item->variety());
|
ditem->setVariety(item->variety());
|
||||||
}
|
|
||||||
visitMObject(item);
|
visitMObject(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,12 +152,10 @@ void DUpdateVisitor::visitMRelation(const MRelation *relation)
|
|||||||
{
|
{
|
||||||
DRelation *drelation = dynamic_cast<DRelation *>(m_target);
|
DRelation *drelation = dynamic_cast<DRelation *>(m_target);
|
||||||
QMT_CHECK(drelation);
|
QMT_CHECK(drelation);
|
||||||
if (isUpdating(relation->stereotypes() != drelation->stereotypes())) {
|
if (isUpdating(relation->stereotypes() != drelation->stereotypes()))
|
||||||
drelation->setStereotypes(relation->stereotypes());
|
drelation->setStereotypes(relation->stereotypes());
|
||||||
}
|
if (isUpdating(relation->name() != drelation->name()))
|
||||||
if (isUpdating(relation->name() != drelation->name())) {
|
|
||||||
drelation->setName(relation->name());
|
drelation->setName(relation->name());
|
||||||
}
|
|
||||||
visitMElement(relation);
|
visitMElement(relation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +163,8 @@ void DUpdateVisitor::visitMDependency(const MDependency *dependency)
|
|||||||
{
|
{
|
||||||
DDependency *ddependency = dynamic_cast<DDependency *>(m_target);
|
DDependency *ddependency = dynamic_cast<DDependency *>(m_target);
|
||||||
QMT_CHECK(ddependency);
|
QMT_CHECK(ddependency);
|
||||||
if (isUpdating(dependency->direction() != ddependency->direction())) {
|
if (isUpdating(dependency->direction() != ddependency->direction()))
|
||||||
ddependency->setDirection(dependency->direction());
|
ddependency->setDirection(dependency->direction());
|
||||||
}
|
|
||||||
visitMRelation(dependency);
|
visitMRelation(dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,29 +182,26 @@ void DUpdateVisitor::visitMAssociation(const MAssociation *association)
|
|||||||
endA.setCardinatlity(association->endA().cardinality());
|
endA.setCardinatlity(association->endA().cardinality());
|
||||||
endA.setNavigable(association->endA().isNavigable());
|
endA.setNavigable(association->endA().isNavigable());
|
||||||
endA.setKind(association->endA().kind());
|
endA.setKind(association->endA().kind());
|
||||||
if (isUpdating(endA != dassociation->endA())) {
|
if (isUpdating(endA != dassociation->endA()))
|
||||||
dassociation->setEndA(endA);
|
dassociation->setEndA(endA);
|
||||||
}
|
|
||||||
DAssociationEnd endB;
|
DAssociationEnd endB;
|
||||||
endB.setName(association->endB().name());
|
endB.setName(association->endB().name());
|
||||||
endB.setCardinatlity(association->endB().cardinality());
|
endB.setCardinatlity(association->endB().cardinality());
|
||||||
endB.setNavigable(association->endB().isNavigable());
|
endB.setNavigable(association->endB().isNavigable());
|
||||||
endB.setKind(association->endB().kind());
|
endB.setKind(association->endB().kind());
|
||||||
if (isUpdating(endB != dassociation->endB())) {
|
if (isUpdating(endB != dassociation->endB()))
|
||||||
dassociation->setEndB(endB);
|
dassociation->setEndB(endB);
|
||||||
}
|
|
||||||
visitMRelation(association);
|
visitMRelation(association);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DUpdateVisitor::isUpdating(bool valueChanged)
|
bool DUpdateVisitor::isUpdating(bool valueChanged)
|
||||||
{
|
{
|
||||||
if (m_checkNeedsUpdate) {
|
if (m_checkNeedsUpdate) {
|
||||||
if (valueChanged) {
|
if (valueChanged)
|
||||||
m_isUpdateNeeded = true;
|
m_isUpdateNeeded = true;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return valueChanged;
|
return valueChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -34,63 +34,40 @@
|
|||||||
#include "qmt/model/mconstvisitor.h"
|
#include "qmt/model/mconstvisitor.h"
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DElement;
|
class DElement;
|
||||||
|
|
||||||
|
class QMT_EXPORT DUpdateVisitor : public MConstVisitor
|
||||||
class QMT_EXPORT DUpdateVisitor :
|
|
||||||
public MConstVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DUpdateVisitor(DElement *target, const MDiagram *diagram, bool checkNeedsUpdate = false);
|
DUpdateVisitor(DElement *target, const MDiagram *diagram, bool checkNeedsUpdate = false);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isUpdateNeeded() const { return m_isUpdateNeeded; }
|
bool isUpdateNeeded() const { return m_isUpdateNeeded; }
|
||||||
|
|
||||||
void setCheckNeedsUpdate(bool checkNeedsUpdate);
|
void setCheckNeedsUpdate(bool checkNeedsUpdate);
|
||||||
|
|
||||||
void visitMElement(const MElement *element);
|
void visitMElement(const MElement *element);
|
||||||
|
|
||||||
void visitMObject(const MObject *object);
|
void visitMObject(const MObject *object);
|
||||||
|
|
||||||
void visitMPackage(const MPackage *package);
|
void visitMPackage(const MPackage *package);
|
||||||
|
|
||||||
void visitMClass(const MClass *klass);
|
void visitMClass(const MClass *klass);
|
||||||
|
|
||||||
void visitMComponent(const MComponent *component);
|
void visitMComponent(const MComponent *component);
|
||||||
|
|
||||||
void visitMDiagram(const MDiagram *diagram);
|
void visitMDiagram(const MDiagram *diagram);
|
||||||
|
|
||||||
void visitMCanvasDiagram(const MCanvasDiagram *diagram);
|
void visitMCanvasDiagram(const MCanvasDiagram *diagram);
|
||||||
|
|
||||||
void visitMItem(const MItem *item);
|
void visitMItem(const MItem *item);
|
||||||
|
|
||||||
void visitMRelation(const MRelation *relation);
|
void visitMRelation(const MRelation *relation);
|
||||||
|
|
||||||
void visitMDependency(const MDependency *dependency);
|
void visitMDependency(const MDependency *dependency);
|
||||||
|
|
||||||
void visitMInheritance(const MInheritance *inheritance);
|
void visitMInheritance(const MInheritance *inheritance);
|
||||||
|
|
||||||
void visitMAssociation(const MAssociation *association);
|
void visitMAssociation(const MAssociation *association);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool isUpdating(bool valueChanged);
|
bool isUpdating(bool valueChanged);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DElement *m_target;
|
DElement *m_target;
|
||||||
|
|
||||||
const MDiagram *m_diagram;
|
const MDiagram *m_diagram;
|
||||||
|
|
||||||
bool m_checkNeedsUpdate;
|
bool m_checkNeedsUpdate;
|
||||||
|
|
||||||
bool m_isUpdateNeeded;
|
bool m_isUpdateNeeded;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DUPDATEVISITOR_H
|
#endif // QMT_DUPDATEVISITOR_H
|
||||||
|
|||||||
@@ -115,8 +115,6 @@ void DVoidVisitor::visitDBoundary(DBoundary *boundary)
|
|||||||
visitDElement(boundary);
|
visitDElement(boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DConstVoidVisitor::DConstVoidVisitor()
|
DConstVoidVisitor::DConstVoidVisitor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -186,5 +184,4 @@ void DConstVoidVisitor::visitDBoundary(const DBoundary *boundary)
|
|||||||
visitDElement(boundary);
|
visitDElement(boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
|
|||||||
@@ -35,77 +35,48 @@
|
|||||||
#include "qmt/diagram/dconstvisitor.h"
|
#include "qmt/diagram/dconstvisitor.h"
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DVoidVisitor :
|
class QMT_EXPORT DVoidVisitor : public DVisitor
|
||||||
public DVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DVoidVisitor();
|
DVoidVisitor();
|
||||||
|
|
||||||
void visitDElement(DElement *element);
|
void visitDElement(DElement *element);
|
||||||
|
|
||||||
void visitDObject(DObject *object);
|
void visitDObject(DObject *object);
|
||||||
|
|
||||||
void visitDPackage(DPackage *package);
|
void visitDPackage(DPackage *package);
|
||||||
|
|
||||||
void visitDClass(DClass *klass);
|
void visitDClass(DClass *klass);
|
||||||
|
|
||||||
void visitDComponent(DComponent *component);
|
void visitDComponent(DComponent *component);
|
||||||
|
|
||||||
void visitDDiagram(DDiagram *diagram);
|
void visitDDiagram(DDiagram *diagram);
|
||||||
|
|
||||||
void visitDItem(DItem *item);
|
void visitDItem(DItem *item);
|
||||||
|
|
||||||
void visitDRelation(DRelation *relation);
|
void visitDRelation(DRelation *relation);
|
||||||
|
|
||||||
void visitDInheritance(DInheritance *inheritance);
|
void visitDInheritance(DInheritance *inheritance);
|
||||||
|
|
||||||
void visitDDependency(DDependency *dependency);
|
void visitDDependency(DDependency *dependency);
|
||||||
|
|
||||||
void visitDAssociation(DAssociation *association);
|
void visitDAssociation(DAssociation *association);
|
||||||
|
|
||||||
void visitDAnnotation(DAnnotation *annotation);
|
void visitDAnnotation(DAnnotation *annotation);
|
||||||
|
|
||||||
void visitDBoundary(DBoundary *boundary);
|
void visitDBoundary(DBoundary *boundary);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class QMT_EXPORT DConstVoidVisitor :
|
class QMT_EXPORT DConstVoidVisitor : public DConstVisitor
|
||||||
public DConstVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DConstVoidVisitor();
|
DConstVoidVisitor();
|
||||||
|
|
||||||
void visitDElement(const DElement *element);
|
void visitDElement(const DElement *element);
|
||||||
|
|
||||||
void visitDObject(const DObject *object);
|
void visitDObject(const DObject *object);
|
||||||
|
|
||||||
void visitDPackage(const DPackage *package);
|
void visitDPackage(const DPackage *package);
|
||||||
|
|
||||||
void visitDClass(const DClass *klass);
|
void visitDClass(const DClass *klass);
|
||||||
|
|
||||||
void visitDComponent(const DComponent *component);
|
void visitDComponent(const DComponent *component);
|
||||||
|
|
||||||
void visitDDiagram(const DDiagram *diagram);
|
void visitDDiagram(const DDiagram *diagram);
|
||||||
|
|
||||||
void visitDItem(const DItem *item);
|
void visitDItem(const DItem *item);
|
||||||
|
|
||||||
void visitDRelation(const DRelation *relation);
|
void visitDRelation(const DRelation *relation);
|
||||||
|
|
||||||
void visitDInheritance(const DInheritance *inheritance);
|
void visitDInheritance(const DInheritance *inheritance);
|
||||||
|
|
||||||
void visitDDependency(const DDependency *dependency);
|
void visitDDependency(const DDependency *dependency);
|
||||||
|
|
||||||
void visitDAssociation(const DAssociation *association);
|
void visitDAssociation(const DAssociation *association);
|
||||||
|
|
||||||
void visitDAnnotation(const DAnnotation *annotation);
|
void visitDAnnotation(const DAnnotation *annotation);
|
||||||
|
|
||||||
void visitDBoundary(const DBoundary *boundary);
|
void visitDBoundary(const DBoundary *boundary);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // DVOIDVISITOR_H
|
#endif // DVOIDVISITOR_H
|
||||||
|
|||||||
@@ -33,11 +33,10 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class IAlignable {
|
class IAlignable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
enum AlignType {
|
enum AlignType {
|
||||||
AlignLeft,
|
AlignLeft,
|
||||||
@@ -51,15 +50,11 @@ public:
|
|||||||
AlignSize
|
AlignSize
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ~IAlignable() { }
|
virtual ~IAlignable() { }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void align(AlignType alignType, const QString &identifier) = 0;
|
virtual void align(AlignType alignType, const QString &identifier) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_ALIGNABLE_H
|
#endif // QMT_ALIGNABLE_H
|
||||||
|
|||||||
@@ -33,17 +33,16 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class IEditable {
|
class IEditable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
~IEditable() { }
|
~IEditable() { }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual bool isEditable() const = 0;
|
virtual bool isEditable() const = 0;
|
||||||
|
|
||||||
virtual void edit() = 0;
|
virtual void edit() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_EDITABLE_H
|
#endif // QMT_EDITABLE_H
|
||||||
|
|||||||
@@ -38,18 +38,16 @@ class QPointF;
|
|||||||
class QLineF;
|
class QLineF;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class IIntersectionable {
|
class IIntersectionable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~IIntersectionable() { }
|
virtual ~IIntersectionable() { }
|
||||||
|
|
||||||
virtual bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine = 0) const = 0;
|
virtual bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine = 0) const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_INTERSECTIONABLE_H
|
#endif // QMT_INTERSECTIONABLE_H
|
||||||
|
|||||||
@@ -35,9 +35,9 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class ILatchable {
|
class ILatchable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Action {
|
enum Action {
|
||||||
Move,
|
Move,
|
||||||
ResizeLeft,
|
ResizeLeft,
|
||||||
@@ -83,16 +83,12 @@ public:
|
|||||||
QString m_identifier;
|
QString m_identifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ~ILatchable() { }
|
virtual ~ILatchable() { }
|
||||||
|
|
||||||
virtual QList<Latch> horizontalLatches(Action action, bool grabbedItem) const = 0;
|
virtual QList<Latch> horizontalLatches(Action action, bool grabbedItem) const = 0;
|
||||||
|
|
||||||
virtual QList<Latch> verticalLatches(Action action, bool grabbedItem) const = 0;
|
virtual QList<Latch> verticalLatches(Action action, bool grabbedItem) const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_LATCHABLE_H
|
#endif // QMT_LATCHABLE_H
|
||||||
|
|||||||
@@ -37,18 +37,17 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QPointF;
|
class QPointF;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class IMoveable {
|
class IMoveable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IMoveable() { }
|
virtual ~IMoveable() { }
|
||||||
|
|
||||||
virtual void moveDelta(const QPointF &delta) = 0;
|
virtual void moveDelta(const QPointF &delta) = 0;
|
||||||
|
|
||||||
virtual void alignItemPositionToRaster(double rasterWidth, double rasterHeight) = 0;
|
virtual void alignItemPositionToRaster(double rasterWidth, double rasterHeight) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_MOVEABLE_H
|
#endif // QMT_MOVEABLE_H
|
||||||
|
|||||||
@@ -35,22 +35,20 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QString;
|
class QString;
|
||||||
class QGraphicsItem;
|
|
||||||
class QPointF;
|
class QPointF;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class IRelationable {
|
class IRelationable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IRelationable() { }
|
virtual ~IRelationable() { }
|
||||||
|
|
||||||
virtual QPointF relationStartPos() const = 0;
|
virtual QPointF relationStartPos() const = 0;
|
||||||
|
|
||||||
virtual void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints) = 0;
|
virtual void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_RELATIONABLE_H
|
#endif // QMT_RELATIONABLE_H
|
||||||
|
|||||||
@@ -39,32 +39,27 @@ class QRectF;
|
|||||||
class QSizeF;
|
class QSizeF;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class IResizable {
|
class IResizable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Side {
|
enum Side {
|
||||||
SideNone,
|
SideNone,
|
||||||
SideLeftOrTop,
|
SideLeftOrTop,
|
||||||
SideRightOrBottom
|
SideRightOrBottom
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ~IResizable() { }
|
virtual ~IResizable() { }
|
||||||
|
|
||||||
virtual QPointF pos() const = 0;
|
virtual QPointF pos() const = 0;
|
||||||
|
|
||||||
virtual QRectF rect() const = 0;
|
virtual QRectF rect() const = 0;
|
||||||
|
|
||||||
virtual QSizeF minimumSize() const = 0;
|
virtual QSizeF minimumSize() const = 0;
|
||||||
|
|
||||||
virtual void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta) = 0;
|
virtual void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta) = 0;
|
||||||
|
|
||||||
virtual void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight) = 0;
|
virtual void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_RESIZABLE_H
|
#endif // QMT_RESIZABLE_H
|
||||||
|
|||||||
@@ -33,19 +33,17 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class ISelectable {
|
class ISelectable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ISelectable() { }
|
virtual ~ISelectable() { }
|
||||||
|
|
||||||
virtual bool isSecondarySelected() const = 0;
|
virtual bool isSecondarySelected() const = 0;
|
||||||
|
|
||||||
virtual void setSecondarySelected(bool secondarySelected) = 0;
|
virtual void setSecondarySelected(bool secondarySelected) = 0;
|
||||||
|
|
||||||
virtual bool isFocusSelected() const = 0;
|
virtual bool isFocusSelected() const = 0;
|
||||||
|
|
||||||
virtual void setFocusSelected(bool focusSelected) = 0;
|
virtual void setFocusSelected(bool focusSelected) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_SELECTABLE_H
|
#endif // QMT_SELECTABLE_H
|
||||||
|
|||||||
@@ -37,25 +37,20 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QPointF;
|
class QPointF;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class IWindable {
|
class IWindable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~IWindable() { }
|
virtual ~IWindable() { }
|
||||||
|
|
||||||
virtual QPointF handlePos(int index) = 0;
|
virtual QPointF handlePos(int index) = 0;
|
||||||
|
|
||||||
virtual void insertHandle(int beforeIndex, const QPointF &pos) = 0;
|
virtual void insertHandle(int beforeIndex, const QPointF &pos) = 0;
|
||||||
|
|
||||||
virtual void deleteHandle(int index) = 0;
|
virtual void deleteHandle(int index) = 0;
|
||||||
|
|
||||||
virtual void setHandlePos(int index, const QPointF &pos) = 0;
|
virtual void setHandlePos(int index, const QPointF &pos) = 0;
|
||||||
|
|
||||||
virtual void alignHandleToRaster(int index, double rasterWidth, double rasterHeight) = 0;
|
virtual void alignHandleToRaster(int index, double rasterWidth, double rasterHeight) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_WINDABLE_H
|
#endif // QMT_WINDABLE_H
|
||||||
|
|||||||
@@ -32,9 +32,6 @@
|
|||||||
|
|
||||||
#include "diagramscenemodel.h"
|
#include "diagramscenemodel.h"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DiagramGraphicsScene::DiagramGraphicsScene(DiagramSceneModel *diagramSceneModel, QObject *parent)
|
DiagramGraphicsScene::DiagramGraphicsScene(DiagramSceneModel *diagramSceneModel, QObject *parent)
|
||||||
@@ -141,4 +138,4 @@ void DiagramGraphicsScene::inputMethodEvent(QInputMethodEvent *event)
|
|||||||
QGraphicsScene::inputMethodEvent(event);
|
QGraphicsScene::inputMethodEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -34,69 +34,45 @@
|
|||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include "qmt/infrastructure/qmt_global.h"
|
#include "qmt/infrastructure/qmt_global.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DiagramSceneModel;
|
class DiagramSceneModel;
|
||||||
|
|
||||||
class QMT_EXPORT DiagramGraphicsScene :
|
class QMT_EXPORT DiagramGraphicsScene : public QGraphicsScene
|
||||||
public QGraphicsScene
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DiagramGraphicsScene(DiagramSceneModel *diagramSceneModel, QObject *parent = 0);
|
DiagramGraphicsScene(DiagramSceneModel *diagramSceneModel, QObject *parent = 0);
|
||||||
|
|
||||||
~DiagramGraphicsScene();
|
~DiagramGraphicsScene();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void sceneActivated();
|
void sceneActivated();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event);
|
||||||
|
|
||||||
bool eventFilter(QObject *watched, QEvent *event);
|
bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||||
|
|
||||||
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
|
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
|
||||||
|
|
||||||
void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
|
void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
|
||||||
|
|
||||||
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
|
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
|
||||||
|
|
||||||
void dropEvent(QGraphicsSceneDragDropEvent *event);
|
void dropEvent(QGraphicsSceneDragDropEvent *event);
|
||||||
|
|
||||||
void focusInEvent(QFocusEvent *event);
|
void focusInEvent(QFocusEvent *event);
|
||||||
|
|
||||||
void focusOutEvent(QFocusEvent *event);
|
void focusOutEvent(QFocusEvent *event);
|
||||||
|
|
||||||
void helpEvent(QGraphicsSceneHelpEvent *event);
|
void helpEvent(QGraphicsSceneHelpEvent *event);
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
|
|
||||||
void keyReleaseEvent(QKeyEvent *event);
|
void keyReleaseEvent(QKeyEvent *event);
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void wheelEvent(QGraphicsSceneWheelEvent *event);
|
void wheelEvent(QGraphicsSceneWheelEvent *event);
|
||||||
|
|
||||||
void inputMethodEvent(QInputMethodEvent *event);
|
void inputMethodEvent(QInputMethodEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DiagramSceneModel *m_diagramSceneModel;
|
DiagramSceneModel *m_diagramSceneModel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DIAGRAMGRAPHICSSCENE_H
|
#endif // QMT_DIAGRAMGRAPHICSSCENE_H
|
||||||
|
|||||||
@@ -34,33 +34,21 @@
|
|||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
const int BOUNDARY_ITEMS_ZVALUE = -1000;
|
const int BOUNDARY_ITEMS_ZVALUE = -1000;
|
||||||
|
|
||||||
// all model objects have z-values from -500 to 500 depending on their depth in the model tree
|
// all model objects have z-values from -500 to 500 depending on their depth in the model tree
|
||||||
|
|
||||||
const int RELATION_ITEMS_ZVALUE = 1000;
|
const int RELATION_ITEMS_ZVALUE = 1000;
|
||||||
|
|
||||||
const int RELATION_ITEMS_ZVALUE_SELECTED = 1001;
|
const int RELATION_ITEMS_ZVALUE_SELECTED = 1001;
|
||||||
|
|
||||||
const int ANNOTATION_ITEMS_ZVALUE = 1500;
|
const int ANNOTATION_ITEMS_ZVALUE = 1500;
|
||||||
|
|
||||||
const int RELATION_STARTER_ZVALUE = 2000;
|
const int RELATION_STARTER_ZVALUE = 2000;
|
||||||
|
|
||||||
const int LATCH_LINES_ZVALUE = 3000;
|
const int LATCH_LINES_ZVALUE = 3000;
|
||||||
|
|
||||||
const int ALIGN_BUTTONS_ZVALUE = 3500;
|
const int ALIGN_BUTTONS_ZVALUE = 3500;
|
||||||
|
|
||||||
const int PREVIEW_RELATION_ZVALUE = 4000;
|
const int PREVIEW_RELATION_ZVALUE = 4000;
|
||||||
|
|
||||||
|
|
||||||
const double RASTER_WIDTH = 5.0;
|
const double RASTER_WIDTH = 5.0;
|
||||||
|
|
||||||
const double RASTER_HEIGHT = 5.0;
|
const double RASTER_HEIGHT = 5.0;
|
||||||
|
|
||||||
|
|
||||||
const double CUSTOM_ICON_MINIMUM_AUTO_WIDTH = 40.0; // must be n * 2 * RASTER_WIDTH
|
const double CUSTOM_ICON_MINIMUM_AUTO_WIDTH = 40.0; // must be n * 2 * RASTER_WIDTH
|
||||||
|
|
||||||
const double CUSTOM_ICON_MINIMUM_AUTO_HEIGHT = 40.0; // must be n * 2 * RASTER_HEIGHT
|
const double CUSTOM_ICON_MINIMUM_AUTO_HEIGHT = 40.0; // must be n * 2 * RASTER_HEIGHT
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DIAGRAMSCENECONSTANTS_H
|
#endif // QMT_DIAGRAMSCENECONSTANTS_H
|
||||||
|
|||||||
@@ -67,13 +67,9 @@
|
|||||||
#include <QtSvg/QSvgGenerator>
|
#include <QtSvg/QSvgGenerator>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DiagramSceneModel::OriginItem :
|
class DiagramSceneModel::OriginItem : public QGraphicsItem
|
||||||
public QGraphicsItem
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OriginItem(QGraphicsItem *parent = 0)
|
OriginItem(QGraphicsItem *parent = 0)
|
||||||
@@ -98,7 +94,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DiagramSceneModel::DiagramSceneModel(QObject *parent)
|
DiagramSceneModel::DiagramSceneModel(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_diagramController(0),
|
m_diagramController(0),
|
||||||
@@ -127,17 +122,15 @@ DiagramSceneModel::~DiagramSceneModel()
|
|||||||
QMT_CHECK(m_busyState == NotBusy);
|
QMT_CHECK(m_busyState == NotBusy);
|
||||||
m_latchController->removeFromGraphicsScene(m_graphicsScene);
|
m_latchController->removeFromGraphicsScene(m_graphicsScene);
|
||||||
disconnect();
|
disconnect();
|
||||||
if (m_diagramController) {
|
if (m_diagramController)
|
||||||
disconnect(m_diagramController, 0, this, 0);
|
disconnect(m_diagramController, 0, this, 0);
|
||||||
}
|
|
||||||
m_graphicsScene->deleteLater();
|
m_graphicsScene->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::setDiagramController(DiagramController *diagramController)
|
void DiagramSceneModel::setDiagramController(DiagramController *diagramController)
|
||||||
{
|
{
|
||||||
if (m_diagramController == diagramController) {
|
if (m_diagramController == diagramController)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (m_diagramController) {
|
if (m_diagramController) {
|
||||||
disconnect(m_diagramController, 0, this, 0);
|
disconnect(m_diagramController, 0, this, 0);
|
||||||
m_diagramController = 0;
|
m_diagramController = 0;
|
||||||
@@ -199,9 +192,8 @@ bool DiagramSceneModel::hasMultiObjectsSelection() const
|
|||||||
QMT_CHECK(element);
|
QMT_CHECK(element);
|
||||||
if (dynamic_cast<DObject *>(element) != 0) {
|
if (dynamic_cast<DObject *>(element) != 0) {
|
||||||
++count;
|
++count;
|
||||||
if (count > 1) {
|
if (count > 1)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -223,9 +215,8 @@ DElement *DiagramSceneModel::findTopmostElement(const QPointF &scenePos) const
|
|||||||
// fetch affected items from scene in correct drawing order to find topmost element
|
// fetch affected items from scene in correct drawing order to find topmost element
|
||||||
QList<QGraphicsItem *> items = m_graphicsScene->items(scenePos);
|
QList<QGraphicsItem *> items = m_graphicsScene->items(scenePos);
|
||||||
foreach (QGraphicsItem *item, items) {
|
foreach (QGraphicsItem *item, items) {
|
||||||
if (m_graphicsItems.contains(item)) {
|
if (m_graphicsItems.contains(item))
|
||||||
return m_itemToElementMap.value(item);
|
return m_itemToElementMap.value(item);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -258,30 +249,26 @@ bool DiagramSceneModel::isElementEditable(const DElement *element) const
|
|||||||
|
|
||||||
void DiagramSceneModel::selectAllElements()
|
void DiagramSceneModel::selectAllElements()
|
||||||
{
|
{
|
||||||
foreach (QGraphicsItem *item, m_graphicsItems) {
|
foreach (QGraphicsItem *item, m_graphicsItems)
|
||||||
item->setSelected(true);
|
item->setSelected(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::selectElement(DElement *element)
|
void DiagramSceneModel::selectElement(DElement *element)
|
||||||
{
|
{
|
||||||
QGraphicsItem *selectItem = m_elementToItemMap.value(element);
|
QGraphicsItem *selectItem = m_elementToItemMap.value(element);
|
||||||
foreach (QGraphicsItem *item, m_selectedItems) {
|
foreach (QGraphicsItem *item, m_selectedItems) {
|
||||||
if (item != selectItem) {
|
if (item != selectItem)
|
||||||
item->setSelected(false);
|
item->setSelected(false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (selectItem) {
|
if (selectItem)
|
||||||
selectItem->setSelected(true);
|
selectItem->setSelected(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::editElement(DElement *element)
|
void DiagramSceneModel::editElement(DElement *element)
|
||||||
{
|
{
|
||||||
IEditable *editable = dynamic_cast<IEditable *>(m_elementToItemMap.value(element));
|
IEditable *editable = dynamic_cast<IEditable *>(m_elementToItemMap.value(element));
|
||||||
if (editable != 0 && editable->isEditable()) {
|
if (editable != 0 && editable->isEditable())
|
||||||
editable->edit();
|
editable->edit();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::copyToClipboard()
|
void DiagramSceneModel::copyToClipboard()
|
||||||
@@ -403,9 +390,7 @@ bool DiagramSceneModel::exportPng(const QString &fileName)
|
|||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
bool success = image.save(fileName);
|
bool success = image.save(fileName);
|
||||||
|
|
||||||
addExtraSceneItems();
|
addExtraSceneItems();
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,9 +429,8 @@ void DiagramSceneModel::selectItem(QGraphicsItem *item, bool multiSelect)
|
|||||||
if (!multiSelect) {
|
if (!multiSelect) {
|
||||||
if (!item->isSelected()) {
|
if (!item->isSelected()) {
|
||||||
foreach (QGraphicsItem *selectedItem, m_selectedItems) {
|
foreach (QGraphicsItem *selectedItem, m_selectedItems) {
|
||||||
if (selectedItem != item) {
|
if (selectedItem != item)
|
||||||
selectedItem->setSelected(false);
|
selectedItem->setSelected(false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
item->setSelected(true);
|
item->setSelected(true);
|
||||||
}
|
}
|
||||||
@@ -461,14 +445,12 @@ void DiagramSceneModel::moveSelectedItems(QGraphicsItem *grabbedItem, const QPoi
|
|||||||
|
|
||||||
if (delta != QPointF(0.0, 0.0)) {
|
if (delta != QPointF(0.0, 0.0)) {
|
||||||
foreach (QGraphicsItem *item, m_selectedItems) {
|
foreach (QGraphicsItem *item, m_selectedItems) {
|
||||||
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item)) {
|
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item))
|
||||||
moveable->moveDelta(delta);
|
moveable->moveDelta(delta);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
|
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
|
||||||
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item)) {
|
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item))
|
||||||
moveable->moveDelta(delta);
|
moveable->moveDelta(delta);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -476,23 +458,20 @@ void DiagramSceneModel::moveSelectedItems(QGraphicsItem *grabbedItem, const QPoi
|
|||||||
void DiagramSceneModel::alignSelectedItemsPositionOnRaster()
|
void DiagramSceneModel::alignSelectedItemsPositionOnRaster()
|
||||||
{
|
{
|
||||||
foreach (QGraphicsItem *item, m_selectedItems) {
|
foreach (QGraphicsItem *item, m_selectedItems) {
|
||||||
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item)) {
|
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item))
|
||||||
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
|
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
|
foreach (QGraphicsItem *item, m_secondarySelectedItems) {
|
||||||
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item)) {
|
if (IMoveable *moveable = dynamic_cast<IMoveable *>(item))
|
||||||
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
|
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::onDoubleClickedItem(QGraphicsItem *item)
|
void DiagramSceneModel::onDoubleClickedItem(QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
DElement *element = m_itemToElementMap.value(item);
|
DElement *element = m_itemToElementMap.value(item);
|
||||||
if (item) {
|
if (item)
|
||||||
m_diagramSceneController->elementTasks()->openElement(element, m_diagram);
|
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
|
||||||
@@ -500,9 +479,8 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
|
|||||||
QList<QGraphicsItem *> collidingItems;
|
QList<QGraphicsItem *> collidingItems;
|
||||||
|
|
||||||
const IResizable *resizable = dynamic_cast<const IResizable *>(item);
|
const IResizable *resizable = dynamic_cast<const IResizable *>(item);
|
||||||
if (!resizable) {
|
if (!resizable)
|
||||||
return collidingItems;
|
return collidingItems;
|
||||||
}
|
|
||||||
QRectF rect = resizable->rect();
|
QRectF rect = resizable->rect();
|
||||||
rect.translate(resizable->pos());
|
rect.translate(resizable->pos());
|
||||||
|
|
||||||
@@ -582,9 +560,8 @@ void DiagramSceneModel::mouseMoveEventReparenting(QGraphicsSceneMouseEvent *even
|
|||||||
view->setCursor(QCursor(Qt::OpenHandCursor));
|
view->setCursor(QCursor(Qt::OpenHandCursor));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach (QGraphicsView *view, m_graphicsScene->views()) {
|
foreach (QGraphicsView *view, m_graphicsScene->views())
|
||||||
view->unsetCursor();
|
view->unsetCursor();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,13 +582,11 @@ void DiagramSceneModel::mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *e
|
|||||||
if (!selectedItemSet.contains(item)) {
|
if (!selectedItemSet.contains(item)) {
|
||||||
// the item may be any graphics item not matching to a DElement
|
// the item may be any graphics item not matching to a DElement
|
||||||
DElement *element = m_itemToElementMap.value(item);
|
DElement *element = m_itemToElementMap.value(item);
|
||||||
if (element && element->modelUid().isValid()) {
|
if (element && element->modelUid().isValid())
|
||||||
newOwner = modelController->findElement<MPackage>(element->modelUid());
|
newOwner = modelController->findElement<MPackage>(element->modelUid());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (newOwner) {
|
if (newOwner)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (newOwner) {
|
if (newOwner) {
|
||||||
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
|
foreach (QGraphicsItem *item, m_graphicsScene->selectedItems()) {
|
||||||
@@ -620,17 +595,15 @@ void DiagramSceneModel::mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *e
|
|||||||
if (element->modelUid().isValid()) {
|
if (element->modelUid().isValid()) {
|
||||||
MObject *modelObject = modelController->findObject(element->modelUid());
|
MObject *modelObject = modelController->findObject(element->modelUid());
|
||||||
if (modelObject) {
|
if (modelObject) {
|
||||||
if (newOwner != modelObject->owner()) {
|
if (newOwner != modelObject->owner())
|
||||||
modelController->moveObject(newOwner, modelObject);
|
modelController->moveObject(newOwner, modelObject);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (QGraphicsView *view, m_graphicsScene->views()) {
|
foreach (QGraphicsView *view, m_graphicsScene->views())
|
||||||
view->unsetCursor();
|
view->unsetCursor();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::onBeginResetAllDiagrams()
|
void DiagramSceneModel::onBeginResetAllDiagrams()
|
||||||
@@ -647,9 +620,8 @@ void DiagramSceneModel::onBeginResetDiagram(const MDiagram *diagram)
|
|||||||
{
|
{
|
||||||
QMT_CHECK(m_busyState == NotBusy);
|
QMT_CHECK(m_busyState == NotBusy);
|
||||||
m_busyState = ResetDiagram;
|
m_busyState = ResetDiagram;
|
||||||
if (diagram == m_diagram) {
|
if (diagram == m_diagram)
|
||||||
clearGraphicsScene();
|
clearGraphicsScene();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramSceneModel::onEndResetDiagram(const MDiagram *diagram)
|
void DiagramSceneModel::onEndResetDiagram(const MDiagram *diagram)
|
||||||
@@ -666,9 +638,8 @@ void DiagramSceneModel::onEndResetDiagram(const MDiagram *diagram)
|
|||||||
// invalidate scene
|
// invalidate scene
|
||||||
m_graphicsScene->invalidate();
|
m_graphicsScene->invalidate();
|
||||||
// update graphics items again so every item gets a correct list of colliding items
|
// update graphics items again so every item gets a correct list of colliding items
|
||||||
foreach (DElement *element, diagram->diagramElements()) {
|
foreach (DElement *element, diagram->diagramElements())
|
||||||
updateGraphicsItem(m_elementToItemMap.value(element), element);
|
updateGraphicsItem(m_elementToItemMap.value(element), element);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_busyState = NotBusy;
|
m_busyState = NotBusy;
|
||||||
}
|
}
|
||||||
@@ -873,9 +844,8 @@ void DiagramSceneModel::deleteGraphicsItem(QGraphicsItem *item, DElement *elemen
|
|||||||
{
|
{
|
||||||
QMT_CHECK(m_elementToItemMap.contains(element));
|
QMT_CHECK(m_elementToItemMap.contains(element));
|
||||||
QMT_CHECK(m_itemToElementMap.contains(item));
|
QMT_CHECK(m_itemToElementMap.contains(item));
|
||||||
if (item == m_focusItem) {
|
if (item == m_focusItem)
|
||||||
unsetFocusItem();
|
unsetFocusItem();
|
||||||
}
|
|
||||||
m_graphicsScene->removeItem(item);
|
m_graphicsScene->removeItem(item);
|
||||||
m_elementToItemMap.remove(element);
|
m_elementToItemMap.remove(element);
|
||||||
m_itemToElementMap.remove(item);
|
m_itemToElementMap.remove(item);
|
||||||
@@ -892,9 +862,8 @@ void DiagramSceneModel::updateFocusItem(const QSet<QGraphicsItem *> &selectedIte
|
|||||||
|
|
||||||
if (mouseGrabberItem && selectedItems.contains(mouseGrabberItem)) {
|
if (mouseGrabberItem && selectedItems.contains(mouseGrabberItem)) {
|
||||||
selectable = dynamic_cast<ISelectable *>(mouseGrabberItem);
|
selectable = dynamic_cast<ISelectable *>(mouseGrabberItem);
|
||||||
if (selectable) {
|
if (selectable)
|
||||||
focusItem = mouseGrabberItem;
|
focusItem = mouseGrabberItem;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (focusItem && focusItem != m_focusItem) {
|
if (focusItem && focusItem != m_focusItem) {
|
||||||
unsetFocusItem();
|
unsetFocusItem();
|
||||||
@@ -908,11 +877,10 @@ void DiagramSceneModel::updateFocusItem(const QSet<QGraphicsItem *> &selectedIte
|
|||||||
void DiagramSceneModel::unsetFocusItem()
|
void DiagramSceneModel::unsetFocusItem()
|
||||||
{
|
{
|
||||||
if (m_focusItem) {
|
if (m_focusItem) {
|
||||||
if (ISelectable *oldSelectable = dynamic_cast<ISelectable *>(m_focusItem)) {
|
if (ISelectable *oldSelectable = dynamic_cast<ISelectable *>(m_focusItem))
|
||||||
oldSelectable->setFocusSelected(false);
|
oldSelectable->setFocusSelected(false);
|
||||||
} else {
|
else
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
}
|
|
||||||
m_focusItem = 0;
|
m_focusItem = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -925,11 +893,10 @@ bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *frontItem, const QGraph
|
|||||||
// shortcut for usual case of root items
|
// shortcut for usual case of root items
|
||||||
if (frontItem->parentItem() == 0 && backItem->parentItem() == 0) {
|
if (frontItem->parentItem() == 0 && backItem->parentItem() == 0) {
|
||||||
foreach (const QGraphicsItem *item, m_graphicsScene->items()) {
|
foreach (const QGraphicsItem *item, m_graphicsScene->items()) {
|
||||||
if (item == frontItem) {
|
if (item == frontItem)
|
||||||
return true;
|
return true;
|
||||||
} else if (item == backItem) {
|
else if (item == backItem)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
return false;
|
return false;
|
||||||
@@ -977,17 +944,15 @@ bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *frontItem, const QGraph
|
|||||||
return frontItem->zValue() > backItem->zValue();
|
return frontItem->zValue() > backItem->zValue();
|
||||||
} else {
|
} else {
|
||||||
QList<QGraphicsItem *> children;
|
QList<QGraphicsItem *> children;
|
||||||
if (frontIndex + 1 < frontStack.size()) {
|
if (frontIndex + 1 < frontStack.size())
|
||||||
children = frontStack.at(frontIndex + 1)->childItems();
|
children = frontStack.at(frontIndex + 1)->childItems();
|
||||||
} else {
|
else
|
||||||
children = m_graphicsScene->items(Qt::AscendingOrder);
|
children = m_graphicsScene->items(Qt::AscendingOrder);
|
||||||
}
|
|
||||||
foreach (const QGraphicsItem *item, children) {
|
foreach (const QGraphicsItem *item, children) {
|
||||||
if (item == frontItem) {
|
if (item == frontItem)
|
||||||
return false;
|
return false;
|
||||||
} else if (item == backItem) {
|
else if (item == backItem)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
return false;
|
return false;
|
||||||
@@ -995,4 +960,4 @@ bool DiagramSceneModel::isInFrontOf(const QGraphicsItem *frontItem, const QGraph
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class QGraphicsScene;
|
|||||||
class QGraphicsSceneMouseEvent;
|
class QGraphicsSceneMouseEvent;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DiagramGraphicsScene;
|
class DiagramGraphicsScene;
|
||||||
@@ -61,8 +60,7 @@ class MDiagram;
|
|||||||
class DElement;
|
class DElement;
|
||||||
class DObject;
|
class DObject;
|
||||||
|
|
||||||
class QMT_EXPORT DiagramSceneModel :
|
class QMT_EXPORT DiagramSceneModel : public QObject
|
||||||
public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -74,168 +72,93 @@ class QMT_EXPORT DiagramSceneModel :
|
|||||||
friend class DiagramGraphicsScene;
|
friend class DiagramGraphicsScene;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum CollidingMode {
|
enum CollidingMode {
|
||||||
CollidingInnerItems,
|
CollidingInnerItems,
|
||||||
CollidingItems,
|
CollidingItems,
|
||||||
CollidingOuterItems
|
CollidingOuterItems
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DiagramSceneModel(QObject *parent = 0);
|
DiagramSceneModel(QObject *parent = 0);
|
||||||
|
|
||||||
~DiagramSceneModel();
|
~DiagramSceneModel();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void diagramSceneActivated(const MDiagram *diagram);
|
void diagramSceneActivated(const MDiagram *diagram);
|
||||||
|
|
||||||
void selectionHasChanged(const MDiagram *diagram);
|
void selectionHasChanged(const MDiagram *diagram);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DiagramController *diagramController() const { return m_diagramController; }
|
DiagramController *diagramController() const { return m_diagramController; }
|
||||||
|
|
||||||
void setDiagramController(DiagramController *diagramController);
|
void setDiagramController(DiagramController *diagramController);
|
||||||
|
|
||||||
DiagramSceneController *diagramSceneController() const { return m_diagramSceneController; }
|
DiagramSceneController *diagramSceneController() const { return m_diagramSceneController; }
|
||||||
|
|
||||||
void setDiagramSceneController(DiagramSceneController *diagramSceneController);
|
void setDiagramSceneController(DiagramSceneController *diagramSceneController);
|
||||||
|
|
||||||
StyleController *styleController() const { return m_styleController; }
|
StyleController *styleController() const { return m_styleController; }
|
||||||
|
|
||||||
void setStyleController(StyleController *styleController);
|
void setStyleController(StyleController *styleController);
|
||||||
|
|
||||||
StereotypeController *stereotypeController() const { return m_stereotypeController; }
|
StereotypeController *stereotypeController() const { return m_stereotypeController; }
|
||||||
|
|
||||||
void setStereotypeController(StereotypeController *stereotypeController);
|
void setStereotypeController(StereotypeController *stereotypeController);
|
||||||
|
|
||||||
MDiagram *diagram() const { return m_diagram; }
|
MDiagram *diagram() const { return m_diagram; }
|
||||||
|
|
||||||
void setDiagram(MDiagram *diagram);
|
void setDiagram(MDiagram *diagram);
|
||||||
|
|
||||||
QGraphicsScene *graphicsScene() const;
|
QGraphicsScene *graphicsScene() const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool hasSelection() const;
|
bool hasSelection() const;
|
||||||
|
|
||||||
bool hasMultiObjectsSelection() const;
|
bool hasMultiObjectsSelection() const;
|
||||||
|
|
||||||
DSelection selectedElements() const;
|
DSelection selectedElements() const;
|
||||||
|
|
||||||
DElement *findTopmostElement(const QPointF &scenePos) const;
|
DElement *findTopmostElement(const QPointF &scenePos) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QList<QGraphicsItem *> graphicsItems() const { return m_graphicsItems; }
|
QList<QGraphicsItem *> graphicsItems() const { return m_graphicsItems; }
|
||||||
|
|
||||||
QGraphicsItem *graphicsItem(DElement *element) const;
|
QGraphicsItem *graphicsItem(DElement *element) const;
|
||||||
|
|
||||||
QGraphicsItem *graphicsItem(const Uid &uid) const;
|
QGraphicsItem *graphicsItem(const Uid &uid) const;
|
||||||
|
|
||||||
QGraphicsItem *focusItem() const { return m_focusItem; }
|
QGraphicsItem *focusItem() const { return m_focusItem; }
|
||||||
|
|
||||||
bool isSelectedItem(QGraphicsItem *item) const;
|
bool isSelectedItem(QGraphicsItem *item) const;
|
||||||
|
|
||||||
QSet<QGraphicsItem *> selectedItems() const { return m_selectedItems; }
|
QSet<QGraphicsItem *> selectedItems() const { return m_selectedItems; }
|
||||||
|
|
||||||
DElement *element(QGraphicsItem *item) const;
|
DElement *element(QGraphicsItem *item) const;
|
||||||
|
|
||||||
bool isElementEditable(const DElement *element) const;
|
bool isElementEditable(const DElement *element) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void selectAllElements();
|
void selectAllElements();
|
||||||
|
|
||||||
void selectElement(DElement *element);
|
void selectElement(DElement *element);
|
||||||
|
|
||||||
void editElement(DElement *element);
|
void editElement(DElement *element);
|
||||||
|
|
||||||
void copyToClipboard();
|
void copyToClipboard();
|
||||||
|
|
||||||
bool exportPng(const QString &fileName);
|
bool exportPng(const QString &fileName);
|
||||||
|
|
||||||
void exportPdf(const QString &fileName);
|
void exportPdf(const QString &fileName);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void selectItem(QGraphicsItem *item, bool multiSelect);
|
void selectItem(QGraphicsItem *item, bool multiSelect);
|
||||||
|
|
||||||
void moveSelectedItems(QGraphicsItem *grabbedItem, const QPointF &delta);
|
void moveSelectedItems(QGraphicsItem *grabbedItem, const QPointF &delta);
|
||||||
|
|
||||||
void alignSelectedItemsPositionOnRaster();
|
void alignSelectedItemsPositionOnRaster();
|
||||||
|
|
||||||
void onDoubleClickedItem(QGraphicsItem *item);
|
void onDoubleClickedItem(QGraphicsItem *item);
|
||||||
|
|
||||||
QList<QGraphicsItem *> collectCollidingObjectItems(const QGraphicsItem *item, CollidingMode collidingMode) const;
|
QList<QGraphicsItem *> collectCollidingObjectItems(const QGraphicsItem *item, CollidingMode collidingMode) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void sceneActivated();
|
void sceneActivated();
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mousePressEventReparenting(QGraphicsSceneMouseEvent *event);
|
void mousePressEventReparenting(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseMoveEventReparenting(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEventReparenting(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEventReparenting(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onBeginResetAllDiagrams();
|
void onBeginResetAllDiagrams();
|
||||||
|
|
||||||
void onEndResetAllDiagrams();
|
void onEndResetAllDiagrams();
|
||||||
|
|
||||||
void onBeginResetDiagram(const MDiagram *diagram);
|
void onBeginResetDiagram(const MDiagram *diagram);
|
||||||
|
|
||||||
void onEndResetDiagram(const MDiagram *diagram);
|
void onEndResetDiagram(const MDiagram *diagram);
|
||||||
|
|
||||||
void onBeginUpdateElement(int row, const MDiagram *diagram);
|
void onBeginUpdateElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void onEndUpdateElement(int row, const MDiagram *diagram);
|
void onEndUpdateElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void onBeginInsertElement(int row, const MDiagram *diagram);
|
void onBeginInsertElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void onEndInsertElement(int row, const MDiagram *diagram);
|
void onEndInsertElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void onBeginRemoveElement(int row, const MDiagram *diagram);
|
void onBeginRemoveElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
void onEndRemoveElement(int row, const MDiagram *diagram);
|
void onEndRemoveElement(int row, const MDiagram *diagram);
|
||||||
|
|
||||||
private slots:
|
|
||||||
|
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void clearGraphicsScene();
|
void clearGraphicsScene();
|
||||||
|
|
||||||
void removeExtraSceneItems();
|
void removeExtraSceneItems();
|
||||||
|
|
||||||
void addExtraSceneItems();
|
void addExtraSceneItems();
|
||||||
|
|
||||||
QGraphicsItem *createGraphicsItem(DElement *element);
|
QGraphicsItem *createGraphicsItem(DElement *element);
|
||||||
|
|
||||||
void updateGraphicsItem(QGraphicsItem *item, DElement *element);
|
void updateGraphicsItem(QGraphicsItem *item, DElement *element);
|
||||||
|
|
||||||
void deleteGraphicsItem(QGraphicsItem *item, DElement *element);
|
void deleteGraphicsItem(QGraphicsItem *item, DElement *element);
|
||||||
|
|
||||||
void updateFocusItem(const QSet<QGraphicsItem *> &selectedItems);
|
void updateFocusItem(const QSet<QGraphicsItem *> &selectedItems);
|
||||||
|
|
||||||
void unsetFocusItem();
|
void unsetFocusItem();
|
||||||
|
|
||||||
bool isInFrontOf(const QGraphicsItem *frontItem, const QGraphicsItem *backItem);
|
bool isInFrontOf(const QGraphicsItem *frontItem, const QGraphicsItem *backItem);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
enum Busy {
|
enum Busy {
|
||||||
NotBusy,
|
NotBusy,
|
||||||
ResetDiagram,
|
ResetDiagram,
|
||||||
@@ -244,39 +167,23 @@ private:
|
|||||||
RemoveElement
|
RemoveElement
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DiagramController *m_diagramController;
|
DiagramController *m_diagramController;
|
||||||
|
|
||||||
DiagramSceneController *m_diagramSceneController;
|
DiagramSceneController *m_diagramSceneController;
|
||||||
|
|
||||||
StyleController *m_styleController;
|
StyleController *m_styleController;
|
||||||
|
|
||||||
StereotypeController *m_stereotypeController;
|
StereotypeController *m_stereotypeController;
|
||||||
|
|
||||||
MDiagram *m_diagram;
|
MDiagram *m_diagram;
|
||||||
|
|
||||||
DiagramGraphicsScene *m_graphicsScene;
|
DiagramGraphicsScene *m_graphicsScene;
|
||||||
|
|
||||||
LatchController *m_latchController;
|
LatchController *m_latchController;
|
||||||
|
|
||||||
QList<QGraphicsItem *> m_graphicsItems;
|
QList<QGraphicsItem *> m_graphicsItems;
|
||||||
|
|
||||||
QHash<const QGraphicsItem *, DElement *> m_itemToElementMap;
|
QHash<const QGraphicsItem *, DElement *> m_itemToElementMap;
|
||||||
|
|
||||||
QHash<const DElement *, QGraphicsItem *> m_elementToItemMap;
|
QHash<const DElement *, QGraphicsItem *> m_elementToItemMap;
|
||||||
|
|
||||||
QSet<QGraphicsItem *> m_selectedItems;
|
QSet<QGraphicsItem *> m_selectedItems;
|
||||||
|
|
||||||
QSet<QGraphicsItem *> m_secondarySelectedItems;
|
QSet<QGraphicsItem *> m_secondarySelectedItems;
|
||||||
|
|
||||||
Busy m_busyState;
|
Busy m_busyState;
|
||||||
|
|
||||||
OriginItem *m_originItem;
|
OriginItem *m_originItem;
|
||||||
|
|
||||||
QGraphicsItem *m_focusItem;
|
QGraphicsItem *m_focusItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DIAGRAMSCENEMODEL_H
|
#endif // QMT_DIAGRAMSCENEMODEL_H
|
||||||
|
|||||||
@@ -55,7 +55,6 @@
|
|||||||
#include "qmt/diagram/dboundary.h"
|
#include "qmt/diagram/dboundary.h"
|
||||||
#include "qmt/infrastructure/qmtassert.h"
|
#include "qmt/infrastructure/qmtassert.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
DiagramSceneModel::CreationVisitor::CreationVisitor(DiagramSceneModel *diagramSceneModel)
|
DiagramSceneModel::CreationVisitor::CreationVisitor(DiagramSceneModel *diagramSceneModel)
|
||||||
@@ -140,8 +139,6 @@ void DiagramSceneModel::CreationVisitor::visitDBoundary(DBoundary *boundary)
|
|||||||
m_graphicsItem = new BoundaryItem(boundary, m_diagramSceneModel);
|
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_graphicsItem(item),
|
||||||
m_diagramSceneModel(diagramSceneModel),
|
m_diagramSceneModel(diagramSceneModel),
|
||||||
@@ -289,4 +286,4 @@ void DiagramSceneModel::UpdateVisitor::visitDBoundary(DBoundary *boundary)
|
|||||||
boundaryItem->update();
|
boundaryItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -37,96 +37,57 @@
|
|||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class QMT_EXPORT DiagramSceneModel::CreationVisitor :
|
class QMT_EXPORT DiagramSceneModel::CreationVisitor : public DVisitor
|
||||||
public DVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CreationVisitor(DiagramSceneModel *diagramSceneModel);
|
CreationVisitor(DiagramSceneModel *diagramSceneModel);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QGraphicsItem *createdGraphicsItem() const { return m_graphicsItem; }
|
QGraphicsItem *createdGraphicsItem() const { return m_graphicsItem; }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void visitDElement(DElement *element);
|
void visitDElement(DElement *element);
|
||||||
|
|
||||||
void visitDObject(DObject *object);
|
void visitDObject(DObject *object);
|
||||||
|
|
||||||
void visitDPackage(DPackage *package);
|
void visitDPackage(DPackage *package);
|
||||||
|
|
||||||
void visitDClass(DClass *klass);
|
void visitDClass(DClass *klass);
|
||||||
|
|
||||||
void visitDComponent(DComponent *component);
|
void visitDComponent(DComponent *component);
|
||||||
|
|
||||||
void visitDDiagram(DDiagram *diagram);
|
void visitDDiagram(DDiagram *diagram);
|
||||||
|
|
||||||
void visitDItem(DItem *item);
|
void visitDItem(DItem *item);
|
||||||
|
|
||||||
void visitDRelation(DRelation *relation);
|
void visitDRelation(DRelation *relation);
|
||||||
|
|
||||||
void visitDInheritance(DInheritance *inheritance);
|
void visitDInheritance(DInheritance *inheritance);
|
||||||
|
|
||||||
void visitDDependency(DDependency *dependency);
|
void visitDDependency(DDependency *dependency);
|
||||||
|
|
||||||
void visitDAssociation(DAssociation *association);
|
void visitDAssociation(DAssociation *association);
|
||||||
|
|
||||||
void visitDAnnotation(DAnnotation *annotation);
|
void visitDAnnotation(DAnnotation *annotation);
|
||||||
|
|
||||||
void visitDBoundary(DBoundary *boundary);
|
void visitDBoundary(DBoundary *boundary);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DiagramSceneModel *m_diagramSceneModel;
|
DiagramSceneModel *m_diagramSceneModel;
|
||||||
|
|
||||||
QGraphicsItem *m_graphicsItem;
|
QGraphicsItem *m_graphicsItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiagramSceneModel::UpdateVisitor :
|
class DiagramSceneModel::UpdateVisitor : public DVisitor
|
||||||
public DVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UpdateVisitor(QGraphicsItem *item, DiagramSceneModel *diagramSceneModel, DElement *relatedElement = 0);
|
UpdateVisitor(QGraphicsItem *item, DiagramSceneModel *diagramSceneModel, DElement *relatedElement = 0);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void visitDElement(DElement *element);
|
void visitDElement(DElement *element);
|
||||||
|
|
||||||
void visitDObject(DObject *object);
|
void visitDObject(DObject *object);
|
||||||
|
|
||||||
void visitDPackage(DPackage *package);
|
void visitDPackage(DPackage *package);
|
||||||
|
|
||||||
void visitDClass(DClass *klass);
|
void visitDClass(DClass *klass);
|
||||||
|
|
||||||
void visitDComponent(DComponent *component);
|
void visitDComponent(DComponent *component);
|
||||||
|
|
||||||
void visitDDiagram(DDiagram *diagram);
|
void visitDDiagram(DDiagram *diagram);
|
||||||
|
|
||||||
void visitDItem(DItem *item);
|
void visitDItem(DItem *item);
|
||||||
|
|
||||||
void visitDRelation(DRelation *relation);
|
void visitDRelation(DRelation *relation);
|
||||||
|
|
||||||
void visitDInheritance(DInheritance *inheritance);
|
void visitDInheritance(DInheritance *inheritance);
|
||||||
|
|
||||||
void visitDDependency(DDependency *dependency);
|
void visitDDependency(DDependency *dependency);
|
||||||
|
|
||||||
void visitDAssociation(DAssociation *association);
|
void visitDAssociation(DAssociation *association);
|
||||||
|
|
||||||
void visitDAnnotation(DAnnotation *annotation);
|
void visitDAnnotation(DAnnotation *annotation);
|
||||||
|
|
||||||
void visitDBoundary(DBoundary *boundary);
|
void visitDBoundary(DBoundary *boundary);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QGraphicsItem *m_graphicsItem;
|
QGraphicsItem *m_graphicsItem;
|
||||||
|
|
||||||
DiagramSceneModel *m_diagramSceneModel;
|
DiagramSceneModel *m_diagramSceneModel;
|
||||||
|
|
||||||
DElement *m_relatedElement;
|
DElement *m_relatedElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_DIAGRAMSCENEMODELITEMVISITORS_H
|
#endif // QMT_DIAGRAMSCENEMODELITEMVISITORS_H
|
||||||
|
|||||||
@@ -49,16 +49,13 @@
|
|||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
static const qreal MINIMUM_TEXT_WIDTH = 20.0;
|
static const qreal MINIMUM_TEXT_WIDTH = 20.0;
|
||||||
static const qreal CONTENTS_BORDER_VERTICAL = 4.0;
|
static const qreal CONTENTS_BORDER_VERTICAL = 4.0;
|
||||||
static const qreal CONTENTS_BORDER_HORIZONTAL = 4.0;
|
static const qreal CONTENTS_BORDER_HORIZONTAL = 4.0;
|
||||||
|
|
||||||
|
class AnnotationItem::AnnotationTextItem : public QGraphicsTextItem
|
||||||
class AnnotationItem::AnnotationTextItem :
|
|
||||||
public QGraphicsTextItem
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AnnotationTextItem(QGraphicsItem *parent)
|
AnnotationTextItem(QGraphicsItem *parent)
|
||||||
@@ -76,7 +73,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
AnnotationItem::AnnotationItem(DAnnotation *annotation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
AnnotationItem::AnnotationItem(DAnnotation *annotation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_annotation(annotation),
|
m_annotation(annotation),
|
||||||
@@ -127,21 +123,17 @@ void AnnotationItem::update()
|
|||||||
}
|
}
|
||||||
m_textItem->setFont(style->normalFont());
|
m_textItem->setFont(style->normalFont());
|
||||||
m_textItem->setDefaultTextColor(style->textBrush().color());
|
m_textItem->setDefaultTextColor(style->textBrush().color());
|
||||||
if (!m_isChanged) {
|
if (!m_isChanged)
|
||||||
m_textItem->setPlainText(annotation()->text());
|
m_textItem->setPlainText(annotation()->text());
|
||||||
}
|
|
||||||
|
|
||||||
// item shown if annotation has no text and is not selected
|
// item shown if annotation has no text and is not selected
|
||||||
if (!m_noTextItem) {
|
if (!m_noTextItem)
|
||||||
m_noTextItem = new QGraphicsRectItem(this);
|
m_noTextItem = new QGraphicsRectItem(this);
|
||||||
}
|
|
||||||
m_noTextItem->setPen(QPen(QBrush(QColor(192, 192, 192)), 1, Qt::DashDotLine));
|
m_noTextItem->setPen(QPen(QBrush(QColor(192, 192, 192)), 1, Qt::DashDotLine));
|
||||||
m_noTextItem->setVisible(!isSelected() && m_textItem->document()->isEmpty());
|
m_noTextItem->setVisible(!isSelected() && m_textItem->document()->isEmpty());
|
||||||
|
|
||||||
updateSelectionMarker();
|
updateSelectionMarker();
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
|
|
||||||
setZValue(ANNOTATION_ITEMS_ZVALUE);
|
setZValue(ANNOTATION_ITEMS_ZVALUE);
|
||||||
|
|
||||||
m_isUpdating = false;
|
m_isUpdating = false;
|
||||||
@@ -170,9 +162,8 @@ void AnnotationItem::setPosAndRect(const QPointF &originalPos, const QRectF &ori
|
|||||||
if (newPos != m_annotation->pos() || newRect != m_annotation->rect()) {
|
if (newPos != m_annotation->pos() || newRect != m_annotation->rect()) {
|
||||||
m_diagramSceneModel->diagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
|
m_diagramSceneModel->diagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
|
||||||
m_annotation->setPos(newPos);
|
m_annotation->setPos(newPos);
|
||||||
if (newRect.size() != m_annotation->rect().size()) {
|
if (newRect.size() != m_annotation->rect().size())
|
||||||
m_annotation->setAutoSized(false);
|
m_annotation->setAutoSized(false);
|
||||||
}
|
|
||||||
m_annotation->setRect(newRect);
|
m_annotation->setRect(newRect);
|
||||||
m_diagramSceneModel->diagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->diagram(), false);
|
m_diagramSceneModel->diagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->diagram(), false);
|
||||||
}
|
}
|
||||||
@@ -239,35 +230,30 @@ bool AnnotationItem::isEditable() const
|
|||||||
|
|
||||||
void AnnotationItem::edit()
|
void AnnotationItem::edit()
|
||||||
{
|
{
|
||||||
if (m_textItem) {
|
if (m_textItem)
|
||||||
m_textItem->setFocus();
|
m_textItem->setFocus();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void AnnotationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) {
|
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
|
||||||
m_diagramSceneModel->selectItem(this, event->modifiers() & Qt::ControlModifier);
|
m_diagramSceneModel->selectItem(this, event->modifiers() & Qt::ControlModifier);
|
||||||
}
|
if (event->buttons() & Qt::LeftButton)
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
|
||||||
m_diagramSceneModel->moveSelectedItems(this, QPointF(0.0, 0.0));
|
m_diagramSceneModel->moveSelectedItems(this, QPointF(0.0, 0.0));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void AnnotationItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
if (event->buttons() & Qt::LeftButton)
|
||||||
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void AnnotationItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
||||||
if (event->scenePos() != event->buttonDownScenePos(Qt::LeftButton)) {
|
if (event->scenePos() != event->buttonDownScenePos(Qt::LeftButton))
|
||||||
m_diagramSceneModel->alignSelectedItemsPositionOnRaster();
|
m_diagramSceneModel->alignSelectedItemsPositionOnRaster();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,9 +267,8 @@ void AnnotationItem::updateSelectionMarker()
|
|||||||
}
|
}
|
||||||
m_selectionMarker->setSecondarySelected(isSelected() ? false : m_isSecondarySelected);
|
m_selectionMarker->setSecondarySelected(isSelected() ? false : m_isSecondarySelected);
|
||||||
} else if (m_selectionMarker) {
|
} else if (m_selectionMarker) {
|
||||||
if (m_selectionMarker->scene()) {
|
if (m_selectionMarker->scene())
|
||||||
m_selectionMarker->scene()->removeItem(m_selectionMarker);
|
m_selectionMarker->scene()->removeItem(m_selectionMarker);
|
||||||
}
|
|
||||||
delete m_selectionMarker;
|
delete m_selectionMarker;
|
||||||
m_selectionMarker = 0;
|
m_selectionMarker = 0;
|
||||||
}
|
}
|
||||||
@@ -291,9 +276,8 @@ void AnnotationItem::updateSelectionMarker()
|
|||||||
|
|
||||||
void AnnotationItem::updateSelectionMarkerGeometry(const QRectF &annotationRect)
|
void AnnotationItem::updateSelectionMarkerGeometry(const QRectF &annotationRect)
|
||||||
{
|
{
|
||||||
if (m_selectionMarker) {
|
if (m_selectionMarker)
|
||||||
m_selectionMarker->setRect(annotationRect);
|
m_selectionMarker->setRect(annotationRect);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Style *AnnotationItem::adaptedStyle()
|
const Style *AnnotationItem::adaptedStyle()
|
||||||
@@ -381,15 +365,13 @@ void AnnotationItem::updateGeometry()
|
|||||||
// a backup for the graphics item used for manual resized and persistency.
|
// a backup for the graphics item used for manual resized and persistency.
|
||||||
annotation()->setRect(rect);
|
annotation()->setRect(rect);
|
||||||
|
|
||||||
if (m_noTextItem) {
|
if (m_noTextItem)
|
||||||
m_noTextItem->setRect(rect);
|
m_noTextItem->setRect(rect);
|
||||||
}
|
|
||||||
|
|
||||||
if (m_textItem) {
|
if (m_textItem)
|
||||||
m_textItem->setPos(left + CONTENTS_BORDER_HORIZONTAL, top + CONTENTS_BORDER_VERTICAL);
|
m_textItem->setPos(left + CONTENTS_BORDER_HORIZONTAL, top + CONTENTS_BORDER_VERTICAL);
|
||||||
}
|
|
||||||
|
|
||||||
updateSelectionMarkerGeometry(rect);
|
updateSelectionMarkerGeometry(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
#include "qmt/diagram_scene/capabilities/selectable.h"
|
#include "qmt/diagram_scene/capabilities/selectable.h"
|
||||||
#include "qmt/diagram_scene/capabilities/editable.h"
|
#include "qmt/diagram_scene/capabilities/editable.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DAnnotation;
|
class DAnnotation;
|
||||||
@@ -46,7 +45,6 @@ class DiagramSceneModel;
|
|||||||
class RectangularSelectionItem;
|
class RectangularSelectionItem;
|
||||||
class Style;
|
class Style;
|
||||||
|
|
||||||
|
|
||||||
class AnnotationItem :
|
class AnnotationItem :
|
||||||
public QGraphicsItem,
|
public QGraphicsItem,
|
||||||
public IResizable,
|
public IResizable,
|
||||||
@@ -57,110 +55,64 @@ class AnnotationItem :
|
|||||||
class AnnotationTextItem;
|
class AnnotationTextItem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AnnotationItem(DAnnotation *annotation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
AnnotationItem(DAnnotation *annotation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~AnnotationItem();
|
~AnnotationItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DAnnotation *annotation() const { return m_annotation; }
|
DAnnotation *annotation() const { return m_annotation; }
|
||||||
|
|
||||||
DiagramSceneModel *diagramSceneModel() const { return m_diagramSceneModel; }
|
DiagramSceneModel *diagramSceneModel() const { return m_diagramSceneModel; }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QPointF pos() const;
|
QPointF pos() const;
|
||||||
|
|
||||||
QRectF rect() const;
|
QRectF rect() const;
|
||||||
|
|
||||||
QSizeF minimumSize() const;
|
QSizeF minimumSize() const;
|
||||||
|
|
||||||
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
||||||
|
|
||||||
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void moveDelta(const QPointF &delta);
|
void moveDelta(const QPointF &delta);
|
||||||
|
|
||||||
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isSecondarySelected() const;
|
bool isSecondarySelected() const;
|
||||||
|
|
||||||
void setSecondarySelected(bool secondarySelected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
bool isFocusSelected() const;
|
bool isFocusSelected() const;
|
||||||
|
|
||||||
void setFocusSelected(bool focusSelected);
|
void setFocusSelected(bool focusSelected);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isEditable() const;
|
bool isEditable() const;
|
||||||
|
|
||||||
void edit();
|
void edit();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void updateSelectionMarker();
|
void updateSelectionMarker();
|
||||||
|
|
||||||
void updateSelectionMarkerGeometry(const QRectF &annotationRect);
|
void updateSelectionMarkerGeometry(const QRectF &annotationRect);
|
||||||
|
|
||||||
const Style *adaptedStyle();
|
const Style *adaptedStyle();
|
||||||
|
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onContentsChanged();
|
void onContentsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QSizeF calcMinimumGeometry() const;
|
QSizeF calcMinimumGeometry() const;
|
||||||
|
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DAnnotation *m_annotation;
|
DAnnotation *m_annotation;
|
||||||
|
|
||||||
DiagramSceneModel *m_diagramSceneModel;
|
DiagramSceneModel *m_diagramSceneModel;
|
||||||
|
|
||||||
bool m_isSecondarySelected;
|
bool m_isSecondarySelected;
|
||||||
|
|
||||||
bool m_isFocusSelected;
|
bool m_isFocusSelected;
|
||||||
|
|
||||||
RectangularSelectionItem *m_selectionMarker;
|
RectangularSelectionItem *m_selectionMarker;
|
||||||
|
|
||||||
QGraphicsRectItem *m_noTextItem;
|
QGraphicsRectItem *m_noTextItem;
|
||||||
|
|
||||||
AnnotationTextItem *m_textItem;
|
AnnotationTextItem *m_textItem;
|
||||||
|
|
||||||
bool m_isUpdating;
|
bool m_isUpdating;
|
||||||
|
|
||||||
bool m_isChanged;
|
bool m_isChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_ANNOTATIONITEM_H
|
#endif // QMT_ANNOTATIONITEM_H
|
||||||
|
|||||||
@@ -45,8 +45,6 @@
|
|||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <qdebug.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
@@ -85,9 +83,8 @@ void AssociationItem::updateEndLabels(const DAssociationEnd &end, const DAssocia
|
|||||||
Q_UNUSED(end);
|
Q_UNUSED(end);
|
||||||
|
|
||||||
if (!otherEnd.name().isEmpty()) {
|
if (!otherEnd.name().isEmpty()) {
|
||||||
if (!*endName) {
|
if (!*endName)
|
||||||
*endName = new QGraphicsSimpleTextItem(this);
|
*endName = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
(*endName)->setFont(style->smallFont());
|
(*endName)->setFont(style->smallFont());
|
||||||
(*endName)->setBrush(style->textBrush());
|
(*endName)->setBrush(style->textBrush());
|
||||||
(*endName)->setText(otherEnd.name());
|
(*endName)->setText(otherEnd.name());
|
||||||
@@ -98,9 +95,8 @@ void AssociationItem::updateEndLabels(const DAssociationEnd &end, const DAssocia
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!otherEnd.cardinality().isEmpty()) {
|
if (!otherEnd.cardinality().isEmpty()) {
|
||||||
if (!*endCardinality) {
|
if (!*endCardinality)
|
||||||
*endCardinality = new QGraphicsSimpleTextItem(this);
|
*endCardinality = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
(*endCardinality)->setFont(style->smallFont());
|
(*endCardinality)->setFont(style->smallFont());
|
||||||
(*endCardinality)->setBrush(style->textBrush());
|
(*endCardinality)->setBrush(style->textBrush());
|
||||||
(*endCardinality)->setText(otherEnd.cardinality());
|
(*endCardinality)->setText(otherEnd.cardinality());
|
||||||
@@ -120,27 +116,21 @@ void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *e
|
|||||||
|
|
||||||
double angle = GeometryUtilities::calcAngle(lineSegment);
|
double angle = GeometryUtilities::calcAngle(lineSegment);
|
||||||
if (angle >= -5 && angle <= 5) {
|
if (angle >= -5 && angle <= 5) {
|
||||||
if (endName) {
|
if (endName)
|
||||||
endName->setPos(lineSegment.p1() + headOffset + sideOffset);
|
endName->setPos(lineSegment.p1() + headOffset + sideOffset);
|
||||||
}
|
if (endCardinality)
|
||||||
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) {
|
} else if (angle <= -175 || angle >= 175) {
|
||||||
if (endName) {
|
if (endName)
|
||||||
endName->setPos(lineSegment.p1() - headOffset + sideOffset - endName->boundingRect().topRight());
|
endName->setPos(lineSegment.p1() - headOffset + sideOffset - endName->boundingRect().topRight());
|
||||||
}
|
if (endCardinality)
|
||||||
if (endCardinality) {
|
|
||||||
endCardinality->setPos(lineSegment.p1() - headOffset - sideOffset - endCardinality->boundingRect().bottomRight());
|
endCardinality->setPos(lineSegment.p1() - headOffset - sideOffset - endCardinality->boundingRect().bottomRight());
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
if (endCardinality) {
|
if (endCardinality)
|
||||||
rect = endCardinality->boundingRect();
|
rect = endCardinality->boundingRect();
|
||||||
}
|
if (endName)
|
||||||
if (endName) {
|
|
||||||
rect = rect.united(endName->boundingRect().translated(rect.bottomLeft()));
|
rect = rect.united(endName->boundingRect().translated(rect.bottomLeft()));
|
||||||
}
|
|
||||||
|
|
||||||
QPointF rectPlacement;
|
QPointF rectPlacement;
|
||||||
GeometryUtilities::Side alignedSide = GeometryUtilities::SideUnspecified;
|
GeometryUtilities::Side alignedSide = GeometryUtilities::SideUnspecified;
|
||||||
@@ -150,9 +140,8 @@ void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *e
|
|||||||
QLineF intersectionLine;
|
QLineF intersectionLine;
|
||||||
|
|
||||||
if (objectItem->intersectShapeWithLine(GeometryUtilities::stretch(lineSegment.translated(pos()), 2.0, 0.0), &intersectionPoint, &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 (!GeometryUtilities::placeRectAtLine(rect, lineSegment, HEAD_OFFSET, SIDE_OFFSET, intersectionLine, &rectPlacement, &alignedSide))
|
||||||
rectPlacement = intersectionPoint;
|
rectPlacement = intersectionPoint;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
rectPlacement = lineSegment.p1();
|
rectPlacement = lineSegment.p1();
|
||||||
}
|
}
|
||||||
@@ -161,21 +150,19 @@ void AssociationItem::placeEndLabels(const QLineF &lineSegment, QGraphicsItem *e
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (endCardinality) {
|
if (endCardinality) {
|
||||||
if (alignedSide == GeometryUtilities::SideRight) {
|
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 {
|
else
|
||||||
endCardinality->setPos(rectPlacement);
|
endCardinality->setPos(rectPlacement);
|
||||||
}
|
|
||||||
rectPlacement += endCardinality->boundingRect().bottomLeft();
|
rectPlacement += endCardinality->boundingRect().bottomLeft();
|
||||||
}
|
}
|
||||||
if (endName) {
|
if (endName) {
|
||||||
if (alignedSide == GeometryUtilities::SideRight) {
|
if (alignedSide == GeometryUtilities::SideRight)
|
||||||
endName->setPos(rectPlacement + QPointF(rect.width() - endName->boundingRect().width(), 0.0));
|
endName->setPos(rectPlacement + QPointF(rect.width() - endName->boundingRect().width(), 0.0));
|
||||||
} else {
|
else
|
||||||
endName->setPos(rectPlacement);
|
endName->setPos(rectPlacement);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -37,46 +37,31 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QGraphicsSimpleTextItem;
|
class QGraphicsSimpleTextItem;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DAssociation;
|
class DAssociation;
|
||||||
class DAssociationEnd;
|
class DAssociationEnd;
|
||||||
|
|
||||||
|
class AssociationItem : public RelationItem
|
||||||
class AssociationItem :
|
|
||||||
public RelationItem
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AssociationItem(DAssociation *association, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
AssociationItem(DAssociation *association, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~AssociationItem();
|
~AssociationItem();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void update(const Style *style);
|
virtual void update(const Style *style);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void updateEndLabels(const DAssociationEnd &end, const DAssociationEnd &otherEnd, QGraphicsSimpleTextItem **endName, QGraphicsSimpleTextItem **endCardinality, const Style *style);
|
void updateEndLabels(const DAssociationEnd &end, const DAssociationEnd &otherEnd, QGraphicsSimpleTextItem **endName, QGraphicsSimpleTextItem **endCardinality, const Style *style);
|
||||||
|
|
||||||
void placeEndLabels(const QLineF &lineSegment, QGraphicsItem *endName, QGraphicsItem *endCardinality, QGraphicsItem *endItem, double headLength);
|
void placeEndLabels(const QLineF &lineSegment, QGraphicsItem *endName, QGraphicsItem *endCardinality, QGraphicsItem *endItem, double headLength);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DAssociation *m_association;
|
DAssociation *m_association;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_endAName;
|
QGraphicsSimpleTextItem *m_endAName;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_endACardinality;
|
QGraphicsSimpleTextItem *m_endACardinality;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_endBName;
|
QGraphicsSimpleTextItem *m_endBName;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_endBCardinality;
|
QGraphicsSimpleTextItem *m_endBCardinality;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_GRAPHICSASSOCIATIONITEM_H
|
#endif // QMT_GRAPHICSASSOCIATIONITEM_H
|
||||||
|
|||||||
@@ -50,7 +50,6 @@
|
|||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
static const qreal MINIMUM_INNER_WIDTH = 22.0;
|
static const qreal MINIMUM_INNER_WIDTH = 22.0;
|
||||||
@@ -58,9 +57,7 @@ static const qreal MINIMUM_INNER_HEIGHT = 22.0;
|
|||||||
static const qreal CONTENTS_BORDER_VERTICAL = 4.0;
|
static const qreal CONTENTS_BORDER_VERTICAL = 4.0;
|
||||||
static const qreal CONTENTS_BORDER_HORIZONTAL = 4.0;
|
static const qreal CONTENTS_BORDER_HORIZONTAL = 4.0;
|
||||||
|
|
||||||
|
class BoundaryItem::BoundaryTextItem : public QGraphicsTextItem
|
||||||
class BoundaryItem::BoundaryTextItem :
|
|
||||||
public QGraphicsTextItem
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoundaryTextItem(QGraphicsItem *parent)
|
BoundaryTextItem(QGraphicsItem *parent)
|
||||||
@@ -78,7 +75,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BoundaryItem::BoundaryItem(DBoundary *boundary, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
BoundaryItem::BoundaryItem(DBoundary *boundary, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_boundary(boundary),
|
m_boundary(boundary),
|
||||||
@@ -137,9 +133,8 @@ void BoundaryItem::update()
|
|||||||
|
|
||||||
// item shown if annotation has no text and is not selected
|
// item shown if annotation has no text and is not selected
|
||||||
if (m_textItem->document()->isEmpty() && isSelected()) {
|
if (m_textItem->document()->isEmpty() && isSelected()) {
|
||||||
if (!m_noTextItem) {
|
if (!m_noTextItem)
|
||||||
m_noTextItem = new QGraphicsRectItem(this);
|
m_noTextItem = new QGraphicsRectItem(this);
|
||||||
}
|
|
||||||
m_noTextItem->setPen(QPen(QBrush(QColor(192, 192, 192)), 1, Qt::DashDotLine));
|
m_noTextItem->setPen(QPen(QBrush(QColor(192, 192, 192)), 1, Qt::DashDotLine));
|
||||||
} else if (m_noTextItem) {
|
} else if (m_noTextItem) {
|
||||||
m_noTextItem->scene()->removeItem(m_noTextItem);
|
m_noTextItem->scene()->removeItem(m_noTextItem);
|
||||||
@@ -148,15 +143,12 @@ void BoundaryItem::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// item shown if annotation has no text and is not selected
|
// item shown if annotation has no text and is not selected
|
||||||
if (!m_borderItem) {
|
if (!m_borderItem)
|
||||||
m_borderItem = new QGraphicsRectItem(this);
|
m_borderItem = new QGraphicsRectItem(this);
|
||||||
}
|
|
||||||
m_borderItem->setPen(QPen(QBrush(Qt::black), 1, Qt::DashLine));
|
m_borderItem->setPen(QPen(QBrush(Qt::black), 1, Qt::DashLine));
|
||||||
|
|
||||||
updateSelectionMarker();
|
updateSelectionMarker();
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
|
|
||||||
setZValue(BOUNDARY_ITEMS_ZVALUE);
|
setZValue(BOUNDARY_ITEMS_ZVALUE);
|
||||||
|
|
||||||
m_isUpdating = false;
|
m_isUpdating = false;
|
||||||
@@ -200,12 +192,10 @@ void BoundaryItem::alignItemSizeToRaster(IResizable::Side adjustHorizontalSide,
|
|||||||
|
|
||||||
// make sure the new size is at least the minimum size
|
// make sure the new size is at least the minimum size
|
||||||
QSizeF minimumSize = this->minimumSize();
|
QSizeF minimumSize = this->minimumSize();
|
||||||
while (rect.width() + horizDelta < minimumSize.width()) {
|
while (rect.width() + horizDelta < minimumSize.width())
|
||||||
horizDelta += rasterWidth;
|
horizDelta += rasterWidth;
|
||||||
}
|
while (rect.height() + vertDelta < minimumSize.height())
|
||||||
while (rect.height() + vertDelta < minimumSize.height()) {
|
|
||||||
vertDelta += rasterHeight;
|
vertDelta += rasterHeight;
|
||||||
}
|
|
||||||
|
|
||||||
double leftDelta = 0.0;
|
double leftDelta = 0.0;
|
||||||
double rightDelta = 0.0;
|
double rightDelta = 0.0;
|
||||||
@@ -292,49 +282,42 @@ bool BoundaryItem::isEditable() const
|
|||||||
|
|
||||||
void BoundaryItem::edit()
|
void BoundaryItem::edit()
|
||||||
{
|
{
|
||||||
if (m_textItem) {
|
if (m_textItem)
|
||||||
m_textItem->setFocus();
|
m_textItem->setFocus();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void BoundaryItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) {
|
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
|
||||||
m_diagramSceneModel->selectItem(this, event->modifiers() & Qt::ControlModifier);
|
m_diagramSceneModel->selectItem(this, event->modifiers() & Qt::ControlModifier);
|
||||||
}
|
if (event->buttons() & Qt::LeftButton)
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
|
||||||
m_diagramSceneModel->moveSelectedItems(this, QPointF(0.0, 0.0));
|
m_diagramSceneModel->moveSelectedItems(this, QPointF(0.0, 0.0));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void BoundaryItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
if (event->buttons() & Qt::LeftButton)
|
||||||
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void BoundaryItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
||||||
if (event->scenePos() != event->buttonDownScenePos(Qt::LeftButton)) {
|
if (event->scenePos() != event->buttonDownScenePos(Qt::LeftButton))
|
||||||
m_diagramSceneModel->alignSelectedItemsPositionOnRaster();
|
m_diagramSceneModel->alignSelectedItemsPositionOnRaster();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundaryItem::updateSelectionMarker()
|
void BoundaryItem::updateSelectionMarker()
|
||||||
{
|
{
|
||||||
if (isSelected() || m_isSecondarySelected) {
|
if (isSelected() || m_isSecondarySelected) {
|
||||||
if (!m_selectionMarker) {
|
if (!m_selectionMarker)
|
||||||
m_selectionMarker = new RectangularSelectionItem(this, this);
|
m_selectionMarker = new RectangularSelectionItem(this, this);
|
||||||
}
|
|
||||||
m_selectionMarker->setSecondarySelected(isSelected() ? false : m_isSecondarySelected);
|
m_selectionMarker->setSecondarySelected(isSelected() ? false : m_isSecondarySelected);
|
||||||
} else if (m_selectionMarker) {
|
} else if (m_selectionMarker) {
|
||||||
if (m_selectionMarker->scene()) {
|
if (m_selectionMarker->scene())
|
||||||
m_selectionMarker->scene()->removeItem(m_selectionMarker);
|
m_selectionMarker->scene()->removeItem(m_selectionMarker);
|
||||||
}
|
|
||||||
delete m_selectionMarker;
|
delete m_selectionMarker;
|
||||||
m_selectionMarker = 0;
|
m_selectionMarker = 0;
|
||||||
}
|
}
|
||||||
@@ -342,9 +325,8 @@ void BoundaryItem::updateSelectionMarker()
|
|||||||
|
|
||||||
void BoundaryItem::updateSelectionMarkerGeometry(const QRectF &boundaryRect)
|
void BoundaryItem::updateSelectionMarkerGeometry(const QRectF &boundaryRect)
|
||||||
{
|
{
|
||||||
if (m_selectionMarker) {
|
if (m_selectionMarker)
|
||||||
m_selectionMarker->setRect(boundaryRect);
|
m_selectionMarker->setRect(boundaryRect);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Style *BoundaryItem::adaptedStyle()
|
const Style *BoundaryItem::adaptedStyle()
|
||||||
@@ -389,13 +371,11 @@ QSizeF BoundaryItem::calcMinimumGeometry() const
|
|||||||
m_textItem->setTextWidth(-1);
|
m_textItem->setTextWidth(-1);
|
||||||
QSizeF textSize = m_textItem->document()->size();
|
QSizeF textSize = m_textItem->document()->size();
|
||||||
qreal textWidth = textSize.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
|
qreal textWidth = textSize.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
|
||||||
if (textWidth > width) {
|
if (textWidth > width)
|
||||||
width = textWidth;
|
width = textWidth;
|
||||||
}
|
|
||||||
qreal textHeight = textSize.height() + 2 * CONTENTS_BORDER_VERTICAL;
|
qreal textHeight = textSize.height() + 2 * CONTENTS_BORDER_VERTICAL;
|
||||||
if (textHeight > height) {
|
if (textHeight > height)
|
||||||
height = textHeight;
|
height = textHeight;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
|
return GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
|
||||||
}
|
}
|
||||||
@@ -418,12 +398,10 @@ void BoundaryItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QRectF boundaryRect = m_boundary->rect();
|
QRectF boundaryRect = m_boundary->rect();
|
||||||
if (boundaryRect.width() > width) {
|
if (boundaryRect.width() > width)
|
||||||
width = boundaryRect.width();
|
width = boundaryRect.width();
|
||||||
}
|
if (boundaryRect.height() > height)
|
||||||
if (boundaryRect.height() > height) {
|
|
||||||
height = boundaryRect.height();
|
height = boundaryRect.height();
|
||||||
}
|
|
||||||
|
|
||||||
// update sizes and positions
|
// update sizes and positions
|
||||||
double left = -width / 2.0;
|
double left = -width / 2.0;
|
||||||
@@ -437,20 +415,13 @@ void BoundaryItem::updateGeometry()
|
|||||||
// attribute rect is not a real attribute stored on DObject but
|
// attribute rect is not a real attribute stored on DObject but
|
||||||
// a backup for the graphics item used for manual resized and persistency.
|
// a backup for the graphics item used for manual resized and persistency.
|
||||||
m_boundary->setRect(rect);
|
m_boundary->setRect(rect);
|
||||||
|
if (m_borderItem)
|
||||||
if (m_borderItem) {
|
|
||||||
m_borderItem->setRect(rect);
|
m_borderItem->setRect(rect);
|
||||||
}
|
if (m_noTextItem)
|
||||||
|
|
||||||
if (m_noTextItem) {
|
|
||||||
m_noTextItem->setRect(QRectF(-textWidth / 2, top + CONTENTS_BORDER_VERTICAL, textWidth, textHeight));
|
m_noTextItem->setRect(QRectF(-textWidth / 2, top + CONTENTS_BORDER_VERTICAL, textWidth, textHeight));
|
||||||
}
|
if (m_textItem)
|
||||||
|
|
||||||
if (m_textItem) {
|
|
||||||
m_textItem->setPos(-textWidth / 2.0, top + CONTENTS_BORDER_VERTICAL);
|
m_textItem->setPos(-textWidth / 2.0, top + CONTENTS_BORDER_VERTICAL);
|
||||||
}
|
|
||||||
|
|
||||||
updateSelectionMarkerGeometry(rect);
|
updateSelectionMarkerGeometry(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
#include "qmt/diagram_scene/capabilities/selectable.h"
|
#include "qmt/diagram_scene/capabilities/selectable.h"
|
||||||
#include "qmt/diagram_scene/capabilities/editable.h"
|
#include "qmt/diagram_scene/capabilities/editable.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DBoundary;
|
class DBoundary;
|
||||||
@@ -46,7 +45,6 @@ class DiagramSceneModel;
|
|||||||
class RectangularSelectionItem;
|
class RectangularSelectionItem;
|
||||||
class Style;
|
class Style;
|
||||||
|
|
||||||
|
|
||||||
class BoundaryItem :
|
class BoundaryItem :
|
||||||
public QGraphicsItem,
|
public QGraphicsItem,
|
||||||
public IResizable,
|
public IResizable,
|
||||||
@@ -58,110 +56,62 @@ class BoundaryItem :
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
BoundaryItem(DBoundary *boundary, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
BoundaryItem(DBoundary *boundary, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~BoundaryItem();
|
~BoundaryItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DBoundary *boundary() const { return m_boundary; }
|
DBoundary *boundary() const { return m_boundary; }
|
||||||
|
|
||||||
DiagramSceneModel *diagramSceneModel() const { return m_diagramSceneModel; }
|
DiagramSceneModel *diagramSceneModel() const { return m_diagramSceneModel; }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QPointF pos() const;
|
QPointF pos() const;
|
||||||
|
|
||||||
QRectF rect() const;
|
QRectF rect() const;
|
||||||
|
|
||||||
QSizeF minimumSize() const;
|
QSizeF minimumSize() const;
|
||||||
|
|
||||||
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
||||||
|
|
||||||
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void moveDelta(const QPointF &delta);
|
void moveDelta(const QPointF &delta);
|
||||||
|
|
||||||
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isSecondarySelected() const;
|
bool isSecondarySelected() const;
|
||||||
|
|
||||||
void setSecondarySelected(bool secondarySelected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
bool isFocusSelected() const;
|
bool isFocusSelected() const;
|
||||||
|
|
||||||
void setFocusSelected(bool focusSelected);
|
void setFocusSelected(bool focusSelected);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isEditable() const;
|
bool isEditable() const;
|
||||||
|
|
||||||
void edit();
|
void edit();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void updateSelectionMarker();
|
void updateSelectionMarker();
|
||||||
|
|
||||||
void updateSelectionMarkerGeometry(const QRectF &boundaryRect);
|
void updateSelectionMarkerGeometry(const QRectF &boundaryRect);
|
||||||
|
|
||||||
const Style *adaptedStyle();
|
const Style *adaptedStyle();
|
||||||
|
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onContentsChanged();
|
void onContentsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QSizeF calcMinimumGeometry() const;
|
QSizeF calcMinimumGeometry() const;
|
||||||
|
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DBoundary *m_boundary;
|
DBoundary *m_boundary;
|
||||||
|
|
||||||
DiagramSceneModel *m_diagramSceneModel;
|
DiagramSceneModel *m_diagramSceneModel;
|
||||||
|
|
||||||
bool m_isSecondarySelected;
|
bool m_isSecondarySelected;
|
||||||
|
|
||||||
bool m_isFocusSelected;
|
bool m_isFocusSelected;
|
||||||
|
|
||||||
RectangularSelectionItem *m_selectionMarker;
|
RectangularSelectionItem *m_selectionMarker;
|
||||||
|
|
||||||
QGraphicsRectItem *m_borderItem;
|
QGraphicsRectItem *m_borderItem;
|
||||||
|
|
||||||
QGraphicsRectItem *m_noTextItem;
|
QGraphicsRectItem *m_noTextItem;
|
||||||
|
|
||||||
BoundaryTextItem *m_textItem;
|
BoundaryTextItem *m_textItem;
|
||||||
|
|
||||||
bool m_isUpdating;
|
bool m_isUpdating;
|
||||||
|
|
||||||
bool m_isChanged;
|
bool m_isChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_BOUNDARYITEM_H
|
#endif // QMT_BOUNDARYITEM_H
|
||||||
|
|||||||
@@ -60,7 +60,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
static const qreal MINIMUM_AUTO_WIDTH = 80.0;
|
static const qreal MINIMUM_AUTO_WIDTH = 80.0;
|
||||||
@@ -68,7 +67,6 @@ static const qreal MINIMUM_AUTO_HEIGHT = 60.0;
|
|||||||
static const qreal BODY_VERT_BORDER = 4.0;
|
static const qreal BODY_VERT_BORDER = 4.0;
|
||||||
static const qreal BODY_HORIZ_BORDER = 4.0;
|
static const qreal BODY_HORIZ_BORDER = 4.0;
|
||||||
|
|
||||||
|
|
||||||
ClassItem::ClassItem(DClass *klass, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
ClassItem::ClassItem(DClass *klass, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(klass, diagramSceneModel, parent),
|
: ObjectItem(klass, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
@@ -109,9 +107,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// custom icon
|
// custom icon
|
||||||
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon)
|
||||||
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
||||||
}
|
|
||||||
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
||||||
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
||||||
m_customIcon->setBrush(style->fillBrush());
|
m_customIcon->setBrush(style->fillBrush());
|
||||||
@@ -125,9 +122,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// shape
|
// shape
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (!m_shape) {
|
if (!m_shape)
|
||||||
m_shape = new QGraphicsRectItem(this);
|
m_shape = new QGraphicsRectItem(this);
|
||||||
}
|
|
||||||
m_shape->setBrush(style->fillBrush());
|
m_shape->setBrush(style->fillBrush());
|
||||||
m_shape->setPen(style->outerLinePen());
|
m_shape->setPen(style->outerLinePen());
|
||||||
m_shape->setZValue(SHAPE_ZVALUE);
|
m_shape->setZValue(SHAPE_ZVALUE);
|
||||||
@@ -142,9 +138,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// namespace
|
// namespace
|
||||||
if (!diagramClass->umlNamespace().isEmpty()) {
|
if (!diagramClass->umlNamespace().isEmpty()) {
|
||||||
if (!m_namespace) {
|
if (!m_namespace)
|
||||||
m_namespace = new QGraphicsSimpleTextItem(this);
|
m_namespace = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
m_namespace->setFont(style->smallFont());
|
m_namespace->setFont(style->smallFont());
|
||||||
m_namespace->setBrush(style->textBrush());
|
m_namespace->setBrush(style->textBrush());
|
||||||
m_namespace->setText(diagramClass->umlNamespace());
|
m_namespace->setText(diagramClass->umlNamespace());
|
||||||
@@ -156,17 +151,15 @@ void ClassItem::update()
|
|||||||
|
|
||||||
DClass::TemplateDisplay templateDisplay = diagramClass->templateDisplay();
|
DClass::TemplateDisplay templateDisplay = diagramClass->templateDisplay();
|
||||||
if (templateDisplay == DClass::TemplateSmart) {
|
if (templateDisplay == DClass::TemplateSmart) {
|
||||||
if (m_customIcon) {
|
if (m_customIcon)
|
||||||
templateDisplay = DClass::TemplateName;
|
templateDisplay = DClass::TemplateName;
|
||||||
} else {
|
else
|
||||||
templateDisplay = DClass::TemplateBox;
|
templateDisplay = DClass::TemplateBox;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// class name
|
// class name
|
||||||
if (!m_className) {
|
if (!m_className)
|
||||||
m_className = new QGraphicsSimpleTextItem(this);
|
m_className = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
m_className->setFont(style->headerFont());
|
m_className->setFont(style->headerFont());
|
||||||
m_className->setBrush(style->textBrush());
|
m_className->setBrush(style->textBrush());
|
||||||
if (templateDisplay == DClass::TemplateName && !diagramClass->templateParameters().isEmpty()) {
|
if (templateDisplay == DClass::TemplateName && !diagramClass->templateParameters().isEmpty()) {
|
||||||
@@ -174,9 +167,8 @@ void ClassItem::update()
|
|||||||
name += QLatin1Char('<');
|
name += QLatin1Char('<');
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach (const QString &p, diagramClass->templateParameters()) {
|
foreach (const QString &p, diagramClass->templateParameters()) {
|
||||||
if (!first) {
|
if (!first)
|
||||||
name += QLatin1Char(',');
|
name += QLatin1Char(',');
|
||||||
}
|
|
||||||
name += p;
|
name += p;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
@@ -188,9 +180,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// context
|
// context
|
||||||
if (showContext()) {
|
if (showContext()) {
|
||||||
if (!m_contextLabel) {
|
if (!m_contextLabel)
|
||||||
m_contextLabel = new ContextLabelItem(this);
|
m_contextLabel = new ContextLabelItem(this);
|
||||||
}
|
|
||||||
m_contextLabel->setFont(style->smallFont());
|
m_contextLabel->setFont(style->smallFont());
|
||||||
m_contextLabel->setBrush(style->textBrush());
|
m_contextLabel->setBrush(style->textBrush());
|
||||||
m_contextLabel->setContext(object()->context());
|
m_contextLabel->setContext(object()->context());
|
||||||
@@ -202,9 +193,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// attributes separator
|
// attributes separator
|
||||||
if (m_shape || !m_attributesText.isEmpty() || !m_methodsText.isEmpty()) {
|
if (m_shape || !m_attributesText.isEmpty() || !m_methodsText.isEmpty()) {
|
||||||
if (!m_attributesSeparator) {
|
if (!m_attributesSeparator)
|
||||||
m_attributesSeparator = new QGraphicsLineItem(this);
|
m_attributesSeparator = new QGraphicsLineItem(this);
|
||||||
}
|
|
||||||
m_attributesSeparator->setPen(style->innerLinePen());
|
m_attributesSeparator->setPen(style->innerLinePen());
|
||||||
m_attributesSeparator->setZValue(SHAPE_DETAILS_ZVALUE);
|
m_attributesSeparator->setZValue(SHAPE_DETAILS_ZVALUE);
|
||||||
} else if (m_attributesSeparator) {
|
} else if (m_attributesSeparator) {
|
||||||
@@ -215,9 +205,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
if (!m_attributesText.isEmpty()) {
|
if (!m_attributesText.isEmpty()) {
|
||||||
if (!m_attributes) {
|
if (!m_attributes)
|
||||||
m_attributes = new QGraphicsTextItem(this);
|
m_attributes = new QGraphicsTextItem(this);
|
||||||
}
|
|
||||||
m_attributes->setFont(style->normalFont());
|
m_attributes->setFont(style->normalFont());
|
||||||
//m_attributes->setBrush(style->textBrush());
|
//m_attributes->setBrush(style->textBrush());
|
||||||
m_attributes->setDefaultTextColor(style->textBrush().color());
|
m_attributes->setDefaultTextColor(style->textBrush().color());
|
||||||
@@ -230,9 +219,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// methods separator
|
// methods separator
|
||||||
if (m_shape || !m_attributesText.isEmpty() || !m_methodsText.isEmpty()) {
|
if (m_shape || !m_attributesText.isEmpty() || !m_methodsText.isEmpty()) {
|
||||||
if (!m_methodsSeparator) {
|
if (!m_methodsSeparator)
|
||||||
m_methodsSeparator = new QGraphicsLineItem(this);
|
m_methodsSeparator = new QGraphicsLineItem(this);
|
||||||
}
|
|
||||||
m_methodsSeparator->setPen(style->innerLinePen());
|
m_methodsSeparator->setPen(style->innerLinePen());
|
||||||
m_methodsSeparator->setZValue(SHAPE_DETAILS_ZVALUE);
|
m_methodsSeparator->setZValue(SHAPE_DETAILS_ZVALUE);
|
||||||
} else if (m_methodsSeparator) {
|
} else if (m_methodsSeparator) {
|
||||||
@@ -243,9 +231,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// methods
|
// methods
|
||||||
if (!m_methodsText.isEmpty()) {
|
if (!m_methodsText.isEmpty()) {
|
||||||
if (!m_methods) {
|
if (!m_methods)
|
||||||
m_methods = new QGraphicsTextItem(this);
|
m_methods = new QGraphicsTextItem(this);
|
||||||
}
|
|
||||||
m_methods->setFont(style->normalFont());
|
m_methods->setFont(style->normalFont());
|
||||||
//m_methods->setBrush(style->textBrush());
|
//m_methods->setBrush(style->textBrush());
|
||||||
m_methods->setDefaultTextColor(style->textBrush().color());
|
m_methods->setDefaultTextColor(style->textBrush().color());
|
||||||
@@ -258,9 +245,8 @@ void ClassItem::update()
|
|||||||
|
|
||||||
// template parameters
|
// template parameters
|
||||||
if (templateDisplay == DClass::TemplateBox && !diagramClass->templateParameters().isEmpty()) {
|
if (templateDisplay == DClass::TemplateBox && !diagramClass->templateParameters().isEmpty()) {
|
||||||
if (!m_templateParameterBox) {
|
if (!m_templateParameterBox)
|
||||||
m_templateParameterBox = new TemplateParameterBox(this);
|
m_templateParameterBox = new TemplateParameterBox(this);
|
||||||
}
|
|
||||||
QPen pen = style->outerLinePen();
|
QPen pen = style->outerLinePen();
|
||||||
pen.setStyle(Qt::DashLine);
|
pen.setStyle(Qt::DashLine);
|
||||||
m_templateParameterBox->setPen(pen);
|
m_templateParameterBox->setPen(pen);
|
||||||
@@ -293,7 +279,6 @@ void ClassItem::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateAlignmentButtons();
|
updateAlignmentButtons();
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,9 +323,8 @@ void ClassItem::relationDrawn(const QString &id, const QPointF &toScenePos, cons
|
|||||||
}
|
}
|
||||||
} else if (id == QLatin1String("dependency")) {
|
} else if (id == QLatin1String("dependency")) {
|
||||||
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
||||||
if (dependantObject) {
|
if (dependantObject)
|
||||||
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
||||||
}
|
|
||||||
} else if (id == QLatin1String("association")) {
|
} else if (id == QLatin1String("association")) {
|
||||||
DClass *assoziatedClass = dynamic_cast<DClass *>(targetElement);
|
DClass *assoziatedClass = dynamic_cast<DClass *>(targetElement);
|
||||||
if (assoziatedClass) {
|
if (assoziatedClass) {
|
||||||
@@ -379,9 +363,8 @@ QSizeF ClassItem::calcMinimumGeometry() const
|
|||||||
double width = 0.0;
|
double width = 0.0;
|
||||||
double height = 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);
|
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
|
||||||
}
|
|
||||||
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
||||||
@@ -400,19 +383,16 @@ QSizeF ClassItem::calcMinimumGeometry() const
|
|||||||
width = std::max(width, m_className->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, m_className->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
height += m_className->boundingRect().height();
|
height += m_className->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_contextLabel) {
|
if (m_contextLabel)
|
||||||
height += m_contextLabel->height();
|
height += m_contextLabel->height();
|
||||||
}
|
if (m_attributesSeparator)
|
||||||
if (m_attributesSeparator) {
|
|
||||||
height += 8.0;
|
height += 8.0;
|
||||||
}
|
|
||||||
if (m_attributes) {
|
if (m_attributes) {
|
||||||
width = std::max(width, m_attributes->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, m_attributes->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
height += m_attributes->boundingRect().height();
|
height += m_attributes->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_methodsSeparator) {
|
if (m_methodsSeparator)
|
||||||
height += 8.0;
|
height += 8.0;
|
||||||
}
|
|
||||||
if (m_methods) {
|
if (m_methods) {
|
||||||
width = std::max(width, m_methods->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
width = std::max(width, m_methods->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
height += m_methods->boundingRect().height();
|
height += m_methods->boundingRect().height();
|
||||||
@@ -436,21 +416,17 @@ void ClassItem::updateGeometry()
|
|||||||
|
|
||||||
if (object()->isAutoSized()) {
|
if (object()->isAutoSized()) {
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (width < MINIMUM_AUTO_WIDTH) {
|
if (width < MINIMUM_AUTO_WIDTH)
|
||||||
width = MINIMUM_AUTO_WIDTH;
|
width = MINIMUM_AUTO_WIDTH;
|
||||||
}
|
if (height < MINIMUM_AUTO_HEIGHT)
|
||||||
if (height < MINIMUM_AUTO_HEIGHT) {
|
|
||||||
height = MINIMUM_AUTO_HEIGHT;
|
height = MINIMUM_AUTO_HEIGHT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QRectF rect = object()->rect();
|
QRectF rect = object()->rect();
|
||||||
if (rect.width() > width) {
|
if (rect.width() > width)
|
||||||
width = rect.width();
|
width = rect.width();
|
||||||
}
|
if (rect.height() > height)
|
||||||
if (rect.height() > height) {
|
|
||||||
height = rect.height();
|
height = rect.height();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update sizes and positions
|
// update sizes and positions
|
||||||
@@ -475,9 +451,8 @@ void ClassItem::updateGeometry()
|
|||||||
y += height;
|
y += height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_shape) {
|
if (m_shape)
|
||||||
m_shape->setRect(rect);
|
m_shape->setRect(rect);
|
||||||
}
|
|
||||||
|
|
||||||
y += BODY_VERT_BORDER;
|
y += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
||||||
@@ -497,11 +472,10 @@ void ClassItem::updateGeometry()
|
|||||||
y += m_className->boundingRect().height();
|
y += m_className->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_contextLabel) {
|
if (m_contextLabel) {
|
||||||
if (m_customIcon) {
|
if (m_customIcon)
|
||||||
m_contextLabel->resetMaxWidth();
|
m_contextLabel->resetMaxWidth();
|
||||||
} else {
|
else
|
||||||
m_contextLabel->setMaxWidth(width - 2 * BODY_HORIZ_BORDER);
|
m_contextLabel->setMaxWidth(width - 2 * BODY_HORIZ_BORDER);
|
||||||
}
|
|
||||||
m_contextLabel->setPos(-m_contextLabel->boundingRect().width() / 2.0, y);
|
m_contextLabel->setPos(-m_contextLabel->boundingRect().width() / 2.0, y);
|
||||||
y += m_contextLabel->boundingRect().height();
|
y += m_contextLabel->boundingRect().height();
|
||||||
}
|
}
|
||||||
@@ -511,11 +485,10 @@ void ClassItem::updateGeometry()
|
|||||||
y += 8.0;
|
y += 8.0;
|
||||||
}
|
}
|
||||||
if (m_attributes) {
|
if (m_attributes) {
|
||||||
if (m_customIcon) {
|
if (m_customIcon)
|
||||||
m_attributes->setPos(-m_attributes->boundingRect().width() / 2.0, y);
|
m_attributes->setPos(-m_attributes->boundingRect().width() / 2.0, y);
|
||||||
} else {
|
else
|
||||||
m_attributes->setPos(left + BODY_HORIZ_BORDER, y);
|
m_attributes->setPos(left + BODY_HORIZ_BORDER, y);
|
||||||
}
|
|
||||||
y += m_attributes->boundingRect().height();
|
y += m_attributes->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_methodsSeparator) {
|
if (m_methodsSeparator) {
|
||||||
@@ -524,11 +497,10 @@ void ClassItem::updateGeometry()
|
|||||||
y += 8.0;
|
y += 8.0;
|
||||||
}
|
}
|
||||||
if (m_methods) {
|
if (m_methods) {
|
||||||
if (m_customIcon) {
|
if (m_customIcon)
|
||||||
m_methods->setPos(-m_methods->boundingRect().width() / 2.0, y);
|
m_methods->setPos(-m_methods->boundingRect().width() / 2.0, y);
|
||||||
} else {
|
else
|
||||||
m_methods->setPos(left + BODY_HORIZ_BORDER, y);
|
m_methods->setPos(left + BODY_HORIZ_BORDER, y);
|
||||||
}
|
|
||||||
y += m_methods->boundingRect().height();
|
y += m_methods->boundingRect().height();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,22 +511,18 @@ void ClassItem::updateGeometry()
|
|||||||
m_templateParameterBox->setBreakLines(true);
|
m_templateParameterBox->setBreakLines(true);
|
||||||
x = right - m_templateParameterBox->boundingRect().width() * 0.8;
|
x = right - m_templateParameterBox->boundingRect().width() * 0.8;
|
||||||
}
|
}
|
||||||
if (x < 0) {
|
if (x < 0)
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
|
||||||
m_templateParameterBox->setPos(x, top - m_templateParameterBox->boundingRect().height() + BODY_VERT_BORDER);
|
m_templateParameterBox->setPos(x, top - m_templateParameterBox->boundingRect().height() + BODY_VERT_BORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSelectionMarkerGeometry(rect);
|
updateSelectionMarkerGeometry(rect);
|
||||||
|
|
||||||
if (m_relationStarter) {
|
if (m_relationStarter)
|
||||||
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
||||||
}
|
|
||||||
|
|
||||||
updateAlignmentButtonsGeometry(rect);
|
updateAlignmentButtonsGeometry(rect);
|
||||||
|
|
||||||
updateDepth();
|
updateDepth();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassItem::updateMembers(const Style *style)
|
void ClassItem::updateMembers(const Style *style)
|
||||||
@@ -582,7 +550,6 @@ void ClassItem::updateMembers(const Style *style)
|
|||||||
bool useGroupVisibility = false;
|
bool useGroupVisibility = false;
|
||||||
|
|
||||||
foreach (const MClassMember &member, dclass->members()) {
|
foreach (const MClassMember &member, dclass->members()) {
|
||||||
|
|
||||||
switch (member.memberType()) {
|
switch (member.memberType()) {
|
||||||
case MClassMember::MemberUndefined:
|
case MClassMember::MemberUndefined:
|
||||||
QMT_CHECK(false);
|
QMT_CHECK(false);
|
||||||
@@ -599,9 +566,8 @@ void ClassItem::updateMembers(const Style *style)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!text->isEmpty()) {
|
if (!text->isEmpty())
|
||||||
*text += QStringLiteral("<br/>");
|
*text += QStringLiteral("<br/>");
|
||||||
}
|
|
||||||
|
|
||||||
bool addNewline = false;
|
bool addNewline = false;
|
||||||
bool addSpace = false;
|
bool addSpace = false;
|
||||||
@@ -642,16 +608,14 @@ void ClassItem::updateMembers(const Style *style)
|
|||||||
*currentVisibility = member.visibility();
|
*currentVisibility = member.visibility();
|
||||||
}
|
}
|
||||||
if (member.group() != currentGroup) {
|
if (member.group() != currentGroup) {
|
||||||
if (addSpace) {
|
if (addSpace)
|
||||||
*text += QStringLiteral(" ");
|
*text += QStringLiteral(" ");
|
||||||
}
|
|
||||||
*text += QString(QStringLiteral("[%1]")).arg(member.group());
|
*text += QString(QStringLiteral("[%1]")).arg(member.group());
|
||||||
addNewline = true;
|
addNewline = true;
|
||||||
*currentGroup = member.group();
|
*currentGroup = member.group();
|
||||||
}
|
}
|
||||||
if (addNewline) {
|
if (addNewline)
|
||||||
*text += QStringLiteral("<br/>");
|
*text += QStringLiteral("<br/>");
|
||||||
}
|
|
||||||
|
|
||||||
addSpace = false;
|
addSpace = false;
|
||||||
bool haveSignal = false;
|
bool haveSignal = false;
|
||||||
@@ -710,33 +674,26 @@ void ClassItem::updateMembers(const Style *style)
|
|||||||
*text += haveIconFonts ? QString(QChar(0xe9cb)) : QStringLiteral("$");
|
*text += haveIconFonts ? QString(QChar(0xe9cb)) : QStringLiteral("$");
|
||||||
addSpace = true;
|
addSpace = true;
|
||||||
}
|
}
|
||||||
if (addSpace) {
|
if (addSpace)
|
||||||
*text += QStringLiteral(" ");
|
*text += QStringLiteral(" ");
|
||||||
}
|
if (member.properties() & MClassMember::PropertyQinvokable)
|
||||||
if (member.properties() & MClassMember::PropertyQinvokable) {
|
|
||||||
*text += QStringLiteral("invokable ");
|
*text += QStringLiteral("invokable ");
|
||||||
}
|
|
||||||
if (!member.stereotypes().isEmpty()) {
|
if (!member.stereotypes().isEmpty()) {
|
||||||
*text += StereotypesItem::format(member.stereotypes());
|
*text += StereotypesItem::format(member.stereotypes());
|
||||||
*text += QStringLiteral(" ");
|
*text += QStringLiteral(" ");
|
||||||
}
|
}
|
||||||
if (member.properties() & MClassMember::PropertyVirtual) {
|
if (member.properties() & MClassMember::PropertyVirtual)
|
||||||
*text += QStringLiteral("virtual ");
|
*text += QStringLiteral("virtual ");
|
||||||
}
|
|
||||||
*text += member.declaration();
|
*text += member.declaration();
|
||||||
if (member.properties() & MClassMember::PropertyConst) {
|
if (member.properties() & MClassMember::PropertyConst)
|
||||||
*text += QStringLiteral(" const");
|
*text += QStringLiteral(" const");
|
||||||
}
|
if (member.properties() & MClassMember::PropertyOverride)
|
||||||
if (member.properties() & MClassMember::PropertyOverride) {
|
|
||||||
*text += QStringLiteral(" override");
|
*text += QStringLiteral(" override");
|
||||||
}
|
if (member.properties() & MClassMember::PropertyFinal)
|
||||||
if (member.properties() & MClassMember::PropertyFinal) {
|
|
||||||
*text += QStringLiteral(" final");
|
*text += QStringLiteral(" final");
|
||||||
}
|
if (member.properties() & MClassMember::PropertyAbstract)
|
||||||
if (member.properties() & MClassMember::PropertyAbstract) {
|
|
||||||
*text += QStringLiteral(" = 0");
|
*text += QStringLiteral(" = 0");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class QGraphicsLineItem;
|
|||||||
class QGraphicsTextItem;
|
class QGraphicsTextItem;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DiagramSceneModel;
|
class DiagramSceneModel;
|
||||||
@@ -53,77 +52,45 @@ class TemplateParameterBox;
|
|||||||
class RelationStarter;
|
class RelationStarter;
|
||||||
class Style;
|
class Style;
|
||||||
|
|
||||||
class ClassItem :
|
class ClassItem : public ObjectItem, public IRelationable
|
||||||
public ObjectItem,
|
|
||||||
public IRelationable
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClassItem(DClass *klass, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
ClassItem(DClass *klass, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~ClassItem();
|
~ClassItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QSizeF minimumSize() const;
|
QSizeF minimumSize() const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QPointF relationStartPos() const;
|
QPointF relationStartPos() const;
|
||||||
|
|
||||||
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool extendContextMenu(QMenu *menu);
|
bool extendContextMenu(QMenu *menu);
|
||||||
|
|
||||||
bool handleSelectedContextMenuAction(QAction *action);
|
bool handleSelectedContextMenuAction(QAction *action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QSizeF calcMinimumGeometry() const;
|
QSizeF calcMinimumGeometry() const;
|
||||||
|
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
|
||||||
void updateMembers(const Style *style);
|
void updateMembers(const Style *style);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
CustomIconItem *m_customIcon;
|
CustomIconItem *m_customIcon;
|
||||||
|
|
||||||
QGraphicsRectItem *m_shape;
|
QGraphicsRectItem *m_shape;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_namespace;
|
QGraphicsSimpleTextItem *m_namespace;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_className;
|
QGraphicsSimpleTextItem *m_className;
|
||||||
|
|
||||||
ContextLabelItem *m_contextLabel;
|
ContextLabelItem *m_contextLabel;
|
||||||
|
|
||||||
QGraphicsLineItem *m_attributesSeparator;
|
QGraphicsLineItem *m_attributesSeparator;
|
||||||
|
|
||||||
QString m_attributesText;
|
QString m_attributesText;
|
||||||
|
|
||||||
QGraphicsTextItem *m_attributes;
|
QGraphicsTextItem *m_attributes;
|
||||||
|
|
||||||
QGraphicsLineItem *m_methodsSeparator;
|
QGraphicsLineItem *m_methodsSeparator;
|
||||||
|
|
||||||
QString m_methodsText;
|
QString m_methodsText;
|
||||||
|
|
||||||
QGraphicsTextItem *m_methods;
|
QGraphicsTextItem *m_methods;
|
||||||
|
|
||||||
TemplateParameterBox *m_templateParameterBox;
|
TemplateParameterBox *m_templateParameterBox;
|
||||||
|
|
||||||
RelationStarter *m_relationStarter;
|
RelationStarter *m_relationStarter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_GRAPHICSCLASSITEM_H
|
#endif // QMT_GRAPHICSCLASSITEM_H
|
||||||
|
|||||||
@@ -54,7 +54,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
static const qreal RECT_HEIGHT = 15.0;
|
static const qreal RECT_HEIGHT = 15.0;
|
||||||
@@ -65,7 +64,6 @@ static const qreal LOWER_RECT_MIN_Y = 10.0;
|
|||||||
static const qreal BODY_VERT_BORDER = 4.0;
|
static const qreal BODY_VERT_BORDER = 4.0;
|
||||||
static const qreal BODY_HORIZ_BORDER = 4.0;
|
static const qreal BODY_HORIZ_BORDER = 4.0;
|
||||||
|
|
||||||
|
|
||||||
ComponentItem::ComponentItem(DComponent *component, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
ComponentItem::ComponentItem(DComponent *component, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(component, diagramSceneModel, parent),
|
: ObjectItem(component, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
@@ -85,16 +83,14 @@ ComponentItem::~ComponentItem()
|
|||||||
void ComponentItem::update()
|
void ComponentItem::update()
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
updateStereotypeIconDisplay();
|
updateStereotypeIconDisplay();
|
||||||
|
|
||||||
const Style *style = adaptedStyle(stereotypeIconId());
|
const Style *style = adaptedStyle(stereotypeIconId());
|
||||||
|
|
||||||
// custom icon
|
// custom icon
|
||||||
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon)
|
||||||
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
||||||
}
|
|
||||||
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
||||||
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
||||||
m_customIcon->setBrush(style->fillBrush());
|
m_customIcon->setBrush(style->fillBrush());
|
||||||
@@ -109,22 +105,19 @@ void ComponentItem::update()
|
|||||||
// shape
|
// shape
|
||||||
bool deleteRects = false;
|
bool deleteRects = false;
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (!m_shape) {
|
if (!m_shape)
|
||||||
m_shape = new QGraphicsRectItem(this);
|
m_shape = new QGraphicsRectItem(this);
|
||||||
}
|
|
||||||
m_shape->setBrush(style->fillBrush());
|
m_shape->setBrush(style->fillBrush());
|
||||||
m_shape->setPen(style->outerLinePen());
|
m_shape->setPen(style->outerLinePen());
|
||||||
m_shape->setZValue(SHAPE_ZVALUE);
|
m_shape->setZValue(SHAPE_ZVALUE);
|
||||||
if (!hasPlainShape()) {
|
if (!hasPlainShape()) {
|
||||||
if (!m_upperRect) {
|
if (!m_upperRect)
|
||||||
m_upperRect = new QGraphicsRectItem(this);
|
m_upperRect = new QGraphicsRectItem(this);
|
||||||
}
|
|
||||||
m_upperRect->setBrush(style->fillBrush());
|
m_upperRect->setBrush(style->fillBrush());
|
||||||
m_upperRect->setPen(style->outerLinePen());
|
m_upperRect->setPen(style->outerLinePen());
|
||||||
m_upperRect->setZValue(SHAPE_DETAILS_ZVALUE);
|
m_upperRect->setZValue(SHAPE_DETAILS_ZVALUE);
|
||||||
if (!m_lowerRect) {
|
if (!m_lowerRect)
|
||||||
m_lowerRect = new QGraphicsRectItem(this);
|
m_lowerRect = new QGraphicsRectItem(this);
|
||||||
}
|
|
||||||
m_lowerRect->setBrush(style->fillBrush());
|
m_lowerRect->setBrush(style->fillBrush());
|
||||||
m_lowerRect->setPen(style->outerLinePen());
|
m_lowerRect->setPen(style->outerLinePen());
|
||||||
m_lowerRect->setZValue(SHAPE_DETAILS_ZVALUE);
|
m_lowerRect->setZValue(SHAPE_DETAILS_ZVALUE);
|
||||||
@@ -156,18 +149,16 @@ void ComponentItem::update()
|
|||||||
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), style);
|
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), style);
|
||||||
|
|
||||||
// component name
|
// component name
|
||||||
if (!m_componentName) {
|
if (!m_componentName)
|
||||||
m_componentName = new QGraphicsSimpleTextItem(this);
|
m_componentName = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
m_componentName->setFont(style->headerFont());
|
m_componentName->setFont(style->headerFont());
|
||||||
m_componentName->setBrush(style->textBrush());
|
m_componentName->setBrush(style->textBrush());
|
||||||
m_componentName->setText(object()->name());
|
m_componentName->setText(object()->name());
|
||||||
|
|
||||||
// context
|
// context
|
||||||
if (showContext()) {
|
if (showContext()) {
|
||||||
if (!m_contextLabel) {
|
if (!m_contextLabel)
|
||||||
m_contextLabel = new ContextLabelItem(this);
|
m_contextLabel = new ContextLabelItem(this);
|
||||||
}
|
|
||||||
m_contextLabel->setFont(style->smallFont());
|
m_contextLabel->setFont(style->smallFont());
|
||||||
m_contextLabel->setBrush(style->textBrush());
|
m_contextLabel->setBrush(style->textBrush());
|
||||||
m_contextLabel->setContext(object()->context());
|
m_contextLabel->setContext(object()->context());
|
||||||
@@ -188,15 +179,13 @@ void ComponentItem::update()
|
|||||||
m_relationStarter->addArrow(QStringLiteral("dependency"), ArrowItem::ShaftDashed, ArrowItem::HeadOpen);
|
m_relationStarter->addArrow(QStringLiteral("dependency"), ArrowItem::ShaftDashed, ArrowItem::HeadOpen);
|
||||||
}
|
}
|
||||||
} else if (m_relationStarter) {
|
} else if (m_relationStarter) {
|
||||||
if (m_relationStarter->scene()) {
|
if (m_relationStarter->scene())
|
||||||
m_relationStarter->scene()->removeItem(m_relationStarter);
|
m_relationStarter->scene()->removeItem(m_relationStarter);
|
||||||
}
|
|
||||||
delete m_relationStarter;
|
delete m_relationStarter;
|
||||||
m_relationStarter = 0;
|
m_relationStarter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAlignmentButtons();
|
updateAlignmentButtons();
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +197,7 @@ bool ComponentItem::intersectShapeWithLine(const QLineF &line, QPointF *intersec
|
|||||||
QRectF rect = object()->rect();
|
QRectF rect = object()->rect();
|
||||||
rect.translate(object()->pos());
|
rect.translate(object()->pos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
} else if (hasPlainShape()){
|
} else if (hasPlainShape()) {
|
||||||
QRectF rect = object()->rect();
|
QRectF rect = object()->rect();
|
||||||
rect.translate(object()->pos());
|
rect.translate(object()->pos());
|
||||||
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
|
||||||
@@ -254,9 +243,8 @@ void ComponentItem::relationDrawn(const QString &id, const QPointF &toScenePos,
|
|||||||
if (targetElement) {
|
if (targetElement) {
|
||||||
if (id == QStringLiteral("dependency")) {
|
if (id == QStringLiteral("dependency")) {
|
||||||
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
||||||
if (dependantObject) {
|
if (dependantObject)
|
||||||
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,9 +261,8 @@ QSizeF ComponentItem::calcMinimumGeometry() const
|
|||||||
double width = 0.0;
|
double width = 0.0;
|
||||||
double height = 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);
|
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
|
||||||
}
|
|
||||||
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
||||||
@@ -290,17 +277,15 @@ QSizeF ComponentItem::calcMinimumGeometry() const
|
|||||||
width = std::max(width, m_componentName->boundingRect().width());
|
width = std::max(width, m_componentName->boundingRect().width());
|
||||||
height += m_componentName->boundingRect().height();
|
height += m_componentName->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_contextLabel) {
|
if (m_contextLabel)
|
||||||
height += m_contextLabel->height();
|
height += m_contextLabel->height();
|
||||||
}
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
|
|
||||||
if (!hasPlainShape()) {
|
if (!hasPlainShape()) {
|
||||||
width = RECT_WIDTH * 0.5 + BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER + RECT_WIDTH * 0.5;
|
width = RECT_WIDTH * 0.5 + BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER + RECT_WIDTH * 0.5;
|
||||||
double minHeight = UPPER_RECT_Y + RECT_HEIGHT + RECT_Y_DISTANCE + RECT_HEIGHT + LOWER_RECT_MIN_Y;
|
double minHeight = UPPER_RECT_Y + RECT_HEIGHT + RECT_Y_DISTANCE + RECT_HEIGHT + LOWER_RECT_MIN_Y;
|
||||||
if (height < minHeight) {
|
if (height < minHeight)
|
||||||
height = minHeight;
|
height = minHeight;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
width = BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER;
|
width = BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER;
|
||||||
}
|
}
|
||||||
@@ -324,12 +309,10 @@ void ComponentItem::updateGeometry()
|
|||||||
// nothing
|
// nothing
|
||||||
} else {
|
} else {
|
||||||
QRectF rect = object()->rect();
|
QRectF rect = object()->rect();
|
||||||
if (rect.width() > width) {
|
if (rect.width() > width)
|
||||||
width = rect.width();
|
width = rect.width();
|
||||||
}
|
if (rect.height() > height)
|
||||||
if (rect.height() > height) {
|
|
||||||
height = rect.height();
|
height = rect.height();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update sizes and positions
|
// update sizes and positions
|
||||||
@@ -354,9 +337,8 @@ void ComponentItem::updateGeometry()
|
|||||||
y += height;
|
y += height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_shape) {
|
if (m_shape)
|
||||||
m_shape->setRect(rect);
|
m_shape->setRect(rect);
|
||||||
}
|
|
||||||
|
|
||||||
if (m_upperRect) {
|
if (m_upperRect) {
|
||||||
QRectF upperRect(0, 0, RECT_WIDTH, RECT_HEIGHT);
|
QRectF upperRect(0, 0, RECT_WIDTH, RECT_HEIGHT);
|
||||||
@@ -396,13 +378,11 @@ void ComponentItem::updateGeometry()
|
|||||||
|
|
||||||
updateSelectionMarkerGeometry(rect);
|
updateSelectionMarkerGeometry(rect);
|
||||||
|
|
||||||
if (m_relationStarter) {
|
if (m_relationStarter)
|
||||||
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
||||||
}
|
|
||||||
|
|
||||||
updateAlignmentButtonsGeometry(rect);
|
updateAlignmentButtonsGeometry(rect);
|
||||||
|
|
||||||
updateDepth();
|
updateDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class QGraphicsSimpleTextItem;
|
|||||||
class QGraphicsLineItem;
|
class QGraphicsLineItem;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DiagramSceneModel;
|
class DiagramSceneModel;
|
||||||
@@ -50,66 +49,38 @@ class CustomIconItem;
|
|||||||
class ContextLabelItem;
|
class ContextLabelItem;
|
||||||
class RelationStarter;
|
class RelationStarter;
|
||||||
|
|
||||||
|
class ComponentItem : public ObjectItem, public IRelationable
|
||||||
class ComponentItem :
|
|
||||||
public ObjectItem,
|
|
||||||
public IRelationable
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComponentItem(DComponent *component, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
ComponentItem(DComponent *component, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~ComponentItem();
|
~ComponentItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QSizeF minimumSize() const;
|
QSizeF minimumSize() const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QList<Latch> horizontalLatches(Action action, bool grabbedItem) const;
|
QList<Latch> horizontalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
QList<Latch> verticalLatches(Action action, bool grabbedItem) const;
|
QList<Latch> verticalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QPointF relationStartPos() const;
|
QPointF relationStartPos() const;
|
||||||
|
|
||||||
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool hasPlainShape() const;
|
bool hasPlainShape() const;
|
||||||
|
|
||||||
QSizeF calcMinimumGeometry() const;
|
QSizeF calcMinimumGeometry() const;
|
||||||
|
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
CustomIconItem *m_customIcon;
|
CustomIconItem *m_customIcon;
|
||||||
|
|
||||||
QGraphicsRectItem *m_shape;
|
QGraphicsRectItem *m_shape;
|
||||||
|
|
||||||
QGraphicsRectItem *m_upperRect;
|
QGraphicsRectItem *m_upperRect;
|
||||||
|
|
||||||
QGraphicsRectItem *m_lowerRect;
|
QGraphicsRectItem *m_lowerRect;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_componentName;
|
QGraphicsSimpleTextItem *m_componentName;
|
||||||
|
|
||||||
ContextLabelItem *m_contextLabel;
|
ContextLabelItem *m_contextLabel;
|
||||||
|
|
||||||
RelationStarter *m_relationStarter;
|
RelationStarter *m_relationStarter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_GRAPHICSCOMPONENTITEM_H
|
#endif // QMT_GRAPHICSCOMPONENTITEM_H
|
||||||
|
|||||||
@@ -47,7 +47,6 @@
|
|||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
static const qreal MINIMUM_AUTO_WIDTH = 60.0;
|
static const qreal MINIMUM_AUTO_WIDTH = 60.0;
|
||||||
@@ -58,7 +57,6 @@ static const qreal FOLD_HEIGHT = 15.0;
|
|||||||
static const qreal BODY_HORIZ_BORDER = 4.0;
|
static const qreal BODY_HORIZ_BORDER = 4.0;
|
||||||
static const qreal BODY_VERT_BORDER = 4.0;
|
static const qreal BODY_VERT_BORDER = 4.0;
|
||||||
|
|
||||||
|
|
||||||
DiagramItem::DiagramItem(DDiagram *diagram, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
DiagramItem::DiagramItem(DDiagram *diagram, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(diagram, diagramSceneModel, parent),
|
: ObjectItem(diagram, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
@@ -75,16 +73,14 @@ DiagramItem::~DiagramItem()
|
|||||||
void DiagramItem::update()
|
void DiagramItem::update()
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
updateStereotypeIconDisplay();
|
updateStereotypeIconDisplay();
|
||||||
|
|
||||||
const Style *style = adaptedStyle(stereotypeIconId());
|
const Style *style = adaptedStyle(stereotypeIconId());
|
||||||
|
|
||||||
// custom icon
|
// custom icon
|
||||||
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon)
|
||||||
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
||||||
}
|
|
||||||
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
||||||
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
||||||
m_customIcon->setBrush(style->fillBrush());
|
m_customIcon->setBrush(style->fillBrush());
|
||||||
@@ -98,15 +94,13 @@ void DiagramItem::update()
|
|||||||
|
|
||||||
// shape
|
// shape
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (!m_body) {
|
if (!m_body)
|
||||||
m_body = new QGraphicsPolygonItem(this);
|
m_body = new QGraphicsPolygonItem(this);
|
||||||
}
|
|
||||||
m_body->setBrush(style->fillBrush());
|
m_body->setBrush(style->fillBrush());
|
||||||
m_body->setPen(style->outerLinePen());
|
m_body->setPen(style->outerLinePen());
|
||||||
m_body->setZValue(SHAPE_ZVALUE);
|
m_body->setZValue(SHAPE_ZVALUE);
|
||||||
if (!m_fold) {
|
if (!m_fold)
|
||||||
m_fold = new QGraphicsPolygonItem(this);
|
m_fold = new QGraphicsPolygonItem(this);
|
||||||
}
|
|
||||||
m_fold->setBrush(style->extraFillBrush());
|
m_fold->setBrush(style->extraFillBrush());
|
||||||
m_fold->setPen(style->outerLinePen());
|
m_fold->setPen(style->outerLinePen());
|
||||||
m_fold->setZValue(SHAPE_DETAILS_ZVALUE);
|
m_fold->setZValue(SHAPE_DETAILS_ZVALUE);
|
||||||
@@ -127,17 +121,14 @@ void DiagramItem::update()
|
|||||||
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), style);
|
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), style);
|
||||||
|
|
||||||
// diagram name
|
// diagram name
|
||||||
if (!m_diagramName) {
|
if (!m_diagramName)
|
||||||
m_diagramName = new QGraphicsSimpleTextItem(this);
|
m_diagramName = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
m_diagramName->setFont(style->headerFont());
|
m_diagramName->setFont(style->headerFont());
|
||||||
m_diagramName->setBrush(style->textBrush());
|
m_diagramName->setBrush(style->textBrush());
|
||||||
m_diagramName->setText(object()->name());
|
m_diagramName->setText(object()->name());
|
||||||
|
|
||||||
updateSelectionMarker(m_customIcon);
|
updateSelectionMarker(m_customIcon);
|
||||||
|
|
||||||
updateAlignmentButtons();
|
updateAlignmentButtons();
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,9 +158,8 @@ QSizeF DiagramItem::calcMinimumGeometry() const
|
|||||||
double width = MINIMUM_WIDTH;
|
double width = MINIMUM_WIDTH;
|
||||||
double height = 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);
|
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
|
||||||
}
|
|
||||||
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
||||||
@@ -205,21 +195,17 @@ void DiagramItem::updateGeometry()
|
|||||||
|
|
||||||
if (object()->isAutoSized()) {
|
if (object()->isAutoSized()) {
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (width < MINIMUM_AUTO_WIDTH) {
|
if (width < MINIMUM_AUTO_WIDTH)
|
||||||
width = MINIMUM_AUTO_WIDTH;
|
width = MINIMUM_AUTO_WIDTH;
|
||||||
}
|
if (height < MINIMUM_AUTO_HEIGHT)
|
||||||
if (height < MINIMUM_AUTO_HEIGHT) {
|
|
||||||
height = MINIMUM_AUTO_HEIGHT;
|
height = MINIMUM_AUTO_HEIGHT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QRectF rect = object()->rect();
|
QRectF rect = object()->rect();
|
||||||
if (rect.width() > width) {
|
if (rect.width() > width)
|
||||||
width = rect.width();
|
width = rect.width();
|
||||||
}
|
if (rect.height() > height)
|
||||||
if (rect.height() > height) {
|
|
||||||
height = rect.height();
|
height = rect.height();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update sizes and positions
|
// update sizes and positions
|
||||||
@@ -282,11 +268,8 @@ void DiagramItem::updateGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateSelectionMarkerGeometry(rect);
|
updateSelectionMarkerGeometry(rect);
|
||||||
|
|
||||||
updateAlignmentButtonsGeometry(rect);
|
updateAlignmentButtonsGeometry(rect);
|
||||||
|
|
||||||
updateDepth();
|
updateDepth();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -33,52 +33,34 @@
|
|||||||
|
|
||||||
#include "objectitem.h"
|
#include "objectitem.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DDiagram;
|
class DDiagram;
|
||||||
class DiagramSceneModel;
|
class DiagramSceneModel;
|
||||||
class CustomIconItem;
|
class CustomIconItem;
|
||||||
|
|
||||||
|
class DiagramItem : public ObjectItem
|
||||||
class DiagramItem :
|
|
||||||
public ObjectItem
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DiagramItem(DDiagram *diagram, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
explicit DiagramItem(DDiagram *diagram, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~DiagramItem();
|
~DiagramItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QSizeF minimumSize() const;
|
QSizeF minimumSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QSizeF calcMinimumGeometry() const;
|
QSizeF calcMinimumGeometry() const;
|
||||||
|
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
CustomIconItem *m_customIcon;
|
CustomIconItem *m_customIcon;
|
||||||
|
|
||||||
QGraphicsPolygonItem *m_body;
|
QGraphicsPolygonItem *m_body;
|
||||||
|
|
||||||
QGraphicsPolygonItem *m_fold;
|
QGraphicsPolygonItem *m_fold;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_diagramName;
|
QGraphicsSimpleTextItem *m_diagramName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_GRAPHICSDIAGRAMITEM_H
|
#endif // QMT_GRAPHICSDIAGRAMITEM_H
|
||||||
|
|||||||
@@ -54,13 +54,11 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
static const qreal BODY_VERT_BORDER = 4.0;
|
static const qreal BODY_VERT_BORDER = 4.0;
|
||||||
static const qreal BODY_HORIZ_BORDER = 4.0;
|
static const qreal BODY_HORIZ_BORDER = 4.0;
|
||||||
|
|
||||||
|
|
||||||
ItemItem::ItemItem(DItem *item, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
ItemItem::ItemItem(DItem *item, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(item, diagramSceneModel, parent),
|
: ObjectItem(item, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
@@ -78,7 +76,6 @@ ItemItem::~ItemItem()
|
|||||||
void ItemItem::update()
|
void ItemItem::update()
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
updateStereotypeIconDisplay();
|
updateStereotypeIconDisplay();
|
||||||
|
|
||||||
DItem *diagramItem = dynamic_cast<DItem *>(object());
|
DItem *diagramItem = dynamic_cast<DItem *>(object());
|
||||||
@@ -88,9 +85,8 @@ void ItemItem::update()
|
|||||||
const Style *style = adaptedStyle(shapeIconId());
|
const Style *style = adaptedStyle(shapeIconId());
|
||||||
|
|
||||||
if (!shapeIconId().isEmpty()) {
|
if (!shapeIconId().isEmpty()) {
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon)
|
||||||
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
||||||
}
|
|
||||||
m_customIcon->setStereotypeIconId(shapeIconId());
|
m_customIcon->setStereotypeIconId(shapeIconId());
|
||||||
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
||||||
m_customIcon->setBrush(style->fillBrush());
|
m_customIcon->setBrush(style->fillBrush());
|
||||||
@@ -104,9 +100,8 @@ void ItemItem::update()
|
|||||||
|
|
||||||
// shape
|
// shape
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (!m_shape) {
|
if (!m_shape)
|
||||||
m_shape = new QGraphicsRectItem(this);
|
m_shape = new QGraphicsRectItem(this);
|
||||||
}
|
|
||||||
m_shape->setBrush(style->fillBrush());
|
m_shape->setBrush(style->fillBrush());
|
||||||
m_shape->setPen(style->outerLinePen());
|
m_shape->setPen(style->outerLinePen());
|
||||||
m_shape->setZValue(SHAPE_ZVALUE);
|
m_shape->setZValue(SHAPE_ZVALUE);
|
||||||
@@ -122,18 +117,16 @@ void ItemItem::update()
|
|||||||
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), adaptedStyle(stereotypeIconId()));
|
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), adaptedStyle(stereotypeIconId()));
|
||||||
|
|
||||||
// component name
|
// component name
|
||||||
if (!m_itemName) {
|
if (!m_itemName)
|
||||||
m_itemName = new QGraphicsSimpleTextItem(this);
|
m_itemName = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
m_itemName->setFont(style->headerFont());
|
m_itemName->setFont(style->headerFont());
|
||||||
m_itemName->setBrush(style->textBrush());
|
m_itemName->setBrush(style->textBrush());
|
||||||
m_itemName->setText(object()->name());
|
m_itemName->setText(object()->name());
|
||||||
|
|
||||||
// context
|
// context
|
||||||
if (showContext()) {
|
if (showContext()) {
|
||||||
if (!m_contextLabel) {
|
if (!m_contextLabel)
|
||||||
m_contextLabel = new ContextLabelItem(this);
|
m_contextLabel = new ContextLabelItem(this);
|
||||||
}
|
|
||||||
m_contextLabel->setFont(style->smallFont());
|
m_contextLabel->setFont(style->smallFont());
|
||||||
m_contextLabel->setBrush(style->textBrush());
|
m_contextLabel->setBrush(style->textBrush());
|
||||||
m_contextLabel->setContext(object()->context());
|
m_contextLabel->setContext(object()->context());
|
||||||
@@ -154,15 +147,13 @@ void ItemItem::update()
|
|||||||
m_relationStarter->addArrow(QStringLiteral("dependency"), ArrowItem::ShaftDashed, ArrowItem::HeadOpen);
|
m_relationStarter->addArrow(QStringLiteral("dependency"), ArrowItem::ShaftDashed, ArrowItem::HeadOpen);
|
||||||
}
|
}
|
||||||
} else if (m_relationStarter) {
|
} else if (m_relationStarter) {
|
||||||
if (m_relationStarter->scene()) {
|
if (m_relationStarter->scene())
|
||||||
m_relationStarter->scene()->removeItem(m_relationStarter);
|
m_relationStarter->scene()->removeItem(m_relationStarter);
|
||||||
}
|
|
||||||
delete m_relationStarter;
|
delete m_relationStarter;
|
||||||
m_relationStarter = 0;
|
m_relationStarter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAlignmentButtons();
|
updateAlignmentButtons();
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,9 +199,8 @@ void ItemItem::relationDrawn(const QString &id, const QPointF &toScenePos, const
|
|||||||
if (targetElement) {
|
if (targetElement) {
|
||||||
if (id == QStringLiteral("dependency")) {
|
if (id == QStringLiteral("dependency")) {
|
||||||
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
||||||
if (dependantObject) {
|
if (dependantObject)
|
||||||
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,9 +210,8 @@ QSizeF ItemItem::calcMinimumGeometry() const
|
|||||||
double width = 0.0;
|
double width = 0.0;
|
||||||
double height = 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);
|
return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
|
||||||
}
|
|
||||||
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
||||||
@@ -237,9 +226,8 @@ QSizeF ItemItem::calcMinimumGeometry() const
|
|||||||
width = std::max(width, m_itemName->boundingRect().width());
|
width = std::max(width, m_itemName->boundingRect().width());
|
||||||
height += m_itemName->boundingRect().height();
|
height += m_itemName->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_contextLabel) {
|
if (m_contextLabel)
|
||||||
height += m_contextLabel->height();
|
height += m_contextLabel->height();
|
||||||
}
|
|
||||||
height += BODY_VERT_BORDER;
|
height += BODY_VERT_BORDER;
|
||||||
|
|
||||||
width = BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER;
|
width = BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER;
|
||||||
@@ -263,12 +251,10 @@ void ItemItem::updateGeometry()
|
|||||||
// nothing
|
// nothing
|
||||||
} else {
|
} else {
|
||||||
QRectF rect = object()->rect();
|
QRectF rect = object()->rect();
|
||||||
if (rect.width() > width) {
|
if (rect.width() > width)
|
||||||
width = rect.width();
|
width = rect.width();
|
||||||
}
|
if (rect.height() > height)
|
||||||
if (rect.height() > height) {
|
|
||||||
height = rect.height();
|
height = rect.height();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update sizes and positions
|
// update sizes and positions
|
||||||
@@ -293,9 +279,8 @@ void ItemItem::updateGeometry()
|
|||||||
y += height;
|
y += height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_shape) {
|
if (m_shape)
|
||||||
m_shape->setRect(rect);
|
m_shape->setRect(rect);
|
||||||
}
|
|
||||||
|
|
||||||
y += BODY_VERT_BORDER;
|
y += BODY_VERT_BORDER;
|
||||||
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
|
||||||
@@ -323,12 +308,10 @@ void ItemItem::updateGeometry()
|
|||||||
|
|
||||||
updateSelectionMarkerGeometry(rect);
|
updateSelectionMarkerGeometry(rect);
|
||||||
|
|
||||||
if (m_relationStarter) {
|
if (m_relationStarter)
|
||||||
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
||||||
}
|
|
||||||
|
|
||||||
updateAlignmentButtonsGeometry(rect);
|
updateAlignmentButtonsGeometry(rect);
|
||||||
|
|
||||||
updateDepth();
|
updateDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class QGraphicsSimpleTextItem;
|
|||||||
class QGraphicsLineItem;
|
class QGraphicsLineItem;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DiagramSceneModel;
|
class DiagramSceneModel;
|
||||||
@@ -50,58 +49,33 @@ class CustomIconItem;
|
|||||||
class ContextLabelItem;
|
class ContextLabelItem;
|
||||||
class RelationStarter;
|
class RelationStarter;
|
||||||
|
|
||||||
|
class ItemItem : public ObjectItem, public IRelationable
|
||||||
class ItemItem :
|
|
||||||
public ObjectItem,
|
|
||||||
public IRelationable
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ItemItem(DItem *item, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
ItemItem(DItem *item, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~ItemItem();
|
~ItemItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QSizeF minimumSize() const;
|
QSizeF minimumSize() const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QList<Latch> horizontalLatches(Action action, bool grabbedItem) const;
|
QList<Latch> horizontalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
QList<Latch> verticalLatches(Action action, bool grabbedItem) const;
|
QList<Latch> verticalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QPointF relationStartPos() const;
|
QPointF relationStartPos() const;
|
||||||
|
|
||||||
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QSizeF calcMinimumGeometry() const;
|
QSizeF calcMinimumGeometry() const;
|
||||||
|
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
CustomIconItem *m_customIcon;
|
CustomIconItem *m_customIcon;
|
||||||
|
|
||||||
QGraphicsRectItem *m_shape;
|
QGraphicsRectItem *m_shape;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_itemName;
|
QGraphicsSimpleTextItem *m_itemName;
|
||||||
|
|
||||||
ContextLabelItem *m_contextLabel;
|
ContextLabelItem *m_contextLabel;
|
||||||
|
|
||||||
RelationStarter *m_relationStarter;
|
RelationStarter *m_relationStarter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace qmt
|
} // namespace qmt
|
||||||
|
|||||||
@@ -58,8 +58,6 @@
|
|||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
ObjectItem::ObjectItem(DObject *object, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
ObjectItem::ObjectItem(DObject *object, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
@@ -112,9 +110,8 @@ void ObjectItem::setPosAndRect(const QPointF &originalPos, const QRectF &origina
|
|||||||
if (newPos != m_object->pos() || newRect != m_object->rect()) {
|
if (newPos != m_object->pos() || newRect != m_object->rect()) {
|
||||||
m_diagramSceneModel->diagramController()->startUpdateElement(m_object, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
|
m_diagramSceneModel->diagramController()->startUpdateElement(m_object, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
|
||||||
m_object->setPos(newPos);
|
m_object->setPos(newPos);
|
||||||
if (newRect.size() != m_object->rect().size()) {
|
if (newRect.size() != m_object->rect().size())
|
||||||
m_object->setAutoSized(false);
|
m_object->setAutoSized(false);
|
||||||
}
|
|
||||||
m_object->setRect(newRect);
|
m_object->setRect(newRect);
|
||||||
m_diagramSceneModel->diagramController()->finishUpdateElement(m_object, m_diagramSceneModel->diagram(), false);
|
m_diagramSceneModel->diagramController()->finishUpdateElement(m_object, m_diagramSceneModel->diagram(), false);
|
||||||
}
|
}
|
||||||
@@ -130,12 +127,10 @@ void ObjectItem::alignItemSizeToRaster(IResizable::Side adjustHorizontalSide, IR
|
|||||||
|
|
||||||
// make sure the new size is at least the minimum size
|
// make sure the new size is at least the minimum size
|
||||||
QSizeF minimumSize = this->minimumSize();
|
QSizeF minimumSize = this->minimumSize();
|
||||||
while (rect.width() + horizDelta < minimumSize.width()) {
|
while (rect.width() + horizDelta < minimumSize.width())
|
||||||
horizDelta += rasterWidth;
|
horizDelta += rasterWidth;
|
||||||
}
|
while (rect.height() + vertDelta < minimumSize.height())
|
||||||
while (rect.height() + vertDelta < minimumSize.height()) {
|
|
||||||
vertDelta += rasterHeight;
|
vertDelta += rasterHeight;
|
||||||
}
|
|
||||||
|
|
||||||
double leftDelta = 0.0;
|
double leftDelta = 0.0;
|
||||||
double rightDelta = 0.0;
|
double rightDelta = 0.0;
|
||||||
@@ -341,9 +336,8 @@ void ObjectItem::updateStereotypes(const QString &stereotypeIconId, StereotypeIc
|
|||||||
stereotypes = m_diagramSceneModel->stereotypeController()->filterStereotypesByIconId(stereotypeIconId, stereotypes);
|
stereotypes = m_diagramSceneModel->stereotypeController()->filterStereotypesByIconId(stereotypeIconId, stereotypes);
|
||||||
}
|
}
|
||||||
if (!stereotypeIconId.isEmpty() && stereotypeDisplay == StereotypeIcon::DisplayDecoration) {
|
if (!stereotypeIconId.isEmpty() && stereotypeDisplay == StereotypeIcon::DisplayDecoration) {
|
||||||
if (!m_stereotypeIcon) {
|
if (!m_stereotypeIcon)
|
||||||
m_stereotypeIcon = new CustomIconItem(m_diagramSceneModel, this);
|
m_stereotypeIcon = new CustomIconItem(m_diagramSceneModel, this);
|
||||||
}
|
|
||||||
m_stereotypeIcon->setStereotypeIconId(stereotypeIconId);
|
m_stereotypeIcon->setStereotypeIconId(stereotypeIconId);
|
||||||
m_stereotypeIcon->setBaseSize(QSizeF(m_stereotypeIcon->shapeWidth(), m_stereotypeIcon->shapeHeight()));
|
m_stereotypeIcon->setBaseSize(QSizeF(m_stereotypeIcon->shapeWidth(), m_stereotypeIcon->shapeHeight()));
|
||||||
m_stereotypeIcon->setBrush(style->fillBrush());
|
m_stereotypeIcon->setBrush(style->fillBrush());
|
||||||
@@ -354,9 +348,8 @@ void ObjectItem::updateStereotypes(const QString &stereotypeIconId, StereotypeIc
|
|||||||
m_stereotypeIcon = 0;
|
m_stereotypeIcon = 0;
|
||||||
}
|
}
|
||||||
if (stereotypeDisplay != StereotypeIcon::DisplayNone && !stereotypes.isEmpty()) {
|
if (stereotypeDisplay != StereotypeIcon::DisplayNone && !stereotypes.isEmpty()) {
|
||||||
if (!m_stereotypes) {
|
if (!m_stereotypes)
|
||||||
m_stereotypes = new StereotypesItem(this);
|
m_stereotypes = new StereotypesItem(this);
|
||||||
}
|
|
||||||
m_stereotypes->setFont(style->smallFont());
|
m_stereotypes->setFont(style->smallFont());
|
||||||
m_stereotypes->setBrush(style->textBrush());
|
m_stereotypes->setBrush(style->textBrush());
|
||||||
m_stereotypes->setStereotypes(stereotypes);
|
m_stereotypes->setStereotypes(stereotypes);
|
||||||
@@ -375,18 +368,16 @@ QSizeF ObjectItem::stereotypeIconMinimumSize(const StereotypeIcon &stereotypeIco
|
|||||||
qreal height = 0.0;
|
qreal height = 0.0;
|
||||||
if (stereotypeIcon.hasMinWidth() && !stereotypeIcon.hasMinHeight()) {
|
if (stereotypeIcon.hasMinWidth() && !stereotypeIcon.hasMinHeight()) {
|
||||||
width = stereotypeIcon.minWidth();
|
width = stereotypeIcon.minWidth();
|
||||||
if (stereotypeIcon.sizeLock() == StereotypeIcon::LockHeight || stereotypeIcon.sizeLock() == StereotypeIcon::LockSize) {
|
if (stereotypeIcon.sizeLock() == StereotypeIcon::LockHeight || stereotypeIcon.sizeLock() == StereotypeIcon::LockSize)
|
||||||
height = stereotypeIcon.minHeight();
|
height = stereotypeIcon.minHeight();
|
||||||
} else {
|
else
|
||||||
height = width * stereotypeIcon.height() / stereotypeIcon.width();
|
height = width * stereotypeIcon.height() / stereotypeIcon.width();
|
||||||
}
|
|
||||||
} else if (!stereotypeIcon.hasMinWidth() && stereotypeIcon.hasMinHeight()) {
|
} else if (!stereotypeIcon.hasMinWidth() && stereotypeIcon.hasMinHeight()) {
|
||||||
height = stereotypeIcon.minHeight();
|
height = stereotypeIcon.minHeight();
|
||||||
if (stereotypeIcon.sizeLock() == StereotypeIcon::LockWidth || stereotypeIcon.sizeLock() == StereotypeIcon::LockSize) {
|
if (stereotypeIcon.sizeLock() == StereotypeIcon::LockWidth || stereotypeIcon.sizeLock() == StereotypeIcon::LockSize)
|
||||||
width = stereotypeIcon.minWidth();
|
width = stereotypeIcon.minWidth();
|
||||||
} else {
|
else
|
||||||
width = height * stereotypeIcon.width() / stereotypeIcon.height();
|
width = height * stereotypeIcon.width() / stereotypeIcon.height();
|
||||||
}
|
|
||||||
} else if (stereotypeIcon.hasMinWidth() && stereotypeIcon.hasMinHeight()) {
|
} else if (stereotypeIcon.hasMinWidth() && stereotypeIcon.hasMinHeight()) {
|
||||||
if (stereotypeIcon.sizeLock() == StereotypeIcon::LockRatio) {
|
if (stereotypeIcon.sizeLock() == StereotypeIcon::LockRatio) {
|
||||||
width = stereotypeIcon.minWidth();
|
width = stereotypeIcon.minWidth();
|
||||||
@@ -443,9 +434,8 @@ void ObjectItem::updateSelectionMarker(CustomIconItem *customIconItem)
|
|||||||
void ObjectItem::updateSelectionMarker(ResizeFlags resizeFlags)
|
void ObjectItem::updateSelectionMarker(ResizeFlags resizeFlags)
|
||||||
{
|
{
|
||||||
if ((isSelected() || isSecondarySelected()) && resizeFlags != ResizeLockedSize) {
|
if ((isSelected() || isSecondarySelected()) && resizeFlags != ResizeLockedSize) {
|
||||||
if (!m_selectionMarker) {
|
if (!m_selectionMarker)
|
||||||
m_selectionMarker = new RectangularSelectionItem(this, this);
|
m_selectionMarker = new RectangularSelectionItem(this, this);
|
||||||
}
|
|
||||||
switch (resizeFlags) {
|
switch (resizeFlags) {
|
||||||
case ResizeUnlocked:
|
case ResizeUnlocked:
|
||||||
m_selectionMarker->setFreedom(RectangularSelectionItem::FreedomAny);
|
m_selectionMarker->setFreedom(RectangularSelectionItem::FreedomAny);
|
||||||
@@ -466,9 +456,8 @@ void ObjectItem::updateSelectionMarker(ResizeFlags resizeFlags)
|
|||||||
m_selectionMarker->setSecondarySelected(isSelected() ? false : isSecondarySelected());
|
m_selectionMarker->setSecondarySelected(isSelected() ? false : isSecondarySelected());
|
||||||
m_selectionMarker->setZValue(SELECTION_MARKER_ZVALUE);
|
m_selectionMarker->setZValue(SELECTION_MARKER_ZVALUE);
|
||||||
} else if (m_selectionMarker) {
|
} else if (m_selectionMarker) {
|
||||||
if (m_selectionMarker->scene()) {
|
if (m_selectionMarker->scene())
|
||||||
m_selectionMarker->scene()->removeItem(m_selectionMarker);
|
m_selectionMarker->scene()->removeItem(m_selectionMarker);
|
||||||
}
|
|
||||||
delete m_selectionMarker;
|
delete m_selectionMarker;
|
||||||
m_selectionMarker = 0;
|
m_selectionMarker = 0;
|
||||||
}
|
}
|
||||||
@@ -476,9 +465,8 @@ void ObjectItem::updateSelectionMarker(ResizeFlags resizeFlags)
|
|||||||
|
|
||||||
void ObjectItem::updateSelectionMarkerGeometry(const QRectF &objectRect)
|
void ObjectItem::updateSelectionMarkerGeometry(const QRectF &objectRect)
|
||||||
{
|
{
|
||||||
if (m_selectionMarker) {
|
if (m_selectionMarker)
|
||||||
m_selectionMarker->setRect(objectRect);
|
m_selectionMarker->setRect(objectRect);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::updateAlignmentButtons()
|
void ObjectItem::updateAlignmentButtons()
|
||||||
@@ -497,16 +485,14 @@ void ObjectItem::updateAlignmentButtons()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_horizontalAlignButtons) {
|
if (m_horizontalAlignButtons) {
|
||||||
if (m_horizontalAlignButtons->scene()) {
|
if (m_horizontalAlignButtons->scene())
|
||||||
m_horizontalAlignButtons->scene()->removeItem(m_horizontalAlignButtons);
|
m_horizontalAlignButtons->scene()->removeItem(m_horizontalAlignButtons);
|
||||||
}
|
|
||||||
delete m_horizontalAlignButtons;
|
delete m_horizontalAlignButtons;
|
||||||
m_horizontalAlignButtons = 0;
|
m_horizontalAlignButtons = 0;
|
||||||
}
|
}
|
||||||
if (m_verticalAlignButtons) {
|
if (m_verticalAlignButtons) {
|
||||||
if (m_verticalAlignButtons->scene()) {
|
if (m_verticalAlignButtons->scene())
|
||||||
m_verticalAlignButtons->scene()->removeItem(m_verticalAlignButtons);
|
m_verticalAlignButtons->scene()->removeItem(m_verticalAlignButtons);
|
||||||
}
|
|
||||||
delete m_verticalAlignButtons;
|
delete m_verticalAlignButtons;
|
||||||
m_verticalAlignButtons = 0;
|
m_verticalAlignButtons = 0;
|
||||||
}
|
}
|
||||||
@@ -518,16 +504,14 @@ void ObjectItem::updateAlignmentButtonsGeometry(const QRectF &objectRect)
|
|||||||
if (m_horizontalAlignButtons) {
|
if (m_horizontalAlignButtons) {
|
||||||
m_horizontalAlignButtons->clear();
|
m_horizontalAlignButtons->clear();
|
||||||
m_horizontalAlignButtons->setPos(mapToScene(QPointF(0.0, objectRect.top() - AlignButtonsItem::NormalButtonHeight - AlignButtonsItem::VerticalDistanceToObejct)));
|
m_horizontalAlignButtons->setPos(mapToScene(QPointF(0.0, objectRect.top() - AlignButtonsItem::NormalButtonHeight - AlignButtonsItem::VerticalDistanceToObejct)));
|
||||||
foreach (const ILatchable::Latch &latch, horizontalLatches(ILatchable::Move, true)) {
|
foreach (const ILatchable::Latch &latch, horizontalLatches(ILatchable::Move, true))
|
||||||
m_horizontalAlignButtons->addButton(translateLatchTypeToAlignType(latch.m_latchType), latch.m_identifier, mapFromScene(QPointF(latch.m_pos, 0.0)).x());
|
m_horizontalAlignButtons->addButton(translateLatchTypeToAlignType(latch.m_latchType), latch.m_identifier, mapFromScene(QPointF(latch.m_pos, 0.0)).x());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (m_verticalAlignButtons) {
|
if (m_verticalAlignButtons) {
|
||||||
m_verticalAlignButtons->clear();
|
m_verticalAlignButtons->clear();
|
||||||
m_verticalAlignButtons->setPos(mapToScene(QPointF(objectRect.left() - AlignButtonsItem::NormalButtonWidth - AlignButtonsItem::HorizontalDistanceToObject, 0.0)));
|
m_verticalAlignButtons->setPos(mapToScene(QPointF(objectRect.left() - AlignButtonsItem::NormalButtonWidth - AlignButtonsItem::HorizontalDistanceToObject, 0.0)));
|
||||||
foreach (const ILatchable::Latch &latch, verticalLatches(ILatchable::Move, true)) {
|
foreach (const ILatchable::Latch &latch, verticalLatches(ILatchable::Move, true))
|
||||||
m_verticalAlignButtons->addButton(translateLatchTypeToAlignType(latch.m_latchType), latch.m_identifier, mapFromScene(QPointF(0.0, latch.m_pos)).y());
|
m_verticalAlignButtons->addButton(translateLatchTypeToAlignType(latch.m_latchType), latch.m_identifier, mapFromScene(QPointF(0.0, latch.m_pos)).y());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,9 +548,8 @@ const Style *ObjectItem::adaptedStyle(const QString &stereotypeIconId)
|
|||||||
{
|
{
|
||||||
QList<const DObject *> collidingObjects;
|
QList<const DObject *> collidingObjects;
|
||||||
foreach (const QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::CollidingItems)) {
|
foreach (const QGraphicsItem *item, m_diagramSceneModel->collectCollidingObjectItems(this, DiagramSceneModel::CollidingItems)) {
|
||||||
if (const ObjectItem *objectItem = dynamic_cast<const ObjectItem *>(item)) {
|
if (const ObjectItem *objectItem = dynamic_cast<const ObjectItem *>(item))
|
||||||
collidingObjects.append(objectItem->object());
|
collidingObjects.append(objectItem->object());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QColor baseColor;
|
QColor baseColor;
|
||||||
if (!stereotypeIconId.isEmpty()) {
|
if (!stereotypeIconId.isEmpty()) {
|
||||||
@@ -623,36 +606,31 @@ bool ObjectItem::handleSelectedContextMenuAction(QAction *action)
|
|||||||
|
|
||||||
void ObjectItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void ObjectItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) {
|
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
|
||||||
m_diagramSceneModel->selectItem(this, event->modifiers() & Qt::ControlModifier);
|
m_diagramSceneModel->selectItem(this, event->modifiers() & Qt::ControlModifier);
|
||||||
}
|
if (event->button() == Qt::LeftButton)
|
||||||
if (event->button() == Qt::LeftButton) {
|
|
||||||
m_diagramSceneModel->moveSelectedItems(this, QPointF(0.0, 0.0));
|
m_diagramSceneModel->moveSelectedItems(this, QPointF(0.0, 0.0));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void ObjectItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
if (event->buttons() & Qt::LeftButton)
|
||||||
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void ObjectItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
m_diagramSceneModel->moveSelectedItems(this, event->scenePos() - event->lastScenePos());
|
||||||
if (event->scenePos() != event->buttonDownScenePos(Qt::LeftButton)) {
|
if (event->scenePos() != event->buttonDownScenePos(Qt::LeftButton))
|
||||||
m_diagramSceneModel->alignSelectedItemsPositionOnRaster();
|
m_diagramSceneModel->alignSelectedItemsPositionOnRaster();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
void ObjectItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton) {
|
if (event->buttons() & Qt::LeftButton)
|
||||||
m_diagramSceneModel->onDoubleClickedItem(this);
|
m_diagramSceneModel->onDoubleClickedItem(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
@@ -667,12 +645,10 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||||||
menu.addAction(new ContextMenuAction(QObject::tr("Create Diagram"), QStringLiteral("createDiagram"), &menu));
|
menu.addAction(new ContextMenuAction(QObject::tr("Create Diagram"), QStringLiteral("createDiagram"), &menu));
|
||||||
addSeparator = true;
|
addSeparator = true;
|
||||||
}
|
}
|
||||||
if (extendContextMenu(&menu)) {
|
if (extendContextMenu(&menu))
|
||||||
addSeparator = true;
|
addSeparator = true;
|
||||||
}
|
if (addSeparator)
|
||||||
if (addSeparator) {
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
}
|
|
||||||
menu.addAction(new ContextMenuAction(QObject::tr("Remove"), QStringLiteral("remove"), QKeySequence(QKeySequence::Delete), &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("Delete"), QStringLiteral("delete"), QKeySequence(Qt::CTRL + Qt::Key_D), &menu));
|
||||||
//menu.addAction(new ContextMenuAction(QObject::tr("Select in Model Tree"), QStringLiteral("selectInModelTree"), &menu));
|
//menu.addAction(new ContextMenuAction(QObject::tr("Select in Model Tree"), QStringLiteral("selectInModelTree"), &menu));
|
||||||
@@ -703,15 +679,13 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||||||
m_diagramSceneModel->diagramSceneController()->elementTasks()->createAndOpenDiagram(m_object, m_diagramSceneModel->diagram());
|
m_diagramSceneModel->diagramSceneController()->elementTasks()->createAndOpenDiagram(m_object, m_diagramSceneModel->diagram());
|
||||||
} else if (action->id() == QStringLiteral("remove")) {
|
} else if (action->id() == QStringLiteral("remove")) {
|
||||||
DSelection selection = m_diagramSceneModel->selectedElements();
|
DSelection selection = m_diagramSceneModel->selectedElements();
|
||||||
if (selection.isEmpty()) {
|
if (selection.isEmpty())
|
||||||
selection.append(m_object->uid(), m_diagramSceneModel->diagram()->uid());
|
selection.append(m_object->uid(), m_diagramSceneModel->diagram()->uid());
|
||||||
}
|
|
||||||
m_diagramSceneModel->diagramController()->deleteElements(selection, m_diagramSceneModel->diagram());
|
m_diagramSceneModel->diagramController()->deleteElements(selection, m_diagramSceneModel->diagram());
|
||||||
} else if (action->id() == QStringLiteral("delete")) {
|
} else if (action->id() == QStringLiteral("delete")) {
|
||||||
DSelection selection = m_diagramSceneModel->selectedElements();
|
DSelection selection = m_diagramSceneModel->selectedElements();
|
||||||
if (selection.isEmpty()) {
|
if (selection.isEmpty())
|
||||||
selection.append(m_object->uid(), m_diagramSceneModel->diagram()->uid());
|
selection.append(m_object->uid(), m_diagramSceneModel->diagram()->uid());
|
||||||
}
|
|
||||||
m_diagramSceneModel->diagramSceneController()->deleteFromDiagram(selection, m_diagramSceneModel->diagram());
|
m_diagramSceneModel->diagramSceneController()->deleteFromDiagram(selection, m_diagramSceneModel->diagram());
|
||||||
} else if (action->id() == QStringLiteral("selectInModelTree")) {
|
} else if (action->id() == QStringLiteral("selectInModelTree")) {
|
||||||
// TODO implement
|
// TODO implement
|
||||||
@@ -744,15 +718,13 @@ QSizeF ObjectItem::minimumSize(const QSet<QGraphicsItem *> &items) const
|
|||||||
foreach (QGraphicsItem *item, items) {
|
foreach (QGraphicsItem *item, items) {
|
||||||
if (IResizable *resizable = dynamic_cast<IResizable *>(item)) {
|
if (IResizable *resizable = dynamic_cast<IResizable *>(item)) {
|
||||||
QSizeF size = resizable->minimumSize();
|
QSizeF size = resizable->minimumSize();
|
||||||
if (size.width() > minimumSize.width()) {
|
if (size.width() > minimumSize.width())
|
||||||
minimumSize.setWidth(size.width());
|
minimumSize.setWidth(size.width());
|
||||||
}
|
if (size.height() > minimumSize.height())
|
||||||
if (size.height() > minimumSize.height()) {
|
|
||||||
minimumSize.setHeight(size.height());
|
minimumSize.setHeight(size.height());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return minimumSize;
|
return minimumSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QAction;
|
class QAction;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DObject;
|
class DObject;
|
||||||
@@ -57,7 +56,6 @@ class RectangularSelectionItem;
|
|||||||
class AlignButtonsItem;
|
class AlignButtonsItem;
|
||||||
class Style;
|
class Style;
|
||||||
|
|
||||||
|
|
||||||
// typical z-values for graphic items
|
// typical z-values for graphic items
|
||||||
static const int SHAPE_ZVALUE = -100; // the filled background of the shape
|
static const int SHAPE_ZVALUE = -100; // the filled background of the shape
|
||||||
static const int SHAPE_DETAILS_ZVALUE = -90; // any details to the shape (e.g. extra lines in shape)
|
static const int SHAPE_DETAILS_ZVALUE = -90; // any details to the shape (e.g. extra lines in shape)
|
||||||
@@ -73,7 +71,6 @@ class ObjectItem :
|
|||||||
public IAlignable
|
public IAlignable
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
enum ResizeFlags {
|
enum ResizeFlags {
|
||||||
ResizeUnlocked,
|
ResizeUnlocked,
|
||||||
ResizeLockedSize,
|
ResizeLockedSize,
|
||||||
@@ -83,153 +80,85 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ObjectItem(DObject *object, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
ObjectItem(DObject *object, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~ObjectItem();
|
~ObjectItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DObject *object() const { return m_object; }
|
DObject *object() const { return m_object; }
|
||||||
|
|
||||||
DiagramSceneModel *diagramSceneModel() const { return m_diagramSceneModel; }
|
DiagramSceneModel *diagramSceneModel() const { return m_diagramSceneModel; }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void update() = 0;
|
virtual void update() = 0;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const = 0;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const = 0;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QPointF pos() const;
|
QPointF pos() const;
|
||||||
|
|
||||||
QRectF rect() const;
|
QRectF rect() const;
|
||||||
|
|
||||||
QSizeF minimumSize() const = 0;
|
QSizeF minimumSize() const = 0;
|
||||||
|
|
||||||
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
void setPosAndRect(const QPointF &originalPos, const QRectF &originalRect, const QPointF &topLeftDelta, const QPointF &bottomRightDelta);
|
||||||
|
|
||||||
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
void alignItemSizeToRaster(Side adjustHorizontalSide, Side adjustVerticalSide, double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void moveDelta(const QPointF &delta);
|
void moveDelta(const QPointF &delta);
|
||||||
|
|
||||||
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isSecondarySelected() const;
|
bool isSecondarySelected() const;
|
||||||
|
|
||||||
void setSecondarySelected(bool secondarySelected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
bool isFocusSelected() const;
|
bool isFocusSelected() const;
|
||||||
|
|
||||||
void setFocusSelected(bool focusSelected);
|
void setFocusSelected(bool focusSelected);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QList<Latch> horizontalLatches(Action action, bool grabbedItem) const;
|
QList<Latch> horizontalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
QList<Latch> verticalLatches(Action action, bool grabbedItem) const;
|
QList<Latch> verticalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void align(AlignType alignType, const QString &identifier);
|
void align(AlignType alignType, const QString &identifier);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void updateStereotypeIconDisplay();
|
void updateStereotypeIconDisplay();
|
||||||
|
|
||||||
QString stereotypeIconId() const { return m_stereotypeIconId; }
|
QString stereotypeIconId() const { return m_stereotypeIconId; }
|
||||||
|
|
||||||
QString shapeIconId() const { return m_shapeIconId; }
|
QString shapeIconId() const { return m_shapeIconId; }
|
||||||
|
|
||||||
StereotypeIcon::Display stereotypeIconDisplay() const { return m_stereotypeIconDisplay; }
|
StereotypeIcon::Display stereotypeIconDisplay() const { return m_stereotypeIconDisplay; }
|
||||||
|
|
||||||
void updateStereotypes(const QString &stereotypeIconId, StereotypeIcon::Display stereotypeDisplay, const Style *style);
|
void updateStereotypes(const QString &stereotypeIconId, StereotypeIcon::Display stereotypeDisplay, const Style *style);
|
||||||
|
|
||||||
StereotypesItem *stereotypesItem() const { return m_stereotypes; }
|
StereotypesItem *stereotypesItem() const { return m_stereotypes; }
|
||||||
|
|
||||||
CustomIconItem *stereotypeIconItem() const { return m_stereotypeIcon; }
|
CustomIconItem *stereotypeIconItem() const { return m_stereotypeIcon; }
|
||||||
|
|
||||||
QSizeF stereotypeIconMinimumSize(const StereotypeIcon &stereotypeIcon, qreal minimumWidth, qreal minimumHeight) const;
|
QSizeF stereotypeIconMinimumSize(const StereotypeIcon &stereotypeIcon, qreal minimumWidth, qreal minimumHeight) const;
|
||||||
|
|
||||||
void updateDepth();
|
void updateDepth();
|
||||||
|
|
||||||
void updateSelectionMarker(CustomIconItem *customIconItem);
|
void updateSelectionMarker(CustomIconItem *customIconItem);
|
||||||
|
|
||||||
void updateSelectionMarker(ResizeFlags resizeFlags);
|
void updateSelectionMarker(ResizeFlags resizeFlags);
|
||||||
|
|
||||||
void updateSelectionMarkerGeometry(const QRectF &objectRect);
|
void updateSelectionMarkerGeometry(const QRectF &objectRect);
|
||||||
|
|
||||||
void updateAlignmentButtons();
|
void updateAlignmentButtons();
|
||||||
|
|
||||||
void updateAlignmentButtonsGeometry(const QRectF &objectRect);
|
void updateAlignmentButtonsGeometry(const QRectF &objectRect);
|
||||||
|
|
||||||
IAlignable::AlignType translateLatchTypeToAlignType(ILatchable::LatchType latchType);
|
IAlignable::AlignType translateLatchTypeToAlignType(ILatchable::LatchType latchType);
|
||||||
|
|
||||||
const Style *adaptedStyle(const QString &stereotypeIconId);
|
const Style *adaptedStyle(const QString &stereotypeIconId);
|
||||||
|
|
||||||
bool showContext() const;
|
bool showContext() const;
|
||||||
|
|
||||||
virtual bool extendContextMenu(QMenu *menu);
|
virtual bool extendContextMenu(QMenu *menu);
|
||||||
|
|
||||||
virtual bool handleSelectedContextMenuAction(QAction *action);
|
virtual bool handleSelectedContextMenuAction(QAction *action);
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QSizeF minimumSize(const QSet<QGraphicsItem *> &items) const;
|
QSizeF minimumSize(const QSet<QGraphicsItem *> &items) const;
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DObject *m_object;
|
DObject *m_object;
|
||||||
|
|
||||||
DiagramSceneModel *m_diagramSceneModel;
|
DiagramSceneModel *m_diagramSceneModel;
|
||||||
|
|
||||||
bool m_isSecondarySelected;
|
bool m_isSecondarySelected;
|
||||||
|
|
||||||
bool m_isFocusSelected;
|
bool m_isFocusSelected;
|
||||||
|
|
||||||
QString m_stereotypeIconId;
|
QString m_stereotypeIconId;
|
||||||
|
|
||||||
QString m_shapeIconId;
|
QString m_shapeIconId;
|
||||||
|
|
||||||
StereotypeIcon::Display m_stereotypeIconDisplay;
|
StereotypeIcon::Display m_stereotypeIconDisplay;
|
||||||
|
|
||||||
StereotypesItem *m_stereotypes;
|
StereotypesItem *m_stereotypes;
|
||||||
|
|
||||||
CustomIconItem *m_stereotypeIcon;
|
CustomIconItem *m_stereotypeIcon;
|
||||||
|
|
||||||
RectangularSelectionItem *m_selectionMarker;
|
RectangularSelectionItem *m_selectionMarker;
|
||||||
|
|
||||||
AlignButtonsItem *m_horizontalAlignButtons;
|
AlignButtonsItem *m_horizontalAlignButtons;
|
||||||
|
|
||||||
AlignButtonsItem *m_verticalAlignButtons;
|
AlignButtonsItem *m_verticalAlignButtons;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_OBJECTITEM_H
|
#endif // QMT_OBJECTITEM_H
|
||||||
|
|||||||
@@ -51,7 +51,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
static const qreal TAB_HORIZ_BORDER = 4.0;
|
static const qreal TAB_HORIZ_BORDER = 4.0;
|
||||||
@@ -63,7 +62,6 @@ static const qreal BODY_MIN_HEIGHT = 24.0;
|
|||||||
static const qreal MINIMUM_AUTO_WIDTH = 100.0;
|
static const qreal MINIMUM_AUTO_WIDTH = 100.0;
|
||||||
static const qreal MINIMUM_AUTO_HEIGHT = 70.0;
|
static const qreal MINIMUM_AUTO_HEIGHT = 70.0;
|
||||||
|
|
||||||
|
|
||||||
class PackageItem::ShapeGeometry
|
class PackageItem::ShapeGeometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -77,7 +75,6 @@ public:
|
|||||||
QSizeF m_minimumTabSize;
|
QSizeF m_minimumTabSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PackageItem::PackageItem(DPackage *package, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
PackageItem::PackageItem(DPackage *package, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: ObjectItem(package, diagramSceneModel, parent),
|
: ObjectItem(package, diagramSceneModel, parent),
|
||||||
m_customIcon(0),
|
m_customIcon(0),
|
||||||
@@ -95,16 +92,14 @@ PackageItem::~PackageItem()
|
|||||||
void PackageItem::update()
|
void PackageItem::update()
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
updateStereotypeIconDisplay();
|
updateStereotypeIconDisplay();
|
||||||
|
|
||||||
const Style *style = adaptedStyle(stereotypeIconId());
|
const Style *style = adaptedStyle(stereotypeIconId());
|
||||||
|
|
||||||
// custom icon
|
// custom icon
|
||||||
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
if (stereotypeIconDisplay() == StereotypeIcon::DisplayIcon) {
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon)
|
||||||
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
m_customIcon = new CustomIconItem(diagramSceneModel(), this);
|
||||||
}
|
|
||||||
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
m_customIcon->setStereotypeIconId(stereotypeIconId());
|
||||||
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
m_customIcon->setBaseSize(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT));
|
||||||
m_customIcon->setBrush(style->fillBrush());
|
m_customIcon->setBrush(style->fillBrush());
|
||||||
@@ -118,9 +113,8 @@ void PackageItem::update()
|
|||||||
|
|
||||||
// shape
|
// shape
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (!m_shape) {
|
if (!m_shape)
|
||||||
m_shape = new QGraphicsPolygonItem(this);
|
m_shape = new QGraphicsPolygonItem(this);
|
||||||
}
|
|
||||||
m_shape->setBrush(style->fillBrush());
|
m_shape->setBrush(style->fillBrush());
|
||||||
m_shape->setPen(style->outerLinePen());
|
m_shape->setPen(style->outerLinePen());
|
||||||
m_shape->setZValue(SHAPE_ZVALUE);
|
m_shape->setZValue(SHAPE_ZVALUE);
|
||||||
@@ -134,18 +128,16 @@ void PackageItem::update()
|
|||||||
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), style);
|
updateStereotypes(stereotypeIconId(), stereotypeIconDisplay(), style);
|
||||||
|
|
||||||
// package name
|
// package name
|
||||||
if (!m_packageName) {
|
if (!m_packageName)
|
||||||
m_packageName = new QGraphicsSimpleTextItem(this);
|
m_packageName = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
m_packageName->setBrush(style->textBrush());
|
m_packageName->setBrush(style->textBrush());
|
||||||
m_packageName->setFont(style->headerFont());
|
m_packageName->setFont(style->headerFont());
|
||||||
m_packageName->setText(object()->name());
|
m_packageName->setText(object()->name());
|
||||||
|
|
||||||
// context
|
// context
|
||||||
if (showContext()) {
|
if (showContext()) {
|
||||||
if (!m_contextLabel) {
|
if (!m_contextLabel)
|
||||||
m_contextLabel = new ContextLabelItem(this);
|
m_contextLabel = new ContextLabelItem(this);
|
||||||
}
|
|
||||||
m_contextLabel->setFont(style->smallFont());
|
m_contextLabel->setFont(style->smallFont());
|
||||||
m_contextLabel->setBrush(style->textBrush());
|
m_contextLabel->setBrush(style->textBrush());
|
||||||
m_contextLabel->setContext(object()->context());
|
m_contextLabel->setContext(object()->context());
|
||||||
@@ -172,7 +164,6 @@ void PackageItem::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateAlignmentButtons();
|
updateAlignmentButtons();
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,9 +214,8 @@ void PackageItem::relationDrawn(const QString &id, const QPointF &toScenePos, co
|
|||||||
if (targetElement) {
|
if (targetElement) {
|
||||||
if (id == QStringLiteral("dependency")) {
|
if (id == QStringLiteral("dependency")) {
|
||||||
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
DObject *dependantObject = dynamic_cast<DObject *>(targetElement);
|
||||||
if (dependantObject) {
|
if (dependantObject)
|
||||||
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
diagramSceneModel()->diagramSceneController()->createDependency(object(), dependantObject, intermediatePoints, diagramSceneModel()->diagram());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,9 +227,8 @@ PackageItem::ShapeGeometry PackageItem::calcMinimumGeometry() const
|
|||||||
double tabHeight = 0.0;
|
double tabHeight = 0.0;
|
||||||
double tabWidth = 0.0;
|
double tabWidth = 0.0;
|
||||||
|
|
||||||
if (m_customIcon) {
|
if (m_customIcon)
|
||||||
return ShapeGeometry(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT), QSizeF(tabWidth, tabHeight));
|
return ShapeGeometry(stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT), QSizeF(tabWidth, tabHeight));
|
||||||
}
|
|
||||||
|
|
||||||
double bodyHeight = 0.0;
|
double bodyHeight = 0.0;
|
||||||
double bodyWidth = 0.0;
|
double bodyWidth = 0.0;
|
||||||
@@ -262,9 +251,8 @@ PackageItem::ShapeGeometry PackageItem::calcMinimumGeometry() const
|
|||||||
bodyWidth = std::max(bodyWidth, stereotypeIconItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
bodyWidth = std::max(bodyWidth, stereotypeIconItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
|
||||||
bodyHeight += stereotypeIconItem->boundingRect().height();
|
bodyHeight += stereotypeIconItem->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (m_contextLabel) {
|
if (m_contextLabel)
|
||||||
bodyHeight += m_contextLabel->height();
|
bodyHeight += m_contextLabel->height();
|
||||||
}
|
|
||||||
bodyHeight += BODY_VERT_BORDER;
|
bodyHeight += BODY_VERT_BORDER;
|
||||||
bodyHeight = std::max(bodyHeight, BODY_MIN_HEIGHT);
|
bodyHeight = std::max(bodyHeight, BODY_MIN_HEIGHT);
|
||||||
width = std::max(width, bodyWidth);
|
width = std::max(width, bodyWidth);
|
||||||
@@ -287,21 +275,17 @@ void PackageItem::updateGeometry()
|
|||||||
// calc width and height
|
// calc width and height
|
||||||
if (object()->isAutoSized()) {
|
if (object()->isAutoSized()) {
|
||||||
if (!m_customIcon) {
|
if (!m_customIcon) {
|
||||||
if (width < MINIMUM_AUTO_WIDTH) {
|
if (width < MINIMUM_AUTO_WIDTH)
|
||||||
width = MINIMUM_AUTO_WIDTH;
|
width = MINIMUM_AUTO_WIDTH;
|
||||||
}
|
if (height < MINIMUM_AUTO_HEIGHT)
|
||||||
if (height < MINIMUM_AUTO_HEIGHT) {
|
|
||||||
height = MINIMUM_AUTO_HEIGHT;
|
height = MINIMUM_AUTO_HEIGHT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QRectF rect = object()->rect();
|
QRectF rect = object()->rect();
|
||||||
if (rect.width() > width) {
|
if (rect.width() > width)
|
||||||
width = rect.width();
|
width = rect.width();
|
||||||
}
|
if (rect.height() > height)
|
||||||
if (rect.height() > height) {
|
|
||||||
height = rect.height();
|
height = rect.height();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update sizes and positions
|
// update sizes and positions
|
||||||
@@ -372,13 +356,11 @@ void PackageItem::updateGeometry()
|
|||||||
|
|
||||||
updateSelectionMarkerGeometry(rect);
|
updateSelectionMarkerGeometry(rect);
|
||||||
|
|
||||||
if (m_relationStarter) {
|
if (m_relationStarter)
|
||||||
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
m_relationStarter->setPos(mapToScene(QPointF(right + 8.0, top)));
|
||||||
}
|
|
||||||
|
|
||||||
updateAlignmentButtonsGeometry(rect);
|
updateAlignmentButtonsGeometry(rect);
|
||||||
|
|
||||||
updateDepth();
|
updateDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -35,13 +35,11 @@
|
|||||||
|
|
||||||
#include "qmt/diagram_scene/capabilities/relationable.h"
|
#include "qmt/diagram_scene/capabilities/relationable.h"
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QGraphicsPolygonItem;
|
class QGraphicsPolygonItem;
|
||||||
class QGraphicsSimpleTextItem;
|
class QGraphicsSimpleTextItem;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class DiagramSceneModel;
|
class DiagramSceneModel;
|
||||||
@@ -50,62 +48,37 @@ class CustomIconItem;
|
|||||||
class ContextLabelItem;
|
class ContextLabelItem;
|
||||||
class RelationStarter;
|
class RelationStarter;
|
||||||
|
|
||||||
|
class PackageItem : public ObjectItem, public IRelationable
|
||||||
class PackageItem :
|
|
||||||
public ObjectItem,
|
|
||||||
public IRelationable
|
|
||||||
{
|
{
|
||||||
class ShapeGeometry;
|
class ShapeGeometry;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PackageItem(DPackage *package, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
PackageItem(DPackage *package, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~PackageItem();
|
~PackageItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
bool intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual QSizeF minimumSize() const;
|
virtual QSizeF minimumSize() const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QList<Latch> horizontalLatches(Action action, bool grabbedItem) const;
|
QList<Latch> horizontalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
QList<Latch> verticalLatches(Action action, bool grabbedItem) const;
|
QList<Latch> verticalLatches(Action action, bool grabbedItem) const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QPointF relationStartPos() const;
|
QPointF relationStartPos() const;
|
||||||
|
|
||||||
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
void relationDrawn(const QString &id, const QPointF &toScenePos, const QList<QPointF> &intermediatePoints);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ShapeGeometry calcMinimumGeometry() const;
|
ShapeGeometry calcMinimumGeometry() const;
|
||||||
|
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
CustomIconItem *m_customIcon;
|
CustomIconItem *m_customIcon;
|
||||||
|
|
||||||
QGraphicsPolygonItem *m_shape;
|
QGraphicsPolygonItem *m_shape;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_packageName;
|
QGraphicsSimpleTextItem *m_packageName;
|
||||||
|
|
||||||
ContextLabelItem *m_contextLabel;
|
ContextLabelItem *m_contextLabel;
|
||||||
|
|
||||||
RelationStarter *m_relationStarter;
|
RelationStarter *m_relationStarter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_GRAPHICSPACKAGEITEM_H
|
#endif // QMT_GRAPHICSPACKAGEITEM_H
|
||||||
|
|||||||
@@ -57,11 +57,9 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class RelationItem::ArrowConfigurator :
|
class RelationItem::ArrowConfigurator : public DConstVoidVisitor
|
||||||
public DConstVoidVisitor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArrowConfigurator(DiagramSceneModel *diagramSceneModel, ArrowItem *arrow, const QList<QPointF> &points)
|
ArrowConfigurator(DiagramSceneModel *diagramSceneModel, ArrowItem *arrow, const QList<QPointF> &points)
|
||||||
@@ -171,15 +169,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DiagramSceneModel *m_diagramSceneModel;
|
DiagramSceneModel *m_diagramSceneModel;
|
||||||
|
|
||||||
ArrowItem *m_arrow;
|
ArrowItem *m_arrow;
|
||||||
|
|
||||||
QList<QPointF> m_points;
|
QList<QPointF> m_points;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
RelationItem::RelationItem(DRelation *relation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
RelationItem::RelationItem(DRelation *relation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_relation(relation),
|
m_relation(relation),
|
||||||
@@ -222,18 +216,14 @@ QPainterPath RelationItem::shape() const
|
|||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.setFillRule(Qt::WindingFill);
|
path.setFillRule(Qt::WindingFill);
|
||||||
if (m_arrow) {
|
if (m_arrow)
|
||||||
path.addPath(m_arrow->shape().translated(m_arrow->pos()));
|
path.addPath(m_arrow->shape().translated(m_arrow->pos()));
|
||||||
}
|
if (m_name)
|
||||||
if (m_name) {
|
|
||||||
path.addPath(m_name->shape().translated(m_name->pos()));
|
path.addPath(m_name->shape().translated(m_name->pos()));
|
||||||
}
|
if (m_stereotypes)
|
||||||
if (m_stereotypes) {
|
|
||||||
path.addPath(m_stereotypes->shape().translated(m_stereotypes->pos()));
|
path.addPath(m_stereotypes->shape().translated(m_stereotypes->pos()));
|
||||||
}
|
if (m_selectionHandles)
|
||||||
if (m_selectionHandles) {
|
|
||||||
path.addPath(m_selectionHandles->shape().translated(m_selectionHandles->pos()));
|
path.addPath(m_selectionHandles->shape().translated(m_selectionHandles->pos()));
|
||||||
}
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,9 +231,8 @@ void RelationItem::moveDelta(const QPointF &delta)
|
|||||||
{
|
{
|
||||||
m_diagramSceneModel->diagramController()->startUpdateElement(m_relation, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
|
m_diagramSceneModel->diagramController()->startUpdateElement(m_relation, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
|
||||||
QList<DRelation::IntermediatePoint> points;
|
QList<DRelation::IntermediatePoint> points;
|
||||||
foreach (const DRelation::IntermediatePoint &point, m_relation->intermediatePoints()) {
|
foreach (const DRelation::IntermediatePoint &point, m_relation->intermediatePoints())
|
||||||
points << DRelation::IntermediatePoint(point.pos() + delta);
|
points << DRelation::IntermediatePoint(point.pos() + delta);
|
||||||
}
|
|
||||||
m_relation->setIntermediatePoints(points);
|
m_relation->setIntermediatePoints(points);
|
||||||
m_diagramSceneModel->diagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->diagram(), false);
|
m_diagramSceneModel->diagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->diagram(), false);
|
||||||
}
|
}
|
||||||
@@ -374,9 +363,8 @@ void RelationItem::update()
|
|||||||
|
|
||||||
const Style *style = adaptedStyle();
|
const Style *style = adaptedStyle();
|
||||||
|
|
||||||
if (!m_arrow) {
|
if (!m_arrow)
|
||||||
m_arrow = new ArrowItem(this);
|
m_arrow = new ArrowItem(this);
|
||||||
}
|
|
||||||
|
|
||||||
update(style);
|
update(style);
|
||||||
}
|
}
|
||||||
@@ -390,9 +378,8 @@ void RelationItem::update(const Style *style)
|
|||||||
|
|
||||||
QList<QPointF> points;
|
QList<QPointF> points;
|
||||||
points << (endAPos - endAPos);
|
points << (endAPos - endAPos);
|
||||||
foreach (const DRelation::IntermediatePoint &point, m_relation->intermediatePoints()) {
|
foreach (const DRelation::IntermediatePoint &point, m_relation->intermediatePoints())
|
||||||
points << (point.pos() - endAPos);
|
points << (point.pos() - endAPos);
|
||||||
}
|
|
||||||
points << (endBPos - endAPos);
|
points << (endBPos - endAPos);
|
||||||
|
|
||||||
ArrowConfigurator visitor(m_diagramSceneModel, m_arrow, points);
|
ArrowConfigurator visitor(m_diagramSceneModel, m_arrow, points);
|
||||||
@@ -400,9 +387,8 @@ void RelationItem::update(const Style *style)
|
|||||||
m_arrow->update(style);
|
m_arrow->update(style);
|
||||||
|
|
||||||
if (!m_relation->name().isEmpty()) {
|
if (!m_relation->name().isEmpty()) {
|
||||||
if (!m_name) {
|
if (!m_name)
|
||||||
m_name = new QGraphicsSimpleTextItem(this);
|
m_name = new QGraphicsSimpleTextItem(this);
|
||||||
}
|
|
||||||
m_name->setFont(style->smallFont());
|
m_name->setFont(style->smallFont());
|
||||||
m_name->setBrush(style->textBrush());
|
m_name->setBrush(style->textBrush());
|
||||||
m_name->setText(m_relation->name());
|
m_name->setText(m_relation->name());
|
||||||
@@ -414,9 +400,8 @@ void RelationItem::update(const Style *style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_relation->stereotypes().isEmpty()) {
|
if (!m_relation->stereotypes().isEmpty()) {
|
||||||
if (!m_stereotypes) {
|
if (!m_stereotypes)
|
||||||
m_stereotypes = new StereotypesItem(this);
|
m_stereotypes = new StereotypesItem(this);
|
||||||
}
|
|
||||||
m_stereotypes->setFont(style->smallFont());
|
m_stereotypes->setFont(style->smallFont());
|
||||||
m_stereotypes->setBrush(style->textBrush());
|
m_stereotypes->setBrush(style->textBrush());
|
||||||
m_stereotypes->setStereotypes(m_relation->stereotypes());
|
m_stereotypes->setStereotypes(m_relation->stereotypes());
|
||||||
@@ -428,15 +413,13 @@ void RelationItem::update(const Style *style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isSelected() || isSecondarySelected()) {
|
if (isSelected() || isSecondarySelected()) {
|
||||||
if (!m_selectionHandles) {
|
if (!m_selectionHandles)
|
||||||
m_selectionHandles = new PathSelectionItem(this, this);
|
m_selectionHandles = new PathSelectionItem(this, this);
|
||||||
}
|
|
||||||
m_selectionHandles->setPoints(points);
|
m_selectionHandles->setPoints(points);
|
||||||
m_selectionHandles->setSecondarySelected(isSelected() ? false : isSecondarySelected());
|
m_selectionHandles->setSecondarySelected(isSelected() ? false : isSecondarySelected());
|
||||||
} else if (m_selectionHandles) {
|
} else if (m_selectionHandles) {
|
||||||
if (m_selectionHandles->scene()) {
|
if (m_selectionHandles->scene())
|
||||||
m_selectionHandles->scene()->removeItem(m_selectionHandles);
|
m_selectionHandles->scene()->removeItem(m_selectionHandles);
|
||||||
}
|
|
||||||
delete m_selectionHandles;
|
delete m_selectionHandles;
|
||||||
m_selectionHandles = 0;
|
m_selectionHandles = 0;
|
||||||
}
|
}
|
||||||
@@ -446,9 +429,8 @@ void RelationItem::update(const Style *style)
|
|||||||
|
|
||||||
void RelationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void RelationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) {
|
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
|
||||||
m_diagramSceneModel->selectItem(this, event->modifiers() & Qt::ControlModifier);
|
m_diagramSceneModel->selectItem(this, event->modifiers() & Qt::ControlModifier);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelationItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void RelationItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
@@ -518,16 +500,14 @@ QPointF RelationItem::calcEndPoint(const Uid &end, const QPointF &otherEndPos, i
|
|||||||
ok = endObjectItem->intersectShapeWithLine(projectedLine, &endPos);
|
ok = endObjectItem->intersectShapeWithLine(projectedLine, &endPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok)
|
||||||
ok = endObjectItem->intersectShapeWithLine(directLine, &endPos);
|
ok = endObjectItem->intersectShapeWithLine(directLine, &endPos);
|
||||||
}
|
if (!ok)
|
||||||
if (!ok) {
|
|
||||||
endPos = endItem->pos();
|
endPos = endItem->pos();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
endPos = endItem->pos();
|
endPos = endItem->pos();
|
||||||
}
|
}
|
||||||
return endPos;
|
return endPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QGraphicsSimpleTextItem;
|
class QGraphicsSimpleTextItem;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
namespace qmt {
|
namespace qmt {
|
||||||
|
|
||||||
class Uid;
|
class Uid;
|
||||||
@@ -51,7 +50,6 @@ class StereotypesItem;
|
|||||||
class PathSelectionItem;
|
class PathSelectionItem;
|
||||||
class Style;
|
class Style;
|
||||||
|
|
||||||
|
|
||||||
class RelationItem :
|
class RelationItem :
|
||||||
public QGraphicsItem,
|
public QGraphicsItem,
|
||||||
public IMoveable,
|
public IMoveable,
|
||||||
@@ -62,94 +60,54 @@ class RelationItem :
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RelationItem(DRelation *relation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
RelationItem(DRelation *relation, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
~RelationItem();
|
~RelationItem();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DRelation *relation() const { return m_relation; }
|
DRelation *relation() const { return m_relation; }
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
QPainterPath shape() const;
|
QPainterPath shape() const;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void moveDelta(const QPointF &delta);
|
void moveDelta(const QPointF &delta);
|
||||||
|
|
||||||
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
void alignItemPositionToRaster(double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool isSecondarySelected() const;
|
bool isSecondarySelected() const;
|
||||||
|
|
||||||
void setSecondarySelected(bool secondarySelected);
|
void setSecondarySelected(bool secondarySelected);
|
||||||
|
|
||||||
bool isFocusSelected() const;
|
bool isFocusSelected() const;
|
||||||
|
|
||||||
void setFocusSelected(bool focusSelected);
|
void setFocusSelected(bool focusSelected);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
QPointF handlePos(int index);
|
QPointF handlePos(int index);
|
||||||
|
|
||||||
void insertHandle(int beforeIndex, const QPointF &pos);
|
void insertHandle(int beforeIndex, const QPointF &pos);
|
||||||
|
|
||||||
void deleteHandle(int index);
|
void deleteHandle(int index);
|
||||||
|
|
||||||
void setHandlePos(int index, const QPointF &pos);
|
void setHandlePos(int index, const QPointF &pos);
|
||||||
|
|
||||||
void alignHandleToRaster(int index, double rasterWidth, double rasterHeight);
|
void alignHandleToRaster(int index, double rasterWidth, double rasterHeight);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void update(const Style *style);
|
virtual void update(const Style *style);
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const Style *adaptedStyle();
|
const Style *adaptedStyle();
|
||||||
|
|
||||||
QPointF calcEndPoint(const Uid &end, const Uid &otherEnd, int nearestIntermediatePointIndex);
|
QPointF calcEndPoint(const Uid &end, const Uid &otherEnd, int nearestIntermediatePointIndex);
|
||||||
|
|
||||||
QPointF calcEndPoint(const Uid &end, const QPointF &otherEndPos, int nearestIntermediatePointIndex);
|
QPointF calcEndPoint(const Uid &end, const QPointF &otherEndPos, int nearestIntermediatePointIndex);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DRelation *m_relation;
|
DRelation *m_relation;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DiagramSceneModel *m_diagramSceneModel;
|
DiagramSceneModel *m_diagramSceneModel;
|
||||||
|
|
||||||
bool m_isSecondarySelected;
|
bool m_isSecondarySelected;
|
||||||
|
|
||||||
bool m_isFocusSelected;
|
bool m_isFocusSelected;
|
||||||
|
|
||||||
ArrowItem *m_arrow;
|
ArrowItem *m_arrow;
|
||||||
|
|
||||||
QGraphicsSimpleTextItem *m_name;
|
QGraphicsSimpleTextItem *m_name;
|
||||||
|
|
||||||
StereotypesItem *m_stereotypes;
|
StereotypesItem *m_stereotypes;
|
||||||
|
|
||||||
PathSelectionItem *m_selectionHandles;
|
PathSelectionItem *m_selectionHandles;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace qmt
|
||||||
|
|
||||||
#endif // QMT_GRAPHICSRELATIONITEM_H
|
#endif // QMT_GRAPHICSRELATIONITEM_H
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user