From 88053b88325318a2769086438ce4740c5bb7a7aa Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Wed, 22 Oct 2014 17:56:13 +0200 Subject: regtools/qeditor: fix field editor not updating the validator on change Change-Id: Ib8df47c8b7cfe0beb486e45542e3fcc9187bcc54 Reviewed-on: http://gerrit.rockbox.org/1020 Reviewed-by: Amaury Pouly --- utils/regtools/qeditor/qeditor.pro | 2 +- utils/regtools/qeditor/utils.cpp | 20 ++++++++++++++++++++ utils/regtools/qeditor/utils.h | 8 +++++--- 3 files changed, 26 insertions(+), 4 deletions(-) (limited to 'utils/regtools') diff --git a/utils/regtools/qeditor/qeditor.pro b/utils/regtools/qeditor/qeditor.pro index 78a984bbce..771b60b61c 100644 --- a/utils/regtools/qeditor/qeditor.pro +++ b/utils/regtools/qeditor/qeditor.pro @@ -7,7 +7,7 @@ SOURCES += main.cpp mainwindow.cpp regtab.cpp backend.cpp analyser.cpp \ LIBS += -L../lib/ -lsocdesc -lxml2 INCLUDEPATH += ../lib/ ../../hwstub/lib -VERSION = 2.0.2 +VERSION = 2.0.3 DEFINES += APP_VERSION=\\\"$$VERSION\\\" diff --git a/utils/regtools/qeditor/utils.cpp b/utils/regtools/qeditor/utils.cpp index effd79e0f6..1e39903a2c 100644 --- a/utils/regtools/qeditor/utils.cpp +++ b/utils/regtools/qeditor/utils.cpp @@ -340,6 +340,26 @@ void SocFieldEditor::setField(uint field) setText(QString("0x%1").arg(field, digits, 16, QChar('0'))); } +void SocFieldEditor::SetRegField(const soc_reg_field_t& field) +{ + setValidator(0); + delete m_validator; + m_validator = new SocFieldValidator(field); + setValidator(m_validator); + m_reg_field = field; +} + +/** + * SocFieldCachedValue + */ +SocFieldCachedValue::SocFieldCachedValue(const soc_reg_field_t& field, uint value) + :m_field(field), m_value(value) +{ + int idx = field.find_value(value); + if(idx != -1) + m_name = QString::fromStdString(field.value[idx].name); +} + /** * SocFieldCachedItemDelegate */ diff --git a/utils/regtools/qeditor/utils.h b/utils/regtools/qeditor/utils.h index 529e40bde1..13b9e896e9 100644 --- a/utils/regtools/qeditor/utils.h +++ b/utils/regtools/qeditor/utils.h @@ -129,7 +129,7 @@ public: uint field() const; void setField(uint field); - void SetRegField(const soc_reg_field_t& field) { m_reg_field = field; } + void SetRegField(const soc_reg_field_t& field); protected: SocFieldValidator *m_validator; @@ -154,14 +154,16 @@ class SocFieldCachedValue { public: SocFieldCachedValue():m_value(0) {} - SocFieldCachedValue(const soc_reg_field_t& field, uint value) - :m_field(field), m_value(value) {} + SocFieldCachedValue(const soc_reg_field_t& field, uint value); virtual ~SocFieldCachedValue() {} const soc_reg_field_t& field() const { return m_field; } uint value() const { return m_value; } + /* return empty string if there no match */ + QString value_name() const { return m_name; } protected: soc_reg_field_t m_field; uint m_value; + QString m_name; }; Q_DECLARE_METATYPE(SocFieldCachedValue) -- cgit v1.2.3