summaryrefslogtreecommitdiff
path: root/utils/regtools/qeditor/regedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/regtools/qeditor/regedit.cpp')
-rw-r--r--utils/regtools/qeditor/regedit.cpp54
1 files changed, 20 insertions, 34 deletions
diff --git a/utils/regtools/qeditor/regedit.cpp b/utils/regtools/qeditor/regedit.cpp
index 9dca6280e0..851e054eb0 100644
--- a/utils/regtools/qeditor/regedit.cpp
+++ b/utils/regtools/qeditor/regedit.cpp
@@ -336,47 +336,33 @@ RegEditPanel::RegEditPanel(SocRegRef ref, QWidget *parent)
336 top_layout->addLayout(name_layout); 336 top_layout->addLayout(name_layout);
337 top_layout->addWidget(m_desc_group, 1); 337 top_layout->addWidget(m_desc_group, 1);
338 338
339 m_sexy_display = new RegSexyDisplay(m_ref, this); 339 m_value_table = new QTableView(this);
340 m_sexy_display->setFont(m_reg_font); 340 m_value_model = new RegFieldTableModel(m_value_table); // view takes ownership
341 m_value_model->SetRegister(m_ref.GetReg());
342 m_value_model->SetReadOnly(true);
343 m_value_table->setModel(m_value_model);
344 m_value_table->verticalHeader()->setVisible(false);
345 m_value_table->horizontalHeader()->setStretchLastSection(true);
346 m_value_table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
347 // FIXME we cannot use setAlternatingRowColors() because we override the
348 // background color, should it be part of the model ?
349 m_table_delegate = new SocFieldCachedItemDelegate(this);
350 m_value_table->setItemDelegate(m_table_delegate);
351 m_value_table->resizeColumnsToContents();
352
353 m_sexy_display2 = new Unscroll<RegSexyDisplay2>(this);
354 m_sexy_display2->setFont(m_reg_font);
355 m_sexy_display2->setModel(m_value_model);
356 m_sexy_display2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
341 357
342 m_field_table = new QTableWidget;
343 m_field_table->setRowCount(m_ref.GetReg().field.size());
344 m_field_table->setColumnCount(4);
345 for(size_t row = 0; row < m_ref.GetReg().field.size(); row++)
346 {
347 const soc_reg_field_t& field = m_ref.GetReg().field[row];
348 QString bits_str;
349 if(field.first_bit == field.last_bit)
350 bits_str.sprintf("%d", field.first_bit);
351 else
352 bits_str.sprintf("%d:%d", field.last_bit, field.first_bit);
353 QTableWidgetItem *item = new QTableWidgetItem(bits_str);
354 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
355 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
356 m_field_table->setItem(row, 1, item);
357 item = new QTableWidgetItem(QString(field.name.c_str()));
358 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
359 m_field_table->setItem(row, 2, item);
360 item = new QTableWidgetItem(QString(field.desc.c_str()));
361 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
362 m_field_table->setItem(row, 3, item);
363 UpdateWarning(row);
364 }
365 m_field_table->setHorizontalHeaderItem(0, new QTableWidgetItem(""));
366 m_field_table->setHorizontalHeaderItem(1, new QTableWidgetItem("Bits"));
367 m_field_table->setHorizontalHeaderItem(2, new QTableWidgetItem("Name"));
368 m_field_table->setHorizontalHeaderItem(3, new QTableWidgetItem("Description"));
369 m_field_table->verticalHeader()->setVisible(false);
370 m_field_table->resizeColumnsToContents();
371 m_field_table->horizontalHeader()->setStretchLastSection(true);
372 QHBoxLayout *field_layout = new QHBoxLayout; 358 QHBoxLayout *field_layout = new QHBoxLayout;
373 field_layout->addWidget(m_field_table); 359 field_layout->addWidget(m_value_table);
374 m_field_group = new QGroupBox("Flags", this); 360 m_field_group = new QGroupBox("Flags", this);
375 m_field_group->setLayout(field_layout); 361 m_field_group->setLayout(field_layout);
376 362
377 QVBoxLayout *layout = new QVBoxLayout; 363 QVBoxLayout *layout = new QVBoxLayout;
378 layout->addLayout(top_layout, 0); 364 layout->addLayout(top_layout, 0);
379 layout->addWidget(m_sexy_display, 0); 365 layout->addWidget(m_sexy_display2, 0);
380 layout->addWidget(m_field_group); 366 layout->addWidget(m_field_group);
381 367
382 UpdateFormula(); 368 UpdateFormula();