| 75 | int rowCount(const QModelIndex&) const override { return static_cast<int>(items.size()); } |
| 76 | int columnCount(const QModelIndex&) const override { return 2; } |
| 77 | QVariant data(const QModelIndex& index, int role) const override |
| 78 | { |
| 79 | switch (role) { |
| 80 | case Qt::DisplayRole: |
| 81 | if (index.column() == 0) { |
| 82 | auto pos { items[index.row()]->boundingRect().center() }; |
| 83 | return QString("X = %1\nY = %2").arg(pos.x()).arg(pos.y()); |
| 84 | } |
| 85 | return items[index.row()]->area(); |
| 86 | case Qt::UserRole: |
| 87 | return QVariant::fromValue(items[index.row()]); |
| 88 | case Qt::DecorationRole: |
| 89 | if (index.column() == 0) |
| 90 | return errorIcon(items[index.row()]->shape()); |
| 91 | return {}; |
| 92 | case Qt::TextAlignmentRole: |
| 93 | if (index.column() == 0) |
| 94 | return Qt::AlignVCenter; |
| 95 | return Qt::AlignCenter; |
| 96 | default: |
| 97 | break; |
| 98 | } |
| 99 | return {}; |
| 100 | } |
| 101 | |
| 102 | QVariant headerData(int section, Qt::Orientation orientation, int role) const override |
| 103 | { |
no test coverage detected