@@ -135,6 +135,8 void peripheralWidget::keyPressEvent(QKe | |||
|
135 | 135 | break; |
|
136 | 136 | case Qt::Key_W: |
|
137 | 137 | emit writeRegSig(registersWdgts.at(selectedReg)->address(),registersWdgts.at(selectedReg)->value()); |
|
138 | registersWdgts.at(selectedReg)->setUpdated(true); | |
|
139 | registersWdgts.at(selectedReg)->repaint(); | |
|
138 | 140 | break; |
|
139 | 141 | case Qt::Key_R: |
|
140 | 142 | qint32 value; |
@@ -171,6 +173,16 void peripheralWidget::keyPressEvent(QKe | |||
|
171 | 173 | case Qt::Key_Down: |
|
172 | 174 | down(); |
|
173 | 175 | break; |
|
176 | case Qt::Key_W: | |
|
177 | emit writeRegSig(registersWdgts.at(selectedReg)->address(),registersWdgts.at(selectedReg)->value()); | |
|
178 | registersWdgts.at(selectedReg)->setUpdated(true); | |
|
179 | registersWdgts.at(selectedReg)->repaint(); | |
|
180 | break; | |
|
181 | case Qt::Key_R: | |
|
182 | qint32 value; | |
|
183 | value = emit readRegSig(registersWdgts.at(selectedReg)->address()); | |
|
184 | registersWdgts.at(selectedReg)->setValue(value); | |
|
185 | break; | |
|
174 | 186 | default: |
|
175 | 187 | break; |
|
176 | 188 | } |
@@ -132,10 +132,11 QString registerWidget::bitFieldToBin(in | |||
|
132 | 132 | return QString("Out of range"); |
|
133 | 133 | } |
|
134 | 134 | |
|
135 | void registerWidget::setValue(qint32 value) | |
|
135 | void registerWidget::setValue(qint32 value, bool updated) | |
|
136 | 136 | { |
|
137 | 137 | this->p_value = value; |
|
138 | 138 | this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0")); |
|
139 | this->p_fieldsEl->setUpdated(updated); | |
|
139 | 140 | emit this->repaint(); |
|
140 | 141 | } |
|
141 | 142 | |
@@ -169,16 +170,25 void registerWidget::leave() | |||
|
169 | 170 | |
|
170 | 171 | void registerWidget::clear(int index) |
|
171 | 172 | { |
|
172 | p_value &= ~(1<<index); | |
|
173 | this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0")); | |
|
174 | emit this->repaint(); | |
|
173 | if(!this->p_fieldsEl->readonly(index)) | |
|
174 | { | |
|
175 | qint32 old = p_value; | |
|
176 | p_value &= ~(1<<index); | |
|
177 | if(old!=p_value) | |
|
178 | p_fieldsEl->setUpdated(false); | |
|
179 | this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0")); | |
|
180 | emit this->repaint(); | |
|
181 | } | |
|
175 | 182 | } |
|
176 | 183 | |
|
177 | 184 | void registerWidget::set(int index) |
|
178 | 185 | { |
|
179 | 186 | if(!this->p_fieldsEl->readonly(index)) |
|
180 | 187 | { |
|
188 | qint32 old = p_value; | |
|
181 | 189 | p_value |= 1<<index; |
|
190 | if(old!=p_value) | |
|
191 | p_fieldsEl->setUpdated(false); | |
|
182 | 192 | this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0")); |
|
183 | 193 | emit this->repaint(); |
|
184 | 194 | } |
@@ -206,7 +216,9 bitfieldsElement::bitfieldsElement(const | |||
|
206 | 216 | p_dx=QFontMetrics(p_font).width("0")+4; |
|
207 | 217 | p_blinkTextBgColor = QColor(Qt::black); |
|
208 | 218 | p_blinkTextColor = QColor(Qt::white); |
|
219 | p_outdated = QColor(Qt::red); | |
|
209 | 220 | p_cursorBlinkEnable = false; |
|
221 | p_changed = false; | |
|
210 | 222 | updateBoundingRect(); |
|
211 | 223 | } |
|
212 | 224 | |
@@ -263,7 +275,13 QPoint bitfieldsElement::paint(QPainter | |||
|
263 | 275 | painter->drawLine(xpos+(p_xMargins/2),p_boundingRec.height()-6,xpos+(p_xMargins/2),p_boundingRec.height()+6); |
|
264 | 276 | xpos+=p_xMargins; |
|
265 | 277 | } |
|
278 | QPen svg = painter->pen(); | |
|
279 | if(p_changed) | |
|
280 | { | |
|
281 | painter->setPen(p_outdated); | |
|
282 | } | |
|
266 | 283 | painter->drawRect(0,0,p_boundingRec.width(),p_boundingRec.height()); |
|
284 | painter->setPen(svg); | |
|
267 | 285 | return QPoint(p_boundingRec.width()+4+p_xMargins,0); |
|
268 | 286 | } |
|
269 | 287 |
@@ -137,6 +137,10 public: | |||
|
137 | 137 | } |
|
138 | 138 | return QString(""); |
|
139 | 139 | } |
|
140 | void setUpdated(bool updated=true) | |
|
141 | { | |
|
142 | this->p_changed = !updated; | |
|
143 | } | |
|
140 | 144 | private: |
|
141 | 145 | uint p_valueUint(int index) |
|
142 | 146 | { |
@@ -170,9 +174,10 private: | |||
|
170 | 174 | uint p_startSelectionIndex; |
|
171 | 175 | uint p_stopSelectionIndex; |
|
172 | 176 | bool p_cursorBlinkEnable; |
|
177 | bool p_changed; | |
|
173 | 178 | int p_dx; |
|
174 | 179 | QList<bitFieldAttribute*> attributesLUT; |
|
175 | QColor p_blinkTextColor,p_blinkTextBgColor; | |
|
180 | QColor p_blinkTextColor,p_blinkTextBgColor,p_outdated; | |
|
176 | 181 | |
|
177 | 182 | }; |
|
178 | 183 | |
@@ -197,6 +202,10 public: | |||
|
197 | 202 | QString bitFieldToHex(int bitIndex); |
|
198 | 203 | QString bitFieldToDec(int bitIndex); |
|
199 | 204 | QString bitFieldToBin(int bitIndex); |
|
205 | void setUpdated(bool updated=true) | |
|
206 | { | |
|
207 | this->p_fieldsEl->setUpdated(updated); | |
|
208 | } | |
|
200 | 209 | signals: |
|
201 | 210 | void cursorUp(int pos); |
|
202 | 211 | void cursorDown(int pos); |
@@ -204,7 +213,7 signals: | |||
|
204 | 213 | void repaint(); |
|
205 | 214 | |
|
206 | 215 | public slots: |
|
207 | void setValue(qint32 value); | |
|
216 | void setValue(qint32 value,bool updated=true); | |
|
208 | 217 | void blinkCursor(); |
|
209 | 218 | void moveCursorLeft(int count); |
|
210 | 219 | void moveCursorRight(int count); |
General Comments 0
You need to be logged in to leave comments.
Login now