aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_bsplugins/src/GUI/IconDelegate.h
blob: 057cd4e0605d5bec42fff4c5c9d8af7286b7cd9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef GUI_ICONDELEGATE_H
#define GUI_ICONDELEGATE_H

#include <QAbstractItemView>
#include <QAbstractProxyModel>
#include <QStyledItemDelegate>
#include <QTreeView>

namespace GUI
{

class IconDelegate : public QStyledItemDelegate
{
  Q_OBJECT

public:
  explicit IconDelegate(QTreeView* view, int column = -1, int compactSize = 100);

  void paint(QPainter* painter, const QStyleOptionViewItem& option,
             const QModelIndex& index) const override;

  QSize sizeHint(const QStyleOptionViewItem& option,
                 const QModelIndex& index) const override;

protected:
  // check if icons should be compacted or not
  //
  [[nodiscard]] bool compact() const { return m_Compact; }

  static void paintIcons(QPainter* painter, const QStyleOptionViewItem& option,
                         const QModelIndex& index, const QList<QString>& icons);

  [[nodiscard]] virtual QList<QString> getIcons(const QModelIndex& index) const = 0;
  [[nodiscard]] virtual int getNumIcons(const QModelIndex& index) const         = 0;

private:
  int m_Column;
  int m_CompactSize;
  bool m_Compact;
};

}  // namespace GUI

#endif  // GUI_ICONDELEGATE_H