Commit 11eca837 authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Apply naming convention to enums

Change-Id: I215214965d4f6196d805b9001cf59d8cbf2c7c64
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 5d3812af
......@@ -136,9 +136,9 @@ Token TextScanner::read()
} else if (sourceChar.ch == QLatin1Char('#')) {
return scanColorIdentifier(sourceChar);
} else if (sourceChar.ch == QChar::LineFeed || sourceChar.ch == QChar::CarriageReturn) {
return Token(Token::TOKEN_ENDOFLINE, QString(), sourceChar.pos);
return Token(Token::TokenEndOfLine, QString(), sourceChar.pos);
} else if (sourceChar.ch.isNull()) {
return Token(Token::TOKEN_ENDOFINPUT, QString(), sourceChar.pos);
return Token(Token::TokenEndOfInput, QString(), sourceChar.pos);
} else if (d->m_operatorFirstCharsSet.contains(sourceChar.ch)) {
return scanOperator(sourceChar);
} else {
......@@ -198,7 +198,7 @@ Token TextScanner::scanString(const SourceChar &delimiterChar)
for (;;) {
SourceChar sourceChar = readChar();
if (sourceChar.ch == delimiterChar.ch) {
return Token(Token::TOKEN_STRING, text, delimiterChar.pos);
return Token(Token::TokenString, text, delimiterChar.pos);
} else if (sourceChar.ch == QLatin1Char('\\')) {
sourceChar = readChar();
if (sourceChar.ch == QLatin1Char('n')) {
......@@ -243,10 +243,10 @@ Token TextScanner::scanNumber(const SourceChar &firstDigit)
text += sourceChar.ch;
}
unreadChar(sourceChar);
return Token(Token::TOKEN_FLOAT, text, firstDigit.pos);
return Token(Token::TokenFloat, text, firstDigit.pos);
} else {
unreadChar(sourceChar);
return Token(Token::TOKEN_INTEGER, text, firstDigit.pos);
return Token(Token::TokenInteger, text, firstDigit.pos);
}
}
......@@ -260,9 +260,9 @@ Token TextScanner::scanIdentifier(const SourceChar &firstChar)
unreadChar(sourceChar);
QString keyword = text.toLower();
if (d->m_keywordToSubtypeMap.contains(keyword)) {
return Token(Token::TOKEN_KEYWORD, d->m_keywordToSubtypeMap.value(keyword), text, firstChar.pos);
return Token(Token::TokenKeyword, d->m_keywordToSubtypeMap.value(keyword), text, firstChar.pos);
}
return Token(Token::TOKEN_IDENTIFIER, text, firstChar.pos);
return Token(Token::TokenIdentifier, text, firstChar.pos);
}
text += sourceChar.ch;
}
......@@ -277,7 +277,7 @@ Token TextScanner::scanColorIdentifier(const SourceChar &firstChar)
QChar ch = sourceChar.ch.toLower();
if (!(ch.isDigit() || (ch >= QLatin1Char('a') && ch <= QLatin1Char('f')))) {
unreadChar(sourceChar);
return Token(Token::TOKEN_COLOR, text, firstChar.pos);
return Token(Token::TokenColor, text, firstChar.pos);
}
text += sourceChar.ch;
}
......@@ -311,7 +311,7 @@ Token TextScanner::scanOperator(const SourceChar &firstChar)
}
QMT_CHECK(haveOperator);
Q_UNUSED(haveOperator); // avoid warning in release mode
return Token(Token::TOKEN_OPERATOR, subtype, op, firstChar.pos);
return Token(Token::TokenOperator, subtype, op, firstChar.pos);
}
text += sourceChar.ch;
extraChars.push(sourceChar);
......
......@@ -33,7 +33,7 @@
namespace qmt {
Token::Token()
: m_type(TOKEN_UNDEFINED),
: m_type(TokenUndefined),
m_subtype(0)
{
}
......
......@@ -42,16 +42,16 @@ class Token
public:
enum Type {
TOKEN_UNDEFINED,
TOKEN_ENDOFINPUT,
TOKEN_ENDOFLINE,
TOKEN_STRING,
TOKEN_INTEGER,
TOKEN_FLOAT,
TOKEN_IDENTIFIER,
TOKEN_KEYWORD,
TOKEN_OPERATOR,
TOKEN_COLOR
TokenUndefined,
TokenEndOfInput,
TokenEndOfLine,
TokenString,
TokenInteger,
TokenFloat,
TokenIdentifier,
TokenKeyword,
TokenOperator,
TokenColor
};
public:
......
......@@ -37,7 +37,7 @@ namespace qmt {
DAnnotation::DAnnotation()
: DElement(),
m_visualRole(ROLE_NORMAL),
m_visualRole(RoleNormal),
m_autoSized(true)
{
}
......
......@@ -44,12 +44,12 @@ class QMT_EXPORT DAnnotation :
public:
enum VisualRole {
ROLE_NORMAL,
ROLE_TITLE,
ROLE_SUBTITLE,
ROLE_EMPHASIZED,
ROLE_SOFTEN,
ROLE_FOOTNOTE
RoleNormal,
RoleTitle,
RoleSubtitle,
RoleEmphasized,
RoleSoften,
RoleFootnote
};
public:
......
......@@ -37,7 +37,7 @@
namespace qmt {
DAssociationEnd::DAssociationEnd()
: m_kind(MAssociationEnd::ASSOCIATION),
: m_kind(MAssociationEnd::Association),
m_navigable(false)
{
}
......
......@@ -37,7 +37,7 @@
namespace qmt {
DClass::DClass()
: m_templateDisplay(TEMPLATE_SMART),
: m_templateDisplay(TemplateSmart),
m_showAllMembers(false)
{
}
......
......@@ -45,9 +45,9 @@ class QMT_EXPORT DClass :
public:
enum TemplateDisplay {
TEMPLATE_SMART,
TEMPLATE_BOX,
TEMPLATE_NAME
TemplateSmart,
TemplateBox,
TemplateName
};
public:
......
......@@ -37,7 +37,7 @@
namespace qmt {
DDependency::DDependency()
: m_direction(MDependency::A_TO_B)
: m_direction(MDependency::AToB)
{
}
......@@ -47,22 +47,22 @@ DDependency::~DDependency()
Uid DDependency::source() const
{
return m_direction == MDependency::B_TO_A ? endBUid() : endAUid();
return m_direction == MDependency::BToA ? endBUid() : endAUid();
}
void DDependency::setSource(const Uid &source)
{
m_direction == MDependency::B_TO_A ? setEndBUid(source) : setEndAUid(source);
m_direction == MDependency::BToA ? setEndBUid(source) : setEndAUid(source);
}
Uid DDependency::target() const
{
return m_direction == MDependency::B_TO_A ? endAUid() : endBUid();
return m_direction == MDependency::BToA ? endAUid() : endBUid();
}
void DDependency::setTarget(const Uid &target)
{
return m_direction == MDependency::B_TO_A ? setEndAUid(target) : setEndBUid(target);
return m_direction == MDependency::BToA ? setEndAUid(target) : setEndBUid(target);
}
void DDependency::setDirection(MDependency::Direction direction)
......
......@@ -39,9 +39,9 @@ DObject::DObject()
: DElement(),
m_modelUid(Uid::invalidUid()),
m_depth(0),
m_visualPrimaryRole(PRIMARY_ROLE_NORMAL),
m_visualSecondaryRole(SECONDARY_ROLE_NONE),
m_stereotypeDisplay(STEREOTYPE_SMART),
m_visualPrimaryRole(PrimaryRoleNormal),
m_visualSecondaryRole(SecondaryRoleNone),
m_stereotypeDisplay(StereotypeSmart),
m_autoSized(true),
m_visualEmphasized(false)
{
......
......@@ -51,32 +51,32 @@ class QMT_EXPORT DObject :
public:
enum VisualPrimaryRole {
PRIMARY_ROLE_NORMAL,
DEPRECATED_PRIMARY_ROLE_LIGHTER,
DEPRECATED_PRIMARY_ROLE_DARKER,
DEPRECATED_PRIMARY_ROLE_SOFTEN,
DEPRECATED_PRIMARY_ROLE_OUTLINE,
PRIMARY_ROLE_CUSTOM1,
PRIMARY_ROLE_CUSTOM2,
PRIMARY_ROLE_CUSTOM3,
PRIMARY_ROLE_CUSTOM4,
PRIMARY_ROLE_CUSTOM5
PrimaryRoleNormal,
DeprecatedPrimaryRoleLighter,
DeprecatedPrimaryRoleDarker,
DeprecatedPrimaryRoleSoften,
DeprecatedPrimaryRoleOutline,
PrimaryRoleCustom1,
PrimaryRoleCustom2,
PrimaryRoleCustom3,
PrimaryRoleCustom4,
PrimaryRoleCustom5
};
enum VisualSecondaryRole {
SECONDARY_ROLE_NONE,
SECONDARY_ROLE_LIGHTER,
SECONDARY_ROLE_DARKER,
SECONDARY_ROLE_SOFTEN,
SECONDARY_ROLE_OUTLINE
SecondaryRoleNone,
SecondaryRoleLighter,
SecondaryRoleDarker,
SecondaryRoleSoften,
SecondaryRoleOutline
};
enum StereotypeDisplay {
STEREOTYPE_NONE,
STEREOTYPE_LABEL,
STEREOTYPE_DECORATION,
STEREOTYPE_ICON,
STEREOTYPE_SMART
StereotypeNone,
StereotypeLabel,
StereotypeDecoration,
StereotypeIcon,
StereotypeSmart
};
public:
......
......@@ -131,7 +131,7 @@ public:
if (diagramKey() != otherUpdateCommand->diagramKey()) {
return false;
}
if (m_updateAction == DiagramController::UPDATE_MAJOR || otherUpdateCommand->m_updateAction == DiagramController::UPDATE_MAJOR
if (m_updateAction == DiagramController::UpdateMajor || otherUpdateCommand->m_updateAction == DiagramController::UpdateMajor
|| m_updateAction != otherUpdateCommand->m_updateAction) {
return false;
}
......
......@@ -64,9 +64,9 @@ class QMT_EXPORT DiagramController :
public:
enum UpdateAction {
UPDATE_GEOMETRY, // update only position and size of element
UPDATE_MAJOR, // a major update of the element which will create a separate undo command
UPDATE_MINOR // a minor update of the element which may be merged with other minor updates in one undo command
UpdateGeometry, // update only position and size of element
UpdateMajor, // a major update of the element which will create a separate undo command
UpdateMinor // a minor update of the element which may be merged with other minor updates in one undo command
};
private:
......
......@@ -40,15 +40,15 @@ class IAlignable {
public:
enum AlignType {
ALIGN_LEFT,
ALIGN_RIGHT,
ALIGN_TOP,
ALIGN_BOTTOM,
ALIGN_HCENTER,
ALIGN_VCENTER,
ALIGN_WIDTH,
ALIGN_HEIGHT,
ALIGN_SIZE
AlignLeft,
AlignRight,
AlignTop,
AlignBottom,
AlignHcenter,
AlignVcenter,
AlignWidth,
AlignHeight,
AlignSize
};
public:
......
......@@ -39,26 +39,26 @@ class ILatchable {
public:
enum Action {
MOVE,
RESIZE_LEFT,
RESIZE_TOP,
RESIZE_RIGHT,
RESIZE_BOTTOM
Move,
ResizeLeft,
ResizeTop,
ResizeRight,
ResizeBottom
};
enum LatchType {
NONE,
LEFT,
TOP,
RIGHT,
BOTTOM,
HCENTER,
VCENTER
None,
Left,
Top,
Right,
Bottom,
Hcenter,
Vcenter
};
struct Latch {
Latch()
: m_latchType(NONE),
: m_latchType(None),
m_pos(0.0),
m_otherPos1(0.0),
m_otherPos2(0.0),
......
......@@ -46,9 +46,9 @@ class IResizable {
public:
enum Side {
SIDE_NONE,
SIDE_LEFT_OR_TOP,
SIDE_RIGHT_OR_BOTTOM
SideNone,
SideLeftOrTop,
SideRightOrBottom
};
public:
......
......@@ -112,7 +112,7 @@ DiagramSceneModel::DiagramSceneModel(QObject *parent)
m_diagram(0),
m_graphicsScene(new DiagramGraphicsScene(this)),
m_latchController(new LatchController(this)),
m_busy(NOT_BUSY),
m_busy(NotBusy),
m_originItem(new OriginItem()),
m_focusItem(0)
{
......@@ -128,7 +128,7 @@ DiagramSceneModel::DiagramSceneModel(QObject *parent)
DiagramSceneModel::~DiagramSceneModel()
{
QMT_CHECK(m_busy == NOT_BUSY);
QMT_CHECK(m_busy == NotBusy);
m_latchController->removeFromGraphicsScene(m_graphicsScene);
disconnect();
if (m_diagramController) {
......@@ -515,7 +515,7 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
rect.translate(resizable->pos());
switch (collidingMode) {
case COLLIDING_INNER_ITEMS:
case CollidingInnerItems:
foreach (QGraphicsItem *candidate, m_graphicsItems) {
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
QRectF candidateRect = candidateResizable->rect();
......@@ -527,7 +527,7 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
}
}
break;
case COLLIDING_ITEMS:
case CollidingItems:
foreach (QGraphicsItem *candidate, m_graphicsItems) {
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
QRectF candidateRect = candidateResizable->rect();
......@@ -539,7 +539,7 @@ QList<QGraphicsItem *> DiagramSceneModel::collectCollidingObjectItems(const QGra
}
}
break;
case COLLIDING_OUTER_ITEMS:
case CollidingOuterItems:
foreach (QGraphicsItem *candidate, m_graphicsItems) {
if (const IResizable *candidateResizable = dynamic_cast<const IResizable *>(candidate)) {
QRectF candidateRect = candidateResizable->rect();
......@@ -653,8 +653,8 @@ void DiagramSceneModel::onEndResetAllDiagrams()
void DiagramSceneModel::onBeginResetDiagram(const MDiagram *diagram)
{
QMT_CHECK(m_busy == NOT_BUSY);
m_busy = RESET_DIAGRAM;
QMT_CHECK(m_busy == NotBusy);
m_busy = ResetDiagram;
if (diagram == m_diagram) {
clearGraphicsScene();
}
......@@ -662,7 +662,7 @@ void DiagramSceneModel::onBeginResetDiagram(const MDiagram *diagram)
void DiagramSceneModel::onEndResetDiagram(const MDiagram *diagram)
{
QMT_CHECK(m_busy == RESET_DIAGRAM);
QMT_CHECK(m_busy == ResetDiagram);
if (diagram == m_diagram) {
QMT_CHECK(m_graphicsItems.size() == 0);
// create all items and update graphics item from element initially
......@@ -678,39 +678,39 @@ void DiagramSceneModel::onEndResetDiagram(const MDiagram *diagram)
updateGraphicsItem(m_elementToItemMap.value(element), element);
}
}
m_busy = NOT_BUSY;
m_busy = NotBusy;
}
void DiagramSceneModel::onBeginUpdateElement(int row, const MDiagram *diagram)
{
Q_UNUSED(row);
Q_UNUSED(diagram);
QMT_CHECK(m_busy == NOT_BUSY);
m_busy = UPDATE_ELEMENT;
QMT_CHECK(m_busy == NotBusy);
m_busy = UpdateElement;
}
void DiagramSceneModel::onEndUpdateElement(int row, const MDiagram *diagram)
{
QMT_CHECK(m_busy == UPDATE_ELEMENT);
QMT_CHECK(m_busy == UpdateElement);
if (diagram == m_diagram) {
QGraphicsItem *item = m_graphicsItems.at(row);
updateGraphicsItem(item, diagram->diagramElements().at(row));
}
m_busy = NOT_BUSY;
m_busy = NotBusy;
}
void DiagramSceneModel::onBeginInsertElement(int row, const MDiagram *diagram)
{
Q_UNUSED(row);
Q_UNUSED(diagram);
QMT_CHECK(m_busy == NOT_BUSY);
m_busy = INSERT_ELEMENT;
QMT_CHECK(m_busy == NotBusy);
m_busy = InsertElement;
}
void DiagramSceneModel::onEndInsertElement(int row, const MDiagram *diagram)
{
QMT_CHECK(m_busy == INSERT_ELEMENT);
QMT_CHECK(m_busy == InsertElement);
QGraphicsItem *item = 0;
if (diagram == m_diagram) {
DElement *element = diagram->diagramElements().at(row);
......@@ -720,25 +720,25 @@ void DiagramSceneModel::onEndInsertElement(int row, const MDiagram *diagram)
m_graphicsScene->invalidate();
updateGraphicsItem(item, element);
}
m_busy = NOT_BUSY;
m_busy = NotBusy;
}
void DiagramSceneModel::onBeginRemoveElement(int row, const MDiagram *diagram)
{
QMT_CHECK(m_busy == NOT_BUSY);
QMT_CHECK(m_busy == NotBusy);
if (diagram == m_diagram) {
QGraphicsItem *item = m_graphicsItems.takeAt(row);
deleteGraphicsItem(item, diagram->diagramElements().at(row));
}
m_busy = REMOVE_ELEMENT;
m_busy = RemoveElement;
}
void DiagramSceneModel::onEndRemoveElement(int row, const MDiagram *diagram)
{
Q_UNUSED(row);
Q_UNUSED(diagram);
QMT_CHECK(m_busy == REMOVE_ELEMENT);
m_busy = NOT_BUSY;
QMT_CHECK(m_busy == RemoveElement);
m_busy = NotBusy;
}
void DiagramSceneModel::onSelectionChanged()
......@@ -769,7 +769,7 @@ void DiagramSceneModel::onSelectionChanged()
// select all contained objects secondarily
foreach (QGraphicsItem *selectedItem, m_selectedItems) {
foreach (QGraphicsItem *item, collectCollidingObjectItems(selectedItem, COLLIDING_INNER_ITEMS)) {
foreach (QGraphicsItem *item, collectCollidingObjectItems(selectedItem, CollidingInnerItems)) {
if (!item->isSelected() && dynamic_cast<ISelectable *>(item) != 0
&& item->collidesWithItem(selectedItem, Qt::ContainsItemBoundingRect)
&& isInFrontOf(item, selectedItem)) {
......
......@@ -76,9 +76,9 @@ class QMT_EXPORT DiagramSceneModel :
public:
enum CollidingMode {
COLLIDING_INNER_ITEMS,
COLLIDING_ITEMS,
COLLIDING_OUTER_ITEMS
CollidingInnerItems,
CollidingItems,
CollidingOuterItems
};
......@@ -237,11 +237,11 @@ private:
private:
enum Busy {
NOT_BUSY,
RESET_DIAGRAM,
UPDATE_ELEMENT,
INSERT_ELEMENT,
REMOVE_ELEMENT
NotBusy,
ResetDiagram,
UpdateElement,
InsertElement,
RemoveElement
};
private:
......
......@@ -168,7 +168,7 @@ void AnnotationItem::setPosAndRect(const QPointF &originalPos, const QRectF &ori
QRectF newRect = originalRect;
GeometryUtilities::adjustPosAndRect(&newPos, &newRect, topLeftDelta, bottomRightDelta, QPointF(0.0, 0.0));
if (newPos != m_annotation->pos() || newRect != m_annotation->rect()) {
m_diagramSceneModel->diagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->diagram(), DiagramController::UPDATE_GEOMETRY);
m_diagramSceneModel->diagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
m_annotation->setPos(newPos);
if (newRect.size() != m_annotation->rect().size()) {
m_annotation->setAutoSize(false);
......@@ -188,7 +188,7 @@ void AnnotationItem::alignItemSizeToRaster(Side adjustHorizontalSide, Side adjus
void AnnotationItem::moveDelta(const QPointF &delta)
{
m_diagramSceneModel->diagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->diagram(), DiagramController::UPDATE_GEOMETRY);
m_diagramSceneModel->diagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->diagram(), DiagramController::UpdateGeometry);
m_annotation->setPos(m_annotation->pos() + delta);
m_diagramSceneModel->diagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->diagram(), false);
}
......@@ -277,7 +277,7 @@ void AnnotationItem::updateSelectionMarker()
if (!m_selectionMarker) {
m_selectionMarker = new RectangularSelectionItem(this, this);
m_selectionMarker->setShowBorder(true);
m_selectionMarker->setFreedom(RectangularSelectionItem::FREEDOM_HORIZONTAL_ONLY);
m_selectionMarker->setFreedom(RectangularSelectionItem::FreedomHorizontalOnly);
}
m_selectionMarker->setSecondarySelected(isSelected() ? false : m_secondarySelected);
} else if (m_selectionMarker) {
......@@ -320,7 +320,7 @@ void AnnotationItem::onContentsChanged()
if (!m_onUpdate) {
QString plainText = m_textItem->toPlainText();
if (m_annotation->text() != plainText) {
m_diagramSceneModel->diagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->diagram(), DiagramController::UPDATE_MINOR);
m_diagramSceneModel->diagramController()->startUpdateElement(m_annotation, m_diagramSceneModel->diagram(), DiagramController::UpdateMinor);
m_annotation->setText(plainText);
m_diagramSceneModel->diagramController()->finishUpdateElement(m_annotation, m_diagramSceneModel->diagram(), false);
}
......