KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
commandfactory.cpp
Go to the documentation of this file.
1/*
2 This file is part of the KDAB State Machine Editor Library.
3
4 SPDX-FileCopyrightText: 2014 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#include "commandfactory_p.h"
17
18#include "command_p.h"
27#include "state.h"
28#include "transition.h"
29
30#include "debug.h"
31
32using namespace KDSME;
33
35 : QObject(parent)
36 , m_model(nullptr)
37{
38 qRegisterMetaType<CreateElementCommand *>();
39 qRegisterMetaType<DeleteElementCommand *>();
40 qRegisterMetaType<ModifyElementCommand *>();
41 qRegisterMetaType<ModifyPropertyCommand *>();
42 qRegisterMetaType<ModifyTransitionCommand *>();
43 qRegisterMetaType<ReparentElementCommand *>();
44 qRegisterMetaType<ChangeStateMachineCommand *>();
45}
46
48{
49 return m_model;
50}
51
53{
54 if (m_model == model)
55 return;
56
57 m_model = model;
58 Q_EMIT modelChanged(m_model);
59}
60
62{
63 auto cmd = new CreateElementCommand(model, type);
64 cmd->setParentElement(parentElement);
65 return cmd;
66}
67
72
74{
75 return new LayoutSnapshotCommand(view, text);
76}
77
78ModifyPropertyCommand *CommandFactory::modifyProperty(QObject *object, const char *property, const QVariant &value, const QString &text)
79{
80 return new ModifyPropertyCommand(object, property, value, text);
81}
82
83ModifyPropertyCommand *CommandFactory::modifyProperty(QObject *object, const QJsonObject &propertyMap, const QString &text)
84{
85 return new ModifyPropertyCommand(object, propertyMap, text);
86}
87
92
97
102
104{
105 auto *cmd = new ChangeStateMachineCommand(view);
106 cmd->setStateMachine(statemachine);
107 return cmd;
108}
void modelChanged(KDSME::StateModel *model)
Q_INVOKABLE KDSME::ReparentElementCommand * reparentElement(KDSME::StateMachineScene *view, KDSME::Element *element)
void setModel(KDSME::StateModel *model)
Q_INVOKABLE KDSME::ChangeStateMachineCommand * changeStateMachineElement(KDSME::StateMachineScene *view, KDSME::StateMachine *statemachine)
Q_INVOKABLE KDSME::ModifyElementCommand * modifyElement(KDSME::Element *item)
Q_INVOKABLE KDSME::LayoutSnapshotCommand * layoutSnapshot(KDSME::StateMachineScene *view, const QString &text=QString()) const
KDSME::StateModel * model
Q_INVOKABLE KDSME::DeleteElementCommand * deleteElement(KDSME::StateMachineScene *view, KDSME::Element *element) const
Q_INVOKABLE KDSME::CreateElementCommand * createElement(KDSME::StateModel *model, KDSME::Element::Type type, KDSME::Element *parentElement=nullptr) const
Q_INVOKABLE KDSME::ModifyPropertyCommand * modifyProperty(QObject *object, const char *property, const QVariant &value, const QString &text=QString())
CommandFactory(QObject *parent=nullptr)
Q_INVOKABLE KDSME::ModifyTransitionCommand * modifyTransition(KDSME::Transition *transition, KDSME::StateModel *model)
Changes the state machine of a KDSME::StateMachineScene and records the old state machine the scene w...
This is the inverse operation to the KDSME::CreateElementCommand command.
Creates a snapshot of the current layout of the state chart.
Command for modifying properties of KDSME::Element.
Modifies any specific property of a QObject.
Command for modifying properties of a KDSME::Transition.
Modifies the parent element of a KDSME::Element.

© 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
Generated on Tue Jul 15 2025 15:21:47 for KDStateMachineEditor API Documentation by doxygen 1.9.8