diff --git a/src/sliderulestab.cpp b/src/sliderulestab.cpp index 91f79749..f687b59f 100644 --- a/src/sliderulestab.cpp +++ b/src/sliderulestab.cpp @@ -158,15 +158,7 @@ SliderulesTab::SliderulesTab(QToolBar *toolbar, QWidget *parent) isaBox->setCurrentIndex( isaBox->findData(QVariant(static_cast(isaInfo.isaID())))); - mainExtBox->clear(); - for (const auto &ext : - QStringList(isaInfo.baseExtension()) + isaInfo.supportedExtensions()) { - mainExtBox->addItem(ext, ext); - } - - baseExtCheckBox->setText(isaInfo.baseExtension()); - baseExtCheckBox->setChecked(true); - baseExtCheckBox->setEnabled(false); + resetExtensionFilters(isaInfo); // Update model when the processor is changed connect(ProcessorHandler::get(), &ProcessorHandler::processorChanged, @@ -196,6 +188,12 @@ SliderulesTab::SliderulesTab(QToolBar *toolbar, QWidget *parent) isaBox->setCurrentIndex( isaBox->findData(QVariant(static_cast(isaInfo.isaID())))); }); + connect(m_isaModel.get(), &ISAInstructionsModel::isaInfoChanged, this, + [=](const ISAInfoBase &isaInfo) { + if (isaInfo.isaID() != m_isaModel->prevISAInfo()->isaID()) { + resetExtensionFilters(isaInfo); + } + }); } SliderulesTab::~SliderulesTab() { delete ui; } @@ -207,4 +205,26 @@ void SliderulesTab::resetISAFilter(const ISAInfoBase &isaInfo) { } } +void SliderulesTab::resetExtensionFilters(const ISAInfoBase &isaInfo) { + mainExtBox->clear(); + for (const auto &ext : + QStringList(isaInfo.baseExtension()) + isaInfo.supportedExtensions()) { + mainExtBox->addItem(ext, ext); + } + + QLayoutItem *child; + while ((child = ui->enabledExtGrid->takeAt(1)) != nullptr) { + delete child->widget(); + delete child; + } + for (const auto &ext : isaInfo.supportedExtensions()) { + auto count = ui->enabledExtGrid->count(); + ui->enabledExtGrid->addWidget(new QCheckBox(ext), count % 2, count / 2); + } + + baseExtCheckBox->setText(isaInfo.baseExtension()); + baseExtCheckBox->setChecked(true); + baseExtCheckBox->setEnabled(false); +} + } // namespace Ripes diff --git a/src/sliderulestab.h b/src/sliderulestab.h index 0b254cf1..c52fd2a2 100644 --- a/src/sliderulestab.h +++ b/src/sliderulestab.h @@ -80,9 +80,11 @@ class SliderulesTab : public RipesTab { public slots: // void updateView(const ISAInfoBase &isaInfo); -private: +private slots: void resetISAFilter(const ISAInfoBase &isaInfo); + void resetExtensionFilters(const ISAInfoBase &isaInfo); +private: Ui::SliderulesTab *ui = nullptr; QComboBox *isaFamilyBox = nullptr;