##// END OF EJS Templates
Sync
Jeandet Alexis -
r7:cfbbc6302d85 default
parent child
Show More
@@ -53,7 +53,16 void peripheralWidget::mousePressEvent(Q
53
53
54 void peripheralWidget::mouseMoveEvent(QMouseEvent *event)
54 void peripheralWidget::mouseMoveEvent(QMouseEvent *event)
55 {
55 {
56
56 bool match=false;
57 for(int i=0; i<registersWdgts.count();i++)
58 {
59 if(registersWdgts.at(i)->contains(event->pos()))
60 {
61 match = true;
62 QToolTip::showText(event->globalPos(),registersWdgts.at(i)->bitFieldDesc(registersWdgts.at(i)->cursorIndex(event->pos().x())),(QWidget*)this);
63 }
64 }
65 if(!match)QToolTip::hideText();
57 }
66 }
58
67
59 void peripheralWidget::mouseReleaseEvent(QMouseEvent *event)
68 void peripheralWidget::mouseReleaseEvent(QMouseEvent *event)
@@ -80,6 +89,7 void peripheralWidget::keyPressEvent(QKe
80 case Qt::Key_R:
89 case Qt::Key_R:
81 qint32 value;
90 qint32 value;
82 value = emit readRegSig(registersWdgts.at(selectedReg)->address());
91 value = emit readRegSig(registersWdgts.at(selectedReg)->address());
92 registersWdgts.at(selectedReg)->setValue(value);
83 break;
93 break;
84 default:
94 default:
85 break;
95 break;
@@ -7,13 +7,21
7 #include <QList>
7 #include <QList>
8 #include <QTimer>
8 #include <QTimer>
9 #include "registerwidget.h"
9 #include "registerwidget.h"
10
10 /*
11 * TODO ADD an outdated marker
12 * Show outdated registers with a different color for example
13 */
11 class peripheralWidget : public QWidget
14 class peripheralWidget : public QWidget
12 {
15 {
13 Q_OBJECT
16 Q_OBJECT
14 public:
17 public:
15 explicit peripheralWidget(const QString& name,qint32 baseAddress, QWidget *parent = 0);
18 explicit peripheralWidget(const QString& name,qint32 baseAddress, QWidget *parent = 0);
16
19 registerWidget* registerAt(int index)
20 {
21 if(index>=0 && index<registersWdgts.count())
22 return registersWdgts.at(index);
23 return NULL;
24 }
17 signals:
25 signals:
18 void writeRegSig(qint32 address,qint32 value);
26 void writeRegSig(qint32 address,qint32 value);
19 qint32 readRegSig(qint32 address);
27 qint32 readRegSig(qint32 address);
@@ -113,9 +113,12 void registerWidget::clear(int index)
113
113
114 void registerWidget::set(int index)
114 void registerWidget::set(int index)
115 {
115 {
116 p_value |= 1<<index;
116 if(!this->p_fieldsEl->readonly(index))
117 this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0"));
117 {
118 emit this->repaint();
118 p_value |= 1<<index;
119 this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0"));
120 emit this->repaint();
121 }
119 }
122 }
120
123
121 void registerWidget::updateBoundingRect()
124 void registerWidget::updateBoundingRect()
@@ -129,11 +132,10 void registerWidget::updateBoundingRect(
129 bitfieldsElement::bitfieldsElement(const QString &value, QFont font, int xMargin, int yMargin)
132 bitfieldsElement::bitfieldsElement(const QString &value, QFont font, int xMargin, int yMargin)
130 :regWidgetElement(value,font,xMargin,yMargin)
133 :regWidgetElement(value,font,xMargin,yMargin)
131 {
134 {
132 this->attributesLUT.append(new bitFieldAttribute(true,"desc1"));
135 this->attributesLUT.append(new bitFieldAttribute(false,"UNSUSED"));
133 this->attributesLUT.append(new bitFieldAttribute(false,"desc2"));
134 for(int i=0;i<32;i++)
136 for(int i=0;i<32;i++)
135 {
137 {
136 attributesIndex[i] = i&1;
138 attributesIndex[i] = 0;
137 }
139 }
138 updateBoundingRect();
140 updateBoundingRect();
139 p_blinkTextBgColor = QColor(Qt::black);
141 p_blinkTextBgColor = QColor(Qt::black);
@@ -154,7 +156,7 QPoint bitfieldsElement::paint(QPainter
154 {
156 {
155 if(p_cursorBlinkEnable == false || (31-p_cursorIndex) != ((i*4)+l))
157 if(p_cursorBlinkEnable == false || (31-p_cursorIndex) != ((i*4)+l))
156 {
158 {
157 if(attributesLUT[attributesIndex[(i*4)+l]]->rw==false)
159 if(attributesLUT[attributesIndex[31-((i*4)+l)]]->rw==false)
158 {
160 {
159 painter->fillRect(xpos-1,0,p_dx,p_boundingRec.height(),Qt::lightGray);
161 painter->fillRect(xpos-1,0,p_dx,p_boundingRec.height(),Qt::lightGray);
160 }
162 }
@@ -79,6 +79,25 public:
79 uint cursorIndex();
79 uint cursorIndex();
80 uint cursorIndex(int xPos);
80 uint cursorIndex(int xPos);
81 void setFont(QFont font);
81 void setFont(QFont font);
82 int addAttribute(const QString& description,bool rw)
83 {
84 attributesLUT.append(new bitFieldAttribute(rw,description));
85 return attributesLUT.count()-1;
86 }
87 int setAttribute(int bitIndex,int attributeIndex)
88 {
89 attributesIndex[bitIndex]=attributeIndex;
90 }
91 QString description(int bitIndex)
92 {
93 return attributesLUT.at(attributesIndex[bitIndex])->description;
94 }
95 bool readonly(int bitIndex)
96 {
97 if(bitIndex>=0 && bitIndex<32)
98 return !attributesLUT.at(attributesIndex[bitIndex])->rw;
99 return false;
100 }
82 private:
101 private:
83 int attributesIndex[32];
102 int attributesIndex[32];
84 uint p_cursorIndex;
103 uint p_cursorIndex;
@@ -103,6 +122,22 public:
103 uint cursorIndex(int xPos);
122 uint cursorIndex(int xPos);
104 qint32 address();
123 qint32 address();
105 qint32 value();
124 qint32 value();
125 void setBitFieldAttribute(uint startIndex,uint stopIndex,const QString& description,bool rw)
126 {
127 if(startIndex<=stopIndex && stopIndex<32)
128 {
129 int index= p_fieldsEl->addAttribute(description,rw );
130 for(uint i=startIndex;i<=stopIndex;i++)
131 {
132 p_fieldsEl->setAttribute(i,index);
133 }
134 }
135 }
136 QString bitFieldDesc(int bitIndex)
137 {
138 return p_fieldsEl->description(bitIndex);
139 }
140
106 signals:
141 signals:
107 void cursorUp(int pos);
142 void cursorUp(int pos);
108 void cursorDown(int pos);
143 void cursorDown(int pos);
@@ -5,6 +5,8
5 #include <QtWidgets>
5 #include <QtWidgets>
6 #include "peripheralwidget.h"
6 #include "peripheralwidget.h"
7
7
8
9
8 class socRegsViewer : public QScrollArea
10 class socRegsViewer : public QScrollArea
9 {
11 {
10 Q_OBJECT
12 Q_OBJECT
General Comments 0
You need to be logged in to leave comments. Login now