@@ -27,12 +27,9 @@ int InstructionModel::addressToRow(AInt addr) const {
2727
2828InstructionModel::InstructionModel (QObject *parent)
2929 : QAbstractTableModel(parent) {
30- for (auto laneIt : ProcessorHandler::getProcessor ()->structure ()) {
31- for (unsigned stageIdx = 0 ; stageIdx < laneIt.second ; stageIdx++) {
32- StageIndex idx = {laneIt.first , stageIdx};
33- m_stageNames[idx] = ProcessorHandler::getProcessor ()->stageName (idx);
34- m_stageInfos[idx] = ProcessorHandler::getProcessor ()->stageInfo (idx);
35- }
30+ for (auto idx : ProcessorHandler::getProcessor ()->structure ().stageIt ()) {
31+ m_stageNames[idx] = ProcessorHandler::getProcessor ()->stageName (idx);
32+ m_stageInfos[idx] = ProcessorHandler::getProcessor ()->stageInfo (idx);
3633 }
3734 connect (ProcessorHandler::get (), &ProcessorHandler::procStateChangedNonRun,
3835 this , &InstructionModel::updateStageInfo);
@@ -67,34 +64,31 @@ int InstructionModel::rowCount(const QModelIndex &) const { return m_rowCount; }
6764
6865void InstructionModel::updateStageInfo () {
6966 bool firstStageChanged = false ;
70- for (auto laneIt : ProcessorHandler::getProcessor ()->structure ()) {
71- for (unsigned stageIdx = 0 ; stageIdx < laneIt.second ; stageIdx++) {
72- StageIndex idx = {laneIt.first , stageIdx};
73- auto stageInfoIt = m_stageInfos.find (idx);
74- if (stageInfoIt != m_stageInfos.end ()) {
75- auto &oldStageInfo = m_stageInfos.at (idx);
76- if (idx == StageIndex (0 , 0 )) {
77- if (oldStageInfo.pc !=
78- ProcessorHandler::getProcessor ()->stageInfo (idx).pc ) {
79- firstStageChanged = true ;
80- }
81- }
82- const auto stageInfo = ProcessorHandler::getProcessor ()->stageInfo (idx);
83- const AInt oldAddress = oldStageInfo.pc ;
84- if (oldStageInfo != stageInfo) {
85- oldStageInfo = stageInfo;
86- const int oldRow = addressToRow (oldAddress);
87- const int newRow = addressToRow (stageInfo.pc );
88- const QModelIndex oldIdx = index (oldRow, Stage);
89- const QModelIndex newIdx = index (newRow, Stage);
90- emit dataChanged (oldIdx, oldIdx, {Qt::DisplayRole});
91- emit dataChanged (newIdx, newIdx, {Qt::DisplayRole});
92- }
93- if (firstStageChanged) {
94- emit firstStageInstrChanged (addressToRow (m_stageInfos.at ({0 , 0 }).pc ));
95- firstStageChanged = false ;
67+ for (auto idx : ProcessorHandler::getProcessor ()->structure ().stageIt ()) {
68+ auto stageInfoIt = m_stageInfos.find (idx);
69+ if (stageInfoIt != m_stageInfos.end ()) {
70+ auto &oldStageInfo = m_stageInfos.at (idx);
71+ if (idx == StageIndex (0 , 0 )) {
72+ if (oldStageInfo.pc !=
73+ ProcessorHandler::getProcessor ()->stageInfo (idx).pc ) {
74+ firstStageChanged = true ;
9675 }
9776 }
77+ const auto stageInfo = ProcessorHandler::getProcessor ()->stageInfo (idx);
78+ const AInt oldAddress = oldStageInfo.pc ;
79+ if (oldStageInfo != stageInfo) {
80+ oldStageInfo = stageInfo;
81+ const int oldRow = addressToRow (oldAddress);
82+ const int newRow = addressToRow (stageInfo.pc );
83+ const QModelIndex oldIdx = index (oldRow, Stage);
84+ const QModelIndex newIdx = index (newRow, Stage);
85+ emit dataChanged (oldIdx, oldIdx, {Qt::DisplayRole});
86+ emit dataChanged (newIdx, newIdx, {Qt::DisplayRole});
87+ }
88+ if (firstStageChanged) {
89+ emit firstStageInstrChanged (addressToRow (m_stageInfos.at ({0 , 0 }).pc ));
90+ firstStageChanged = false ;
91+ }
9892 }
9993 }
10094}
0 commit comments