| 40 | } |
| 41 | |
| 42 | QVariant StructSelectModel::data(const QModelIndex& index, int role) const |
| 43 | { |
| 44 | if (!index.isValid()) |
| 45 | return {}; |
| 46 | |
| 47 | StructTreeNode* item = static_cast<StructTreeNode*>(index.internalPointer()); |
| 48 | |
| 49 | if (!item->isGroup()) |
| 50 | { |
| 51 | if (role == Qt::DisplayRole || role == Qt::EditRole) |
| 52 | { |
| 53 | switch (index.column()) |
| 54 | { |
| 55 | case WATCH_COL_LABEL: |
| 56 | { |
| 57 | return item->getName(); |
| 58 | } |
| 59 | default: |
| 60 | break; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | if (index.column() == WATCH_COL_LABEL && (role == Qt::DisplayRole || role == Qt::EditRole)) |
| 67 | return item->getName(); |
| 68 | if (index.column() == WATCH_COL_LABEL && role == Qt::DecorationRole) |
| 69 | { |
| 70 | static const QIcon s_folderIcon(":/folder.svg"); |
| 71 | static const QIcon s_emptyFolderIcon(":/folder_empty.svg"); |
| 72 | return item->hasChildren() ? s_folderIcon : s_emptyFolderIcon; |
| 73 | } |
| 74 | } |
| 75 | return {}; |
| 76 | } |
| 77 | |
| 78 | QModelIndex StructSelectModel::index(int row, int column, const QModelIndex& parent) const |
| 79 | { |
no test coverage detected