Skip to content
Snippets Groups Projects
Commit 1173b0f6 authored by hjk's avatar hjk
Browse files

debugger: fix color of changed register values.

Was broken since 1e7cee62.
parent 377ed944
No related branches found
No related tags found
No related merge requests found
...@@ -67,8 +67,6 @@ int RegisterHandler::columnCount(const QModelIndex &parent) const ...@@ -67,8 +67,6 @@ int RegisterHandler::columnCount(const QModelIndex &parent) const
QVariant RegisterHandler::data(const QModelIndex &index, int role) const QVariant RegisterHandler::data(const QModelIndex &index, int role) const
{ {
static const QVariant red = QColor(200, 0, 0);
if (role == RegisterNumberBaseRole) if (role == RegisterNumberBaseRole)
return m_base; return m_base;
...@@ -78,7 +76,7 @@ QVariant RegisterHandler::data(const QModelIndex &index, int role) const ...@@ -78,7 +76,7 @@ QVariant RegisterHandler::data(const QModelIndex &index, int role) const
const Register &reg = m_registers.at(index.row()); const Register &reg = m_registers.at(index.row());
if (role == RegisterAddressRole) { if (role == RegisterAddressRole) {
// return some address associated with the register // Return some address associated with the register.
bool ok = true; bool ok = true;
qulonglong value = reg.value.toULongLong(&ok, 0); qulonglong value = reg.value.toULongLong(&ok, 0);
return ok ? QString::fromLatin1("0x") + QString::number(value, 16) : QVariant(); return ok ? QString::fromLatin1("0x") + QString::number(value, 16) : QVariant();
...@@ -100,8 +98,8 @@ QVariant RegisterHandler::data(const QModelIndex &index, int role) const ...@@ -100,8 +98,8 @@ QVariant RegisterHandler::data(const QModelIndex &index, int role) const
if (role == Qt::TextAlignmentRole && index.column() == 1) if (role == Qt::TextAlignmentRole && index.column() == 1)
return Qt::AlignRight; return Qt::AlignRight;
if (role == Qt::TextColorRole && reg.changed && index.column() == 1) if (role == RegisterChangedRole)
return red; return reg.changed;
return QVariant(); return QVariant();
} }
......
...@@ -38,7 +38,8 @@ namespace Internal { ...@@ -38,7 +38,8 @@ namespace Internal {
enum RegisterRole enum RegisterRole
{ {
RegisterNumberBaseRole = Qt::UserRole, // Currently used number base RegisterNumberBaseRole = Qt::UserRole, // Currently used number base
RegisterAddressRole // Start value for opening memory view RegisterAddressRole, // Start value for opening memory view
RegisterChangedRole // Used for painting changed values
}; };
class Register class Register
......
...@@ -105,6 +105,10 @@ public: ...@@ -105,6 +105,10 @@ public:
const QModelIndex &index) const const QModelIndex &index) const
{ {
if (index.column() == 1) { if (index.column() == 1) {
bool paintRed = index.data(RegisterChangedRole).toBool();
QPen oldPen = painter->pen();
if (paintRed)
painter->setPen(QColor(200, 0, 0));
// FIXME: performance? this changes only on real font changes. // FIXME: performance? this changes only on real font changes.
QFontMetrics fm(option.font); QFontMetrics fm(option.font);
int charWidth = fm.width(QLatin1Char('x')); int charWidth = fm.width(QLatin1Char('x'));
...@@ -112,7 +116,7 @@ public: ...@@ -112,7 +116,7 @@ public:
charWidth = qMax(charWidth, fm.width(QLatin1Char(i))); charWidth = qMax(charWidth, fm.width(QLatin1Char(i)));
for (int i = 'a'; i <= 'f'; ++i) for (int i = 'a'; i <= 'f'; ++i)
charWidth = qMax(charWidth, fm.width(QLatin1Char(i))); charWidth = qMax(charWidth, fm.width(QLatin1Char(i)));
QString str = index.model()->data(index, Qt::DisplayRole).toString(); QString str = index.data(Qt::DisplayRole).toString();
int x = option.rect.x(); int x = option.rect.x();
for (int i = 0; i < str.size(); ++i) { for (int i = 0; i < str.size(); ++i) {
QRect r = option.rect; QRect r = option.rect;
...@@ -121,6 +125,8 @@ public: ...@@ -121,6 +125,8 @@ public:
x += charWidth; x += charWidth;
painter->drawText(r, Qt::AlignHCenter, QString(str.at(i))); painter->drawText(r, Qt::AlignHCenter, QString(str.at(i)));
} }
if (paintRed)
painter->setPen(oldPen);
} else { } else {
QItemDelegate::paint(painter, option, index); QItemDelegate::paint(painter, option, index);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment