KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
quickrecursiveinstantiator_p.h
Go to the documentation of this file.
1/*
2 This file is part of the KDAB State Machine Editor Library.
3
4 SPDX-FileCopyrightText: 2015 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_QUICK_QUICKRECURSIVEINSTANTIATOR_P_H
17#define KDSME_QUICK_QUICKRECURSIVEINSTANTIATOR_P_H
18
20
21#include <QPersistentModelIndex>
22#include <QQuickItem>
23
24QT_BEGIN_NAMESPACE
25class QAbstractItemModel;
26class QQmlContext;
27QT_END_NAMESPACE
28
29class QuickRecursiveInstantiator : public QQuickItem, public InstantiatorInterface
30{
31 Q_OBJECT
32 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged)
33 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
34 Q_CLASSINFO("DefaultProperty", "delegate")
35
36public:
37 explicit QuickRecursiveInstantiator(QQuickItem *parent = nullptr);
38
39 QAbstractItemModel *model() const;
40 virtual void setModel(QAbstractItemModel *model);
41
42 QQmlComponent *delegate() const;
43 void setDelegate(QQmlComponent *delegate);
44
45 QObject *itemForIndex(const QModelIndex &index) const override;
46
47 QList<QObject *> rootItems() const;
48
49private Q_SLOTS:
50 void modelReset();
51 void modelDestroyed();
52 void rowsInserted(const QModelIndex &parent, int first, int last);
53 void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
54
55Q_SIGNALS:
56 void modelChanged(QAbstractItemModel *model);
57 void delegateChanged(QQmlComponent *delegate);
58
59private:
60 QObject *createItems(const QModelIndex &index, QObject *parent);
61 void removeItems(const QModelIndex &index, QObject *parent);
62
63 QAbstractItemModel *m_model;
64 QQmlComponent *m_delegate;
65 QHash<QPersistentModelIndex, QObject *> m_createdItems;
66
67 QList<QObject *> m_rootItems;
68};
69
70#endif // KDSME_QUICK_QUICKRECURSIVEINSTANTIATOR_P_H
virtual void setModel(QAbstractItemModel *model)
void modelChanged(QAbstractItemModel *model)
QObject * itemForIndex(const QModelIndex &index) const override
void setDelegate(QQmlComponent *delegate)
void delegateChanged(QQmlComponent *delegate)
QList< QObject * > rootItems() const

© 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