KDStateMachineEditor API Documentation  1.2
statemachinescene.h
1 /*
2  This file is part of the KDAB State Machine Editor Library.
3 
4  SPDX-FileCopyrightText: 2014-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5  Author: Kevin Funk <kevin.funk@kdab.com>
6 
7  SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
8 
9  Licensees holding valid commercial KDAB State Machine Editor Library
10  licenses may use this file in accordance with the KDAB State Machine Editor
11  Library License Agreement provided with the Software.
12 
13  Contact info@kdab.com if any conditions of this licensing are not clear to you.
14 */
15 
16 
17 #ifndef KDSME_VIEW_STATEMACHINESCENE_H
18 #define KDSME_VIEW_STATEMACHINESCENE_H
19 
20 #include "kdsme_view_export.h"
21 #include "abstractscene.h"
22 
23 #include <QObject>
24 
25 namespace KDSME {
26 class Element;
27 class Layouter;
28 class LayoutProperties;
29 class State;
30 class StateMachine;
31 class StateModel;
32 class Transition;
33 
34 class KDSME_VIEW_EXPORT StateMachineScene : public AbstractScene
35 {
36  Q_OBJECT
37  Q_PROPERTY(KDSME::State* rootState READ rootState WRITE setRootState NOTIFY rootStateChanged)
38  Q_PROPERTY(KDSME::Element* currentItem READ currentItem WRITE setCurrentItem NOTIFY currentItemChanged)
39  Q_PROPERTY(KDSME::LayoutProperties* layoutProperties READ layoutProperties CONSTANT)
40  Q_PROPERTY(qreal zoom READ zoom WRITE setZoom NOTIFY zoomChanged FINAL)
41  Q_PROPERTY(int maximumDepth READ maximumDepth WRITE setMaximumDepth NOTIFY maximumDepthChanged FINAL)
42 
43 public:
44  explicit StateMachineScene(QQuickItem* parent = nullptr);
46 
47  StateModel* stateModel() const;
48  void setModel(QAbstractItemModel* model) override;
49 
50  State* rootState() const;
51  void setRootState(State* rootState);
52 
53  Layouter* layouter() const;
55  void setLayouter(Layouter* layouter);
56 
57  qreal zoom() const;
58  void setZoom(qreal zoom);
59 
60  void zoomBy(qreal scale);
61 
62  int maximumDepth() const;
63  void setMaximumDepth(int maximumDepth);
64 
65  LayoutProperties* layoutProperties() const;
66 
67  Q_INVOKABLE void collapseItem(KDSME::State* state);
68  Q_INVOKABLE void expandItem(KDSME::State* state);
69  Q_INVOKABLE bool isItemExpanded(KDSME::State* state) const;
70  Q_INVOKABLE void setItemExpanded(KDSME::State* state, bool expand);
71 
72  Q_INVOKABLE bool isItemSelected(KDSME::Element* item);
73  Q_INVOKABLE void setItemSelected(KDSME::Element* item, bool selected);
74 
75  KDSME::Element* currentItem() const;
76  void setCurrentItem(KDSME::Element* item);
77 
78  KDSME::Element* currentState() const;
79 
80 public Q_SLOTS:
81  void layout();
82 
83 Q_SIGNALS:
84  void stateMachineChanged(KDSME::StateMachine* stateMachine);
85  void rootStateChanged(KDSME::State* state);
86  void currentItemChanged(KDSME::Element* currentItem);
87  void zoomChanged(qreal zoom);
88  void maximumDepthChanged(int depth);
89 
90 protected Q_SLOTS:
91  void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
92 
93  void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
94  void rowsInserted(const QModelIndex& parent, int start, int end) override;
95  void layoutChanged() override;
96 
97 private:
98  struct Private;
100 };
101 
102 }
103 
104 Q_DECLARE_METATYPE(KDSME::StateMachineScene*)
105 
106 #endif // VIEW_H
KDSME::LayoutProperties
Definition: layoutproperties.h:29
KDSME::StateMachine
Definition: state.h:154
KDSME::AbstractScene
Definition: abstractscene.h:51
QScopedPointer< Private >
KDSME::Layouter
Definition: layouter.h:34
QModelIndex
KDSME::Element
Definition: element.h:35
KDSME::State
Definition: state.h:29
KDSME::StateModel
Definition: elementmodel.h:85
QAbstractItemModel
KDSME::StateMachineScene
Definition: statemachinescene.h:35

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor