From 7b590a953639714cf8ea4b550dd7f6558698e23f Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sun, 11 May 2014 19:51:55 +0200 Subject: qeditor: many enhancement Qeditor has been improved in many ways: - it can now dump all registers, just like the lua DUMPER.dump_all() command - several crash were fixed - when connected to a hwstub command, one can correctly edit individual fields - the code was simplified in several places Change-Id: I092b99ce3a12ff6417552de61d62c65f706bcff0 --- utils/regtools/qeditor/aux.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'utils/regtools/qeditor/aux.cpp') diff --git a/utils/regtools/qeditor/aux.cpp b/utils/regtools/qeditor/aux.cpp index 0614bb57f6..de45f6c438 100644 --- a/utils/regtools/qeditor/aux.cpp +++ b/utils/regtools/qeditor/aux.cpp @@ -320,6 +320,47 @@ void SocFieldEditor::setField(uint field) setText(QString("0x%1").arg(field, digits, 16, QChar('0'))); } +/** + * SocFieldCachedItemDelegate + */ + +QString SocFieldCachedItemDelegate::displayText(const QVariant& value, const QLocale& locale) const +{ + // FIXME see QTBUG-30392 + if(value.type() == QVariant::UserType && value.userType() == qMetaTypeId< SocFieldCachedValue >()) + { + const SocFieldCachedValue& v = value.value< SocFieldCachedValue >(); + int bitcount = v.field().last_bit - v.field().first_bit; + return QString("0x%1").arg(v.value(), (bitcount + 3) / 4, 16, QChar('0')); + } + else + return QStyledItemDelegate::displayText(value, locale); +} + +/** + * SocFieldCachedEditor + */ +SocFieldCachedEditor::SocFieldCachedEditor(QWidget *parent) + :SocFieldEditor(soc_reg_field_t(), parent) +{ +} + +SocFieldCachedEditor::~SocFieldCachedEditor() +{ +} + +SocFieldCachedValue SocFieldCachedEditor::value() const +{ + return SocFieldCachedValue(m_value.field(), field()); +} + +void SocFieldCachedEditor::setValue(SocFieldCachedValue val) +{ + m_value = val; + SetRegField(m_value.field()); + setField(m_value.value()); +} + /** * SocFieldEditorCreator */ @@ -333,6 +374,19 @@ QByteArray SocFieldEditorCreator::valuePropertyName() const return QByteArray("field"); } +/** + * SocFieldCachedEditorCreator + */ +QWidget *SocFieldCachedEditorCreator::createWidget(QWidget *parent) const +{ + return new SocFieldCachedEditor(parent); +} + +QByteArray SocFieldCachedEditorCreator::valuePropertyName() const +{ + return QByteArray("value"); +} + /** * RegSexyDisplay */ -- cgit v1.2.3