##// 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 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 68 void peripheralWidget::mouseReleaseEvent(QMouseEvent *event)
@@ -80,6 +89,7 void peripheralWidget::keyPressEvent(QKe
80 89 case Qt::Key_R:
81 90 qint32 value;
82 91 value = emit readRegSig(registersWdgts.at(selectedReg)->address());
92 registersWdgts.at(selectedReg)->setValue(value);
83 93 break;
84 94 default:
85 95 break;
@@ -7,13 +7,21
7 7 #include <QList>
8 8 #include <QTimer>
9 9 #include "registerwidget.h"
10
10 /*
11 * TODO ADD an outdated marker
12 * Show outdated registers with a different color for example
13 */
11 14 class peripheralWidget : public QWidget
12 15 {
13 16 Q_OBJECT
14 17 public:
15 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 25 signals:
18 26 void writeRegSig(qint32 address,qint32 value);
19 27 qint32 readRegSig(qint32 address);
@@ -113,9 +113,12 void registerWidget::clear(int index)
113 113
114 114 void registerWidget::set(int index)
115 115 {
116 p_value |= 1<<index;
117 this->p_fieldsEl->setValue(QString("%1").arg((uint)p_value,32,2).replace(" ","0"));
118 emit this->repaint();
116 if(!this->p_fieldsEl->readonly(index))
117 {
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 124 void registerWidget::updateBoundingRect()
@@ -129,11 +132,10 void registerWidget::updateBoundingRect(
129 132 bitfieldsElement::bitfieldsElement(const QString &value, QFont font, int xMargin, int yMargin)
130 133 :regWidgetElement(value,font,xMargin,yMargin)
131 134 {
132 this->attributesLUT.append(new bitFieldAttribute(true,"desc1"));
133 this->attributesLUT.append(new bitFieldAttribute(false,"desc2"));
135 this->attributesLUT.append(new bitFieldAttribute(false,"UNSUSED"));
134 136 for(int i=0;i<32;i++)
135 137 {
136 attributesIndex[i] = i&1;
138 attributesIndex[i] = 0;
137 139 }
138 140 updateBoundingRect();
139 141 p_blinkTextBgColor = QColor(Qt::black);
@@ -154,7 +156,7 QPoint bitfieldsElement::paint(QPainter
154 156 {
155 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 161 painter->fillRect(xpos-1,0,p_dx,p_boundingRec.height(),Qt::lightGray);
160 162 }
@@ -79,6 +79,25 public:
79 79 uint cursorIndex();
80 80 uint cursorIndex(int xPos);
81 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 101 private:
83 102 int attributesIndex[32];
84 103 uint p_cursorIndex;
@@ -103,6 +122,22 public:
103 122 uint cursorIndex(int xPos);
104 123 qint32 address();
105 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 141 signals:
107 142 void cursorUp(int pos);
108 143 void cursorDown(int pos);
@@ -5,6 +5,8
5 5 #include <QtWidgets>
6 6 #include "peripheralwidget.h"
7 7
8
9
8 10 class socRegsViewer : public QScrollArea
9 11 {
10 12 Q_OBJECT
General Comments 0
You need to be logged in to leave comments. Login now