Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_node_model.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KIS_NODE_MODEL
7#define KIS_NODE_MODEL
8
9#include "kritaui_export.h"
10#include <kis_types.h>
11#include <QAbstractItemModel>
12#include <QList>
13#include <QString>
14#include <QVariant>
15
16#include <KisSelectionTags.h>
17
19class KisNodeDummy;
26class KisNodeManager;
28
45class KRITAUI_EXPORT KisNodeModel : public QAbstractItemModel
46{
47
48 Q_OBJECT
49
50public:
53 {
55 ActiveRole = Qt::UserRole + 1,
56
59
62
65
69
70 // When a layer is not (recursively) visible, then it should be grayed out
72
73 // An index of a color label associated with the node
75
76 // Instruct this model to update all its items' Qt::ItemIsDropEnabled flags in order to
77 // reflect if the item allows an "onto" drop of the given QMimeData*.
79
80 // Instructs the model to activate "select opaque" action,
81 // the selection action (of type SelectionAction) value
82 // is passed via QVariant as integer
84
85 // Returns a text explaining why the node has been excluded from
86 // projection rendering. If the node is not excluded, then empty
87 // string is returned
89
90 // Let's the model quickly determine whether a layer has any
91 // animated content attached to it.
93
94 // Returns a string with layer opacity and blending mode information;
95 // content depends on style setting.
97
98 // If the item is a filter mask that has a "color" property,
99 // returns that mask's color. Otherwise, returns a null variant.
101
102 // If the item is a filter mask, shows that mask's properties dialog.
104
105 // If the item is a layer that has a color overlay filter mask,
106 // returns that mask's color. Otherwise, returns a null variant.
108
109 // If the item is a layer that has a color overlay filter mask,
110 // shows that mask's properties dialog.
112
114 ReservedRole = Qt::UserRole + 99,
115
122 BeginThumbnailRole
123 };
124
125public: // from QAbstractItemModel
126
127 explicit KisNodeModel(QObject * parent, int clonedColumns = 0);
128 ~KisNodeModel() override;
129
130 void setDummiesFacade(KisDummiesFacadeBase *dummiesFacade,
131 KisImageWSP image,
132 KisShapeController *shapeController,
133 KisSelectionActionsAdapter *selectionActionsAdapter,
134 KisNodeManager *nodeManager);
135 void setIdleTaskManager(KisIdleTasksManager *idleTasksManager);
136 KisNodeSP nodeFromIndex(const QModelIndex &index) const;
137 QModelIndex indexFromNode(KisNodeSP node) const;
138
139 bool showGlobalSelection() const;
140 void setPreferredThumnalSize(int preferredSize) const;
141
142public Q_SLOTS:
143 void setShowGlobalSelection(bool value);
144
145public:
146
147 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
148 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
149 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
150 QModelIndex parent(const QModelIndex &index) const override;
151 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
152 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
153 Qt::ItemFlags flags(const QModelIndex &index) const override;
154 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
155 QStringList mimeTypes() const override;
156 QMimeData* mimeData(const QModelIndexList & indexes) const override;
157 bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) override;
158 bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
159 Qt::DropActions supportedDragActions() const override;
160 Qt::DropActions supportedDropActions() const override;
161 bool hasDummiesFacade();
162
163 static bool belongsToIsolatedGroup(KisImageSP image, KisNodeSP node, KisDummiesFacadeBase *dummiesFacade);
164
165Q_SIGNALS:
166
168 void sigBeforeBeginRemoveRows(const QModelIndex &parent, int start, int end);
169
170protected Q_SLOTS:
171 void slotBeginInsertDummy(KisNodeDummy *parent, int index, const QString &metaObjectType);
172 void slotEndInsertDummy(KisNodeDummy *dummy);
173 void slotBeginRemoveDummy(KisNodeDummy *dummy);
174 void slotEndRemoveDummy();
175 void slotDummyChanged(KisNodeDummy *dummy);
176
177 void slotIsolatedModeChanged();
178
179 void slotNodeDisplayModeChanged(bool showRootNode, bool showGlobalSelectionMask);
180
181 void processUpdateQueue();
182 void progressPercentageChanged(int, const KisNodeSP);
183
184 void slotLayerThumbnailUpdated(KisNodeSP node);
185
186protected:
187 virtual KisModelIndexConverterBase *createIndexConverter();
188 KisModelIndexConverterBase *indexConverter() const;
189 KisDummiesFacadeBase *dummiesFacade() const;
190
191private:
194
195 void connectDummy(KisNodeDummy *dummy, bool needConnect);
196 void connectDummies(KisNodeDummy *dummy, bool needConnect);
197
198 void resetIndexConverter();
199
200 void regenerateItems(KisNodeDummy *dummy);
201 bool belongsToIsolatedGroup(KisNodeSP node) const;
202
203 void setDropEnabled(const QMimeData *data);
204 void updateDropEnabled(const QList<KisNodeSP> &nodes, QModelIndex parent = QModelIndex());
205
206private:
207
208 struct Private;
209 Private * const m_d;
210};
211
212#endif
float value(const T *src, size_t ch)
ItemDataRole
Extensions to Qt::ItemDataRole.
@ LayerColorOverlayPropertiesRole
@ ProgressRole
Use to communicate a progress report to the section delegate on an action (a value of -1 or a QVarian...
@ PropertiesRole
A list of properties the part has.
@ AspectRatioRole
The aspect ratio of the section as a floating point value: width divided by height.
void toggleIsolateActiveNode()
Private *const m_d
void sigBeforeBeginRemoveRows(const QModelIndex &parent, int start, int end)