2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2016-09-15 17:55:28 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "connectableitem.h"
|
2023-04-18 16:46:04 +02:00
|
|
|
#include "textitem.h"
|
2016-09-15 17:55:28 +02:00
|
|
|
#include <QPen>
|
2023-04-18 16:46:04 +02:00
|
|
|
#include <QStyleOptionGraphicsItem>
|
2016-09-15 17:55:28 +02:00
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QGraphicsSceneMouseEvent)
|
|
|
|
|
|
|
|
|
|
namespace ScxmlEditor {
|
|
|
|
|
|
|
|
|
|
namespace PluginInterface {
|
|
|
|
|
|
|
|
|
|
class TransitionItem;
|
|
|
|
|
class TextItem;
|
|
|
|
|
class IdWarningItem;
|
|
|
|
|
class StateWarningItem;
|
2023-04-18 16:46:04 +02:00
|
|
|
class OnEntryExitItem;
|
2016-09-15 17:55:28 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief The StateItem class represents the SCXML-State.
|
|
|
|
|
*/
|
|
|
|
|
class StateItem : public ConnectableItem
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit StateItem(const QPointF &pos = QPointF(), BaseItem *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
int type() const override
|
|
|
|
|
{
|
|
|
|
|
return StateType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
|
|
|
|
|
|
|
|
|
QString itemId() const;
|
|
|
|
|
void init(ScxmlTag *tag, BaseItem *parentItem = nullptr, bool initChildren = true, bool blockUpdates = false) override;
|
|
|
|
|
void updateBoundingRect();
|
|
|
|
|
void updateAttributes() override;
|
|
|
|
|
void updateEditorInfo(bool allChildren = false) override;
|
|
|
|
|
void updateColors() override;
|
2018-05-07 15:14:01 +02:00
|
|
|
void doLayout(int d) override;
|
2016-09-15 17:55:28 +02:00
|
|
|
void shrink();
|
|
|
|
|
void setInitial(bool initial);
|
|
|
|
|
bool isInitial() const;
|
|
|
|
|
void checkWarnings() override;
|
|
|
|
|
void checkInitial(bool parent = false) override;
|
|
|
|
|
QRectF childItemsBoundingRect() const;
|
|
|
|
|
void connectToParent(BaseItem *parentItem) override;
|
|
|
|
|
|
2023-04-18 16:46:04 +02:00
|
|
|
void addChild(ScxmlTag *child) override;
|
|
|
|
|
|
2016-09-15 17:55:28 +02:00
|
|
|
protected:
|
|
|
|
|
void updatePolygon() override;
|
|
|
|
|
void transitionsChanged() override;
|
|
|
|
|
void transitionCountChanged() override;
|
|
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
|
|
|
|
bool canStartTransition(ItemType type) const override;
|
|
|
|
|
void createContextMenu(QMenu *menu) override;
|
|
|
|
|
void selectedMenuAction(const QAction *action) override;
|
|
|
|
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
|
|
|
|
void writeStateProperties(const QString &tag, QXmlStreamWriter &xml);
|
|
|
|
|
|
|
|
|
|
QRectF m_drawingRect;
|
|
|
|
|
QRectF m_titleRect;
|
|
|
|
|
QRectF m_transitionRect;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void titleHasChanged(const QString &text);
|
|
|
|
|
void updateTextPositions();
|
|
|
|
|
void checkParentBoundingRect();
|
|
|
|
|
void checkWarningItems();
|
2023-04-18 16:46:04 +02:00
|
|
|
void positionOnExitItems();
|
2016-09-15 17:55:28 +02:00
|
|
|
|
|
|
|
|
TextItem *m_stateNameItem;
|
|
|
|
|
StateWarningItem *m_stateWarningItem = nullptr;
|
|
|
|
|
IdWarningItem *m_idWarningItem = nullptr;
|
|
|
|
|
QPen m_pen;
|
|
|
|
|
bool m_initial = false;
|
|
|
|
|
bool m_parallelState = false;
|
2023-04-18 16:46:04 +02:00
|
|
|
QPointer<OnEntryExitItem> m_onEntryItem;
|
|
|
|
|
QPointer<OnEntryExitItem> m_onExitItem;
|
2016-09-15 17:55:28 +02:00
|
|
|
QImage m_backgroundImage;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace PluginInterface
|
|
|
|
|
} // namespace ScxmlEditor
|