QVariant RegisterEditItem::data(int column, int role) const { switch (role) { case Qt::DisplayRole: case Qt::EditRole: switch (column) { case RegisterNameColumn: { return QString("[%1]").arg(m_index); } case RegisterValueColumn: { RegisterValue value = parent()->parent()->m_reg.value; return value.subValue(m_subSize, m_index) .toString(m_subKind, m_subSize, m_subFormat, role == Qt::EditRole); } } break; case Qt::ToolTipRole: { RegisterItem *registerItem = parent()->parent(); return RegisterHandler::tr("Edit bits %1...%2 of register %3") .arg(m_index * 8).arg(m_index * 8 + 7).arg(registerItem->m_reg.name); } default: break; } return QVariant(); }
QVariant RegisterSubItem::data(int column, int role) const { switch (role) { case RegisterChangedRole: return m_changed; case RegisterNumberBaseRole: return 16; case RegisterAsAddressRole: return 0; case Qt::DisplayRole: switch (column) { case 0: return subTypeName(m_subKind, m_subSize); case 1: { QTC_ASSERT(parent(), return QVariant()); RegisterItem *registerItem = static_cast<RegisterItem *>(parent()); RegisterValue value = registerItem->m_reg.value; QByteArray ba; for (int i = 0; i != m_count; ++i) { ba += value.subValue(m_subSize, i).toByteArray(16, m_subKind, m_subSize); int tab = 5 * (i + 1) * m_subSize; ba += QByteArray(tab - ba.size(), ' '); } return ba; } } default: break; } return QVariant(); }
QVariant RegisterSubItem::data(int column, int role) const { switch (role) { case RegisterChangedRole: return m_changed; case RegisterFormatRole: { RegisterItem *registerItem = static_cast<RegisterItem *>(parent()); return int(registerItem->m_format); } case RegisterAsAddressRole: return 0; case Qt::DisplayRole: switch (column) { case RegisterNameColumn: return subTypeName(m_subKind, m_subSize, m_subFormat); case RegisterValueColumn: { QTC_ASSERT(parent(), return QVariant()); RegisterItem *registerItem = static_cast<RegisterItem *>(parent()); RegisterValue value = registerItem->m_reg.value; QString ba; for (int i = 0; i != m_count; ++i) { int tab = 5 * (i + 1) * m_subSize; QString b = value.subValue(m_subSize, i).toString(m_subKind, m_subSize, m_subFormat); ba += QString(tab - ba.size() - b.size(), ' '); ba += b; } return ba; } } case Qt::ToolTipRole: if (m_subKind == IntegerRegister) { if (m_subFormat == CharacterFormat) return RegisterHandler::tr("Content as ASCII Characters"); if (m_subFormat == SignedDecimalFormat) return RegisterHandler::tr("Content as %1-bit Signed Decimal Values").arg(8 * m_subSize); if (m_subFormat == DecimalFormat) return RegisterHandler::tr("Content as %1-bit Unsigned Decimal Values").arg(8 * m_subSize); if (m_subFormat == HexadecimalFormat) return RegisterHandler::tr("Content as %1-bit Hexadecimal Values").arg(8 * m_subSize); if (m_subFormat == OctalFormat) return RegisterHandler::tr("Content as %1-bit Octal Values").arg(8 * m_subSize); if (m_subFormat == BinaryFormat) return RegisterHandler::tr("Content as %1-bit Binary Values").arg(8 * m_subSize); } if (m_subKind == FloatRegister) return RegisterHandler::tr("Content as %1-bit Floating Point Values").arg(8 * m_subSize); default: break; } return QVariant(); }