KDStateMachineEditor  1.0.0
A framework for creating Qt State Machine metacode using a graphical user interface
statemachinescene.h
1 /*
2  statemachinescene.h
3 
4  This file is part of the KDAB State Machine Editor Library.
5 
6  Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com.
7  All rights reserved.
8  Author: Kevin Funk <kevin.funk@kdab.com>
9 
10  Licensees holding valid commercial KDAB State Machine Editor Library
11  licenses may use this file in accordance with the KDAB State Machine Editor
12  Library License Agreement provided with the Software.
13 
14  This file may be distributed and/or modified under the terms of the
15  GNU Lesser General Public License version 2.1 as published by the
16  Free Software Foundation and appearing in the file LICENSE.LGPL.txt included.
17 
18  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 
21  Contact info@kdab.com if any conditions of this licensing are not
22  clear to you.
23 */
24 
25 
26 #ifndef KDSME_VIEW_STATEMACHINESCENE_H
27 #define KDSME_VIEW_STATEMACHINESCENE_H
28 
29 #include "kdsme_view_export.h"
30 #include "abstractscene.h"
31 
32 #include <QObject>
33 
34 namespace KDSME {
35 class Element;
36 class Layouter;
37 class LayoutProperties;
38 class State;
39 class StateMachine;
40 class StateModel;
41 class Transition;
42 
43 class KDSME_VIEW_EXPORT StateMachineScene : public AbstractScene
44 {
45  Q_OBJECT
46  Q_PROPERTY(KDSME::State* rootState READ rootState WRITE setRootState NOTIFY rootStateChanged)
47  Q_PROPERTY(KDSME::Element* currentItem READ currentItem WRITE setCurrentItem NOTIFY currentItemChanged)
48  Q_PROPERTY(KDSME::LayoutProperties* layoutProperties READ layoutProperties CONSTANT)
49  Q_PROPERTY(qreal zoom READ zoom WRITE setZoom NOTIFY zoomChanged FINAL)
50  Q_PROPERTY(int maximumDepth READ maximumDepth WRITE setMaximumDepth NOTIFY maximumDepthChanged FINAL)
51 
52 public:
53  explicit StateMachineScene(QQuickItem* parent = nullptr);
54  virtual ~StateMachineScene();
55 
56  StateModel* stateModel() const;
57  virtual void setModel(QAbstractItemModel* model) override;
58 
59  State* rootState() const;
60  void setRootState(State* rootState);
61 
62  Layouter* layouter() const;
64  void setLayouter(Layouter* layouter);
65 
66  qreal zoom() const;
67  void setZoom(qreal zoom);
68 
69  void zoomBy(qreal scale);
70 
71  int maximumDepth() const;
72  void setMaximumDepth(int depth);
73 
74  LayoutProperties* layoutProperties() const;
75 
76  Q_INVOKABLE void collapseItem(KDSME::State* state);
77  Q_INVOKABLE void expandItem(KDSME::State* state);
78  Q_INVOKABLE bool isItemExpanded(KDSME::State* state) const;
79  Q_INVOKABLE void setItemExpanded(KDSME::State* state, bool expand);
80 
81  Q_INVOKABLE bool isItemSelected(KDSME::Element* item);
82  Q_INVOKABLE void setItemSelected(KDSME::Element* item, bool selected);
83 
84  KDSME::Element* currentItem() const;
85  void setCurrentItem(KDSME::Element* item);
86 
87  KDSME::Element* currentState();
88 
89 public Q_SLOTS:
90  void layout();
91 
92 Q_SIGNALS:
93  void stateMachineChanged(KDSME::StateMachine* stateMachine);
94  void rootStateChanged(KDSME::State* state);
95  void currentItemChanged(KDSME::Element* currentItem);
96  void zoomChanged(qreal zoom);
97  void maximumDepthChanged(int depth);
98 
99 protected Q_SLOTS:
100  virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
101 
102  virtual void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
103  virtual void rowsInserted(const QModelIndex& parent, int start, int end) override;
104  virtual void layoutChanged() override;
105 
106 private:
107  struct Private;
108  QScopedPointer<Private> d;
109 };
110 
111 }
112 
113 Q_DECLARE_METATYPE(KDSME::StateMachineScene*)
114 
115 #endif // VIEW_H
Definition: layoutproperties.h:37
Definition: elementmodel.h:97
Definition: state.h:160
Definition: abstractscene.h:38
Definition: state.h:35
Definition: layouter.h:40
Definition: statemachinescene.h:43
Definition: element.h:41
Definition: abstractexporter.h:33

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
https://github.com/KDAB/KDStateMachineEditor