File indexing completed on 2024-05-12 16:01:33

0001 /*
0002  *  SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KIS_MODEL_INDEX_CONVERTER_H
0008 #define __KIS_MODEL_INDEX_CONVERTER_H
0009 
0010 #include "kis_model_index_converter_base.h"
0011 
0012 class KisDummiesFacadeBase;
0013 class KisNodeModel;
0014 
0015 
0016 /**
0017  * The class for converting to/from QModelIndex and KisNodeDummy when
0018  * the root node is *hidden* (ShowRootLayer == *false*). All the selection
0019  * masks owned by the root layer are hidden as well.
0020  */
0021 
0022 class KRITAUI_EXPORT KisModelIndexConverter : public KisModelIndexConverterBase
0023 {
0024 public:
0025     KisModelIndexConverter(KisDummiesFacadeBase *dummiesFacade,
0026                            KisNodeModel *model,
0027                            bool showGlobalSelection);
0028 
0029     KisNodeDummy* dummyFromRow(int row, QModelIndex parent) override;
0030     KisNodeDummy* dummyFromIndex(QModelIndex index) override;
0031 
0032     QModelIndex indexFromDummy(KisNodeDummy *dummy) override;
0033     bool indexFromAddedDummy(KisNodeDummy *parentDummy, int index,
0034                              const QString &newNodeMetaObjectType,
0035                              QModelIndex &parentIndex, int &row) override;
0036 
0037     int rowCount(QModelIndex parent) override;
0038 
0039 private:
0040     inline bool checkDummyType(KisNodeDummy *dummy);
0041     inline bool checkDummyMetaObjectType(const QString &type);
0042 
0043 private:
0044     KisDummiesFacadeBase *m_dummiesFacade;
0045     KisNodeModel *m_model;
0046     bool m_showGlobalSelection;
0047 };
0048 
0049 #endif /* __KIS_MODEL_INDEX_CONVERTER_H */