summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-12-18 10:58:17 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2015-09-10 15:20:38 +0200
commit2c832968c91cb56e4c252bd8eafb03d7d9c8aeda (patch)
tree8b6dd9e3e4688d4e5bbd7ed2dbbf52b62bd35deb /utils
parent983c8084c9a64e48b29fb1e826cc84c35d2c9849 (diff)
downloadrockbox-2c832968c91cb56e4c252bd8eafb03d7d9c8aeda.tar.gz
rockbox-2c832968c91cb56e4c252bd8eafb03d7d9c8aeda.tar.bz2
rockbox-2c832968c91cb56e4c252bd8eafb03d7d9c8aeda.zip
qeditor: use delegate to show bit range information
Change-Id: I314365c3a2cb9d230c412f24d2a8034a12c43444
Diffstat (limited to 'utils')
-rw-r--r--utils/regtools/qeditor/utils.cpp19
-rw-r--r--utils/regtools/qeditor/utils.h14
2 files changed, 25 insertions, 8 deletions
diff --git a/utils/regtools/qeditor/utils.cpp b/utils/regtools/qeditor/utils.cpp
index 5aef2414a4..4116dbcc81 100644
--- a/utils/regtools/qeditor/utils.cpp
+++ b/utils/regtools/qeditor/utils.cpp
@@ -388,6 +388,14 @@ QString SocFieldCachedItemDelegate::displayText(const QVariant& value, const QLo
return strval;
}
}
+ else if(value.type() == QVariant::UserType && value.userType() == qMetaTypeId< SocFieldBitRange >())
+ {
+ const SocFieldBitRange& br = value.value< SocFieldBitRange >();
+ if(br.GetFirstBit() == br.GetLastBit())
+ return QString("%1").arg(br.GetFirstBit());
+ else
+ return QString("%1:%2").arg(br.GetLastBit()).arg(br.GetFirstBit());
+ }
else
return QStyledItemDelegate::displayText(value, locale);
}
@@ -485,12 +493,7 @@ QVariant RegFieldTableModel::data(const QModelIndex& index, int role) const
if(section == BitRangeColumn)
{
if(role == Qt::DisplayRole)
- {
- if(field.first_bit == field.last_bit)
- return QVariant(QString("%1").arg(field.first_bit));
- else
- return QVariant(QString("%1:%2").arg(field.last_bit).arg(field.first_bit));
- }
+ return QVariant::fromValue(SocFieldBitRange(field));
else if(role == Qt::TextAlignmentRole)
return QVariant(Qt::AlignVCenter | Qt::AlignHCenter);
else
@@ -603,9 +606,9 @@ void RegFieldTableModel::SetReadOnly(bool en)
void RegFieldTableModel::SetRegister(const soc_reg_t& reg)
{
/* remove all rows */
- beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
+ beginResetModel();
m_reg.field.clear();
- endRemoveRows();
+ endResetModel();
/* add them all */
beginInsertRows(QModelIndex(), 0, reg.field.size() - 1);
m_reg = reg;
diff --git a/utils/regtools/qeditor/utils.h b/utils/regtools/qeditor/utils.h
index 27476dba61..c78b0a40e4 100644
--- a/utils/regtools/qeditor/utils.h
+++ b/utils/regtools/qeditor/utils.h
@@ -168,6 +168,20 @@ protected:
Q_DECLARE_METATYPE(SocFieldCachedValue)
+class SocFieldBitRange
+{
+public:
+ SocFieldBitRange():m_first_bit(0),m_last_bit(0) {}
+ SocFieldBitRange(const soc_reg_field_t& field)
+ :m_first_bit(field.first_bit), m_last_bit(field.last_bit) {}
+ unsigned GetFirstBit() const { return m_first_bit; }
+ unsigned GetLastBit() const { return m_last_bit; }
+protected:
+ unsigned m_first_bit, m_last_bit;
+};
+
+Q_DECLARE_METATYPE(SocFieldBitRange)
+
class SocFieldCachedItemDelegate : public QStyledItemDelegate
{
public: