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