diff --git a/peripheralwidget.cpp b/peripheralwidget.cpp --- a/peripheralwidget.cpp +++ b/peripheralwidget.cpp @@ -7,7 +7,7 @@ peripheralWidget::peripheralWidget(const for(int i=0;i<10;i++) { registersWdgts.append(new registerWidget(QString("REG%1").arg(i),i*8)); - registersWdgts.at(i)->setValue(-1); + registersWdgts.at(i)->setValue((i<<24)+(i<<8)+i); mainLayout->addWidget(registersWdgts.at(i)); } setLayout(mainLayout); diff --git a/registerwidget.h b/registerwidget.h --- a/registerwidget.h +++ b/registerwidget.h @@ -53,18 +53,26 @@ protected: class bitfieldsElement: public regWidgetElement { - struct bitAttribute + class bitFieldAttribute { + public: + bitFieldAttribute(bool rw,QString description) + { + this->rw = rw; + this->description = description; + } bool rw; - int descIndex; + QString description; }; public: bitfieldsElement(const QString& value,QFont font,int xMargin,int yMargin) :regWidgetElement(value,font,xMargin,yMargin) { + this->attributesLUT.append(new bitFieldAttribute(true,"desc1")); + this->attributesLUT.append(new bitFieldAttribute(false,"desc2")); for(int i=0;i<32;i++) { - attributes[i].rw = false; + attributesIndex[i] = i&1; } updateBoundingRect(); } @@ -78,7 +86,7 @@ public: { for(int l = 0;l<4;l++) { - if(attributes[(i*4)+l].rw==false) + if(attributesLUT[attributesIndex[(i*4)+l]]->rw==false) painter->fillRect(xpos-1,0,dx,p_boundingRec.height(),Qt::lightGray); else painter->fillRect(xpos-1,0,dx,p_boundingRec.height(),Qt::white); @@ -101,8 +109,14 @@ public: int width = (((4*(QFontMetrics(p_font).width("0") + 2)) + p_xMargins) * 8) + (p_xMargins); p_boundingRec.setWidth(width); } + void setValue(const QString& value) + { + p_valueStr = value; + updateBoundingRect(); + } private: - struct bitAttribute attributes[32]; + int attributesIndex[32]; + QList attributesLUT; };