diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-10-22 17:59:57 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-12-15 22:54:28 +0100 |
commit | abed208efbba78b502c94408b0c9b97c8ab61e14 (patch) | |
tree | ccc7c8c575f7b3f45aeb7f9a978755f172a70590 /utils/regtools/qeditor/utils.h | |
parent | edaeee168df5137c451ce777df431633287bad0a (diff) | |
download | rockbox-abed208efbba78b502c94408b0c9b97c8ab61e14.tar.gz rockbox-abed208efbba78b502c94408b0c9b97c8ab61e14.zip |
regtools/qeditor: introduce custom table model for reg fields
This one is much more efficient than using a generic table widget.
Change-Id: I3578964eead746e656f6b0a8dcec0f8442deb13d
Reviewed-on: http://gerrit.rockbox.org/1022
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'utils/regtools/qeditor/utils.h')
-rw-r--r-- | utils/regtools/qeditor/utils.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/utils/regtools/qeditor/utils.h b/utils/regtools/qeditor/utils.h index 771b671b2c..da9638baf7 100644 --- a/utils/regtools/qeditor/utils.h +++ b/utils/regtools/qeditor/utils.h | |||
@@ -201,6 +201,72 @@ public: | |||
201 | protected: | 201 | protected: |
202 | }; | 202 | }; |
203 | 203 | ||
204 | struct RegThemeGroup | ||
205 | { | ||
206 | QBrush foreground; | ||
207 | QBrush background; | ||
208 | QFont font; | ||
209 | }; | ||
210 | |||
211 | struct RegTheme | ||
212 | { | ||
213 | RegTheme():valid(false) {} | ||
214 | bool valid; | ||
215 | RegThemeGroup normal; | ||
216 | RegThemeGroup diff; | ||
217 | RegThemeGroup error; | ||
218 | }; | ||
219 | |||
220 | class RegFieldTableModel : public QAbstractTableModel | ||
221 | { | ||
222 | Q_OBJECT | ||
223 | public: | ||
224 | RegFieldTableModel(QObject *parent); | ||
225 | virtual int rowCount(const QModelIndex & parent = QModelIndex()) const; | ||
226 | virtual int columnCount(const QModelIndex & parent = QModelIndex()) const; | ||
227 | virtual QVariant data(const QModelIndex & index, int role) const; | ||
228 | virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; | ||
229 | virtual Qt::ItemFlags flags (const QModelIndex & index) const; | ||
230 | virtual bool setData(const QModelIndex& index, const QVariant& value, int role); | ||
231 | |||
232 | void SetRegister(const soc_reg_t& reg); | ||
233 | /* values can either be an invalid QVariant() (means no value/error), or a | ||
234 | * QVariant containing a soc_word_t */ | ||
235 | void SetValues(const QVector< QVariant >& values); | ||
236 | QVariant GetValue(int index); | ||
237 | void SetTheme(const RegTheme& theme); | ||
238 | void SetReadOnly(bool en); | ||
239 | |||
240 | signals: | ||
241 | void OnValueModified(int index); | ||
242 | |||
243 | protected: | ||
244 | void RecomputeTheme(); | ||
245 | |||
246 | enum | ||
247 | { | ||
248 | BitRangeColumn = 0, | ||
249 | NameColumn, | ||
250 | FirstValueColumn, | ||
251 | DescColumnOffset = FirstValueColumn, /* offset from nr_values */ | ||
252 | ColumnCountOffset, /* offset from nr_values */ | ||
253 | }; | ||
254 | |||
255 | enum ColorStatus | ||
256 | { | ||
257 | None, | ||
258 | Normal, | ||
259 | Diff, | ||
260 | Error | ||
261 | }; | ||
262 | |||
263 | soc_reg_t m_reg; | ||
264 | QVector< QVariant > m_value; | ||
265 | QVector< ColorStatus > m_status; | ||
266 | RegTheme m_theme; | ||
267 | bool m_read_only; | ||
268 | }; | ||
269 | |||
204 | class RegSexyDisplay : public QWidget | 270 | class RegSexyDisplay : public QWidget |
205 | { | 271 | { |
206 | Q_OBJECT | 272 | Q_OBJECT |