KDStateMachineEditor API Documentation
1.2
source
src
core
model
elementmodel.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
#ifndef KDSME_MODEL_ELEMENTMODEL_H
17
#define KDSME_MODEL_ELEMENTMODEL_H
18
19
#include "element.h"
20
#include "objecttreemodel.h"
21
#include "kdsme_core_export.h"
22
23
#include <QAbstractItemModel>
24
#include <QObject>
25
#include <QPointer>
26
#include <QSortFilterProxyModel>
27
28
namespace
KDSME {
29
30
class
StateModel;
31
class
State;
32
33
class
KDSME_CORE_EXPORT
TransitionModel
:
public
QSortFilterProxyModel
34
{
35
Q_OBJECT
36
37
public
:
38
explicit
TransitionModel
(
QObject
* parent =
nullptr
);
39
~
TransitionModel
();
40
41
void
setSourceModel(
QAbstractItemModel
* sourceModel)
override
;
42
43
bool
filterAcceptsRow(
int
source_row,
const
QModelIndex
& source_parent)
const override
;
44
45
private
:
46
struct
Private;
47
QScopedPointer<Private>
d;
48
};
49
50
class
KDSME_CORE_EXPORT
TransitionListModel
:
public
QAbstractListModel
51
{
52
Q_OBJECT
53
Q_PROPERTY(
KDSME::State
* state READ state WRITE setState)
54
55
public
:
56
enum
Role {
57
ObjectRole =
Qt::UserRole
+ 1,
58
};
59
60
enum
Column {
61
NameColumn,
62
SourceStateColumn,
63
TargetStateColumn,
64
_LastColumn
65
};
66
67
explicit
TransitionListModel
(
QObject
* parent =
nullptr
);
68
~
TransitionListModel
();
69
70
State
* state()
const
;
71
void
setState(
State
* state);
72
73
int
rowCount(
const
QModelIndex
& parent =
QModelIndex
())
const override
;
74
int
columnCount(
const
QModelIndex
& parent)
const override
;
75
QVariant
data(
const
QModelIndex
& index,
int
role =
Qt::DisplayRole
)
const override
;
76
QVariant
headerData(
int
section,
Qt::Orientation
orientation,
int
role =
Qt::DisplayRole
)
const override
;
77
QHash< int, QByteArray >
roleNames()
const override
;
78
79
private
:
80
struct
Private;
81
QScopedPointer<Private>
d;
82
};
83
84
class
KDSME_CORE_EXPORT
StateModel
:
public
ObjectTreeModel
85
{
86
Q_OBJECT
87
Q_PROPERTY(
KDSME::State
* state READ state WRITE setState)
88
89
public
:
90
enum
Role
{
91
ElementRole = ObjectTreeModel::UserRole + 1,
92
InternalIdRole
,
93
};
94
95
explicit
StateModel
(
QObject
* parent =
nullptr
);
96
~
StateModel
();
97
98
State
* state()
const
;
99
void
setState(
State
* state);
100
101
QVariant
data(
const
QModelIndex
& index,
int
role =
Qt::DisplayRole
)
const override
;
102
QVariant
headerData(
int
section,
Qt::Orientation
orientation,
int
role =
Qt::DisplayRole
)
const override
;
103
Qt::ItemFlags
flags(
const
QModelIndex
& index)
const override
;
104
105
private
:
106
struct
Private;
107
QScopedPointer<Private>
d;
108
};
109
110
}
111
112
Q_DECLARE_METATYPE(
KDSME::TransitionModel
*)
113
Q_DECLARE_METATYPE(
KDSME::StateModel
*)
114
115
#endif
Qt::UserRole
UserRole
QAbstractListModel
QSortFilterProxyModel
KDSME::StateModel::Role
Role
Definition:
elementmodel.h:90
Qt::ItemFlags
typedef ItemFlags
QObject
Qt::Orientation
Orientation
KDSME::StateModel::InternalIdRole
@ InternalIdRole
return quint64
Definition:
elementmodel.h:92
KDSME::TransitionModel
Definition:
elementmodel.h:34
QScopedPointer< Private >
KDSME::TransitionListModel
Definition:
elementmodel.h:51
QModelIndex
QVariant
KDSME::State
Definition:
state.h:29
KDSME::StateModel
Definition:
elementmodel.h:85
QHash
KDSME::ObjectTreeModel
Definition:
objecttreemodel.h:28
QAbstractItemModel
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