File indexing completed on 2024-05-26 04:05:28

0001 /*
0002     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0003     SPDX-FileCopyrightText: 2023 David Redondo <kde@david-redondo.de>
0004 */
0005 
0006 #ifndef ITEMBRANCHINDICATORS_H
0007 #define ITEMBRANCHINDICATORS_H
0008 
0009 #include <QModelIndex>
0010 #include <QPalette>
0011 #include <QQuickPaintedItem>
0012 
0013 class ItemBranchIndicators : public QQuickPaintedItem
0014 {
0015     Q_OBJECT
0016     QML_ELEMENT
0017     Q_PROPERTY(QModelIndex modelIndex MEMBER m_index WRITE setModelIndex NOTIFY modelIndexChanged)
0018     Q_PROPERTY(QModelIndex rootIndex MEMBER m_rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
0019     Q_PROPERTY(bool selected MEMBER m_selected WRITE setSelected NOTIFY selectedChanged)
0020 public:
0021     explicit ItemBranchIndicators(QQuickItem *parent = nullptr);
0022     void setModelIndex(const QModelIndex &index);
0023     void setRootIndex(const QModelIndex &index);
0024     void setSelected(bool selected);
0025     void paint(QPainter *painter) override;
0026 
0027 Q_SIGNALS:
0028     void modelIndexChanged();
0029     void rootIndexChanged();
0030     void selectedChanged();
0031 
0032 private:
0033     void updateParentChain();
0034 
0035     std::vector<QModelIndex> parentChain;
0036     QModelIndex m_index;
0037     QModelIndex m_rootIndex;
0038     bool m_selected;
0039     QPalette m_palette;
0040 };
0041 
0042 #endif