# HG changeset patch # User jeandet # Date 2014-01-25 22:00:17 # Node ID 9180c6ebb055b7702a48a7cef9b027fd61cae89c # Parent 8ee59f35313b9a77468a9d0e5aef7190db3439d7 added outdated marker for registers diff --git a/src/peripheralwidget.cpp b/src/peripheralwidget.cpp --- a/src/peripheralwidget.cpp +++ b/src/peripheralwidget.cpp @@ -135,6 +135,8 @@ void peripheralWidget::keyPressEvent(QKe break; case Qt::Key_W: emit writeRegSig(registersWdgts.at(selectedReg)->address(),registersWdgts.at(selectedReg)->value()); + registersWdgts.at(selectedReg)->setUpdated(true); + registersWdgts.at(selectedReg)->repaint(); break; case Qt::Key_R: qint32 value; @@ -171,6 +173,16 @@ void peripheralWidget::keyPressEvent(QKe case Qt::Key_Down: down(); break; + case Qt::Key_W: + emit writeRegSig(registersWdgts.at(selectedReg)->address(),registersWdgts.at(selectedReg)->value()); + registersWdgts.at(selectedReg)->setUpdated(true); + registersWdgts.at(selectedReg)->repaint(); + break; + case Qt::Key_R: + qint32 value; + value = emit readRegSig(registersWdgts.at(selectedReg)->address()); + registersWdgts.at(selectedReg)->setValue(value); + break; default: break; } diff --git a/src/registerwidget.cpp b/src/registerwidget.cpp --- a/src/registerwidget.cpp +++ b/src/registerwidget.cpp @@ -132,10 +132,11 @@ QString registerWidget::bitFieldToBin(in return QString("Out of range"); } -void registerWidget::setValue(qint32 value) +void registerWidget::setValue(qint32 value, bool updated) { this->p_value = value; this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0")); + this->p_fieldsEl->setUpdated(updated); emit this->repaint(); } @@ -169,16 +170,25 @@ void registerWidget::leave() void registerWidget::clear(int index) { - p_value &= ~(1<p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0")); - emit this->repaint(); + if(!this->p_fieldsEl->readonly(index)) + { + qint32 old = p_value; + p_value &= ~(1<setUpdated(false); + this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0")); + emit this->repaint(); + } } void registerWidget::set(int index) { if(!this->p_fieldsEl->readonly(index)) { + qint32 old = p_value; p_value |= 1<setUpdated(false); this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0")); emit this->repaint(); } @@ -206,7 +216,9 @@ bitfieldsElement::bitfieldsElement(const p_dx=QFontMetrics(p_font).width("0")+4; p_blinkTextBgColor = QColor(Qt::black); p_blinkTextColor = QColor(Qt::white); + p_outdated = QColor(Qt::red); p_cursorBlinkEnable = false; + p_changed = false; updateBoundingRect(); } @@ -263,7 +275,13 @@ QPoint bitfieldsElement::paint(QPainter painter->drawLine(xpos+(p_xMargins/2),p_boundingRec.height()-6,xpos+(p_xMargins/2),p_boundingRec.height()+6); xpos+=p_xMargins; } + QPen svg = painter->pen(); + if(p_changed) + { + painter->setPen(p_outdated); + } painter->drawRect(0,0,p_boundingRec.width(),p_boundingRec.height()); + painter->setPen(svg); return QPoint(p_boundingRec.width()+4+p_xMargins,0); } diff --git a/src/registerwidget.h b/src/registerwidget.h --- a/src/registerwidget.h +++ b/src/registerwidget.h @@ -137,6 +137,10 @@ public: } return QString(""); } + void setUpdated(bool updated=true) + { + this->p_changed = !updated; + } private: uint p_valueUint(int index) { @@ -170,9 +174,10 @@ private: uint p_startSelectionIndex; uint p_stopSelectionIndex; bool p_cursorBlinkEnable; + bool p_changed; int p_dx; QList attributesLUT; - QColor p_blinkTextColor,p_blinkTextBgColor; + QColor p_blinkTextColor,p_blinkTextBgColor,p_outdated; }; @@ -197,6 +202,10 @@ public: QString bitFieldToHex(int bitIndex); QString bitFieldToDec(int bitIndex); QString bitFieldToBin(int bitIndex); + void setUpdated(bool updated=true) + { + this->p_fieldsEl->setUpdated(updated); + } signals: void cursorUp(int pos); void cursorDown(int pos); @@ -204,7 +213,7 @@ signals: void repaint(); public slots: - void setValue(qint32 value); + void setValue(qint32 value,bool updated=true); void blinkCursor(); void moveCursorLeft(int count); void moveCursorRight(int count);