| 31 | } |
| 32 | |
| 33 | QVariant StructDetailModel::data(const QModelIndex& index, int role) const |
| 34 | { |
| 35 | if (!index.isValid()) |
| 36 | return {}; |
| 37 | |
| 38 | if (role == Qt::DisplayRole) |
| 39 | { |
| 40 | switch (index.column()) |
| 41 | { |
| 42 | case STRUCT_COL_OFFSET: |
| 43 | return QString("0x%1").arg(m_fields[index.row()]->getOffset(), 0, 16); |
| 44 | case STRUCT_COL_SIZE: |
| 45 | return m_fields[index.row()]->getFieldSize(); |
| 46 | case STRUCT_COL_LABEL: |
| 47 | if (m_fields[index.row()]->isPadding()) |
| 48 | return QString("-- Padding --"); |
| 49 | return m_fields[index.row()]->getEntry()->getLabel(); |
| 50 | case STRUCT_COL_TYPE: |
| 51 | { |
| 52 | return getFieldDetails(m_fields[index.row()]); |
| 53 | } |
| 54 | |
| 55 | default: |
| 56 | break; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if (role == Qt::EditRole && index.column() == STRUCT_COL_LABEL) |
| 61 | if (!m_fields[index.row()]->isPadding()) |
| 62 | return m_fields[index.row()]->getEntry()->getLabel(); |
| 63 | |
| 64 | return {}; |
| 65 | } |
| 66 | |
| 67 | bool StructDetailModel::setData(const QModelIndex& index, const QVariant& value, int role) |
| 68 | { |
no test coverage detected