aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_bsplugins/src/GUI/GenericIconDelegate.cpp
blob: 9e5f31c37e31f9bd0ff40ab72e5631de3362b194 (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
#include "GenericIconDelegate.h"

namespace GUI
{

GenericIconDelegate::GenericIconDelegate(QTreeView* parent, int role, int logicalIndex,
                                         int compactSize)
    : IconDelegate(parent, logicalIndex, compactSize), m_Role{role}
{}

QList<QString> GenericIconDelegate::getIcons(const QModelIndex& index) const
{
  QList<QString> result;
  if (index.isValid()) {
    for (const QVariant& var : index.data(m_Role).toList()) {
      if (!compact() || !var.toString().isEmpty()) {
        result.append(var.toString());
      }
    }
  }
  return result;
}

int GenericIconDelegate::getNumIcons(const QModelIndex& index) const
{
  return index.data(m_Role).toList().count();
}

}  // namespace GUI