diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h index 8235d577892..914d7fbe88e 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h @@ -71,17 +71,20 @@ namespace hal { class BoolWizardPage:public QWizardPage { - friend BooleanFunctionEdit; + Q_OBJECT public: BoolWizardPage(QWidget* parent = nullptr); void initializePage() override; bool isComplete() const override; void setData(GateType* gate); std::unordered_map getBoolFunctions(); + private Q_SLOTS: + void handleStateChanged(const QString& stat); private: QGridLayout* mLayout; GateLibraryWizard* mWizard; + QList mEditFunctions; GateType* mGate = nullptr; }; } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp index 616b1c5810b..e3398eb795f 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/bool_wizardpage.cpp @@ -58,7 +58,8 @@ namespace hal setState(nextState); } //-------------------------------------------- - BoolWizardPage::BoolWizardPage(QWidget* parent) : QWizardPage(parent) + BoolWizardPage::BoolWizardPage(QWidget* parent) + : QWizardPage(parent) { setTitle("Boolean functions"); setSubTitle("Enter the boolean functions"); @@ -74,6 +75,13 @@ namespace hal for (PinItem* pi : inputPins) input_pins.insert(pi->getName().toStdString()); + if (mEditFunctions.isEmpty()) + { + for (BooleanFunctionEdit* bfe : mEditFunctions) + delete bfe; + mEditFunctions.clear(); + } + if(mGate != nullptr){ auto boolFunctions = mGate->get_boolean_functions(); auto list = QList>(); @@ -85,6 +93,8 @@ namespace hal mLayout->addWidget(label, boolFuncCnt, 0); mLayout->addWidget(lineEdit, boolFuncCnt, 1); lineEdit->setText(QString::fromStdString(bf.second.to_string())); + connect(lineEdit,&BooleanFunctionEdit::stateChanged,this,&BoolWizardPage::handleStateChanged); + mEditFunctions.append(lineEdit); boolFuncCnt++; } } @@ -103,6 +113,8 @@ namespace hal BooleanFunctionEdit* lineEdit = new BooleanFunctionEdit(input_pins, this); mLayout->addWidget(label, rowCount, 0); mLayout->addWidget(lineEdit, rowCount, 1); + connect(lineEdit,&BooleanFunctionEdit::stateChanged,this,&BoolWizardPage::handleStateChanged); + mEditFunctions.append(lineEdit); rowCount++; } } @@ -114,16 +126,21 @@ namespace hal setLayout(mLayout); } - void BoolWizardPage::setData(GateType *gate){ + void BoolWizardPage::setData(GateType *gate) + { mGate = gate; } - bool BoolWizardPage::isComplete() const{ + void BoolWizardPage::handleStateChanged(const QString& stat) + { + Q_UNUSED(stat); + Q_EMIT completeChanged(); + } - for(int i = 0; irowCount(); i++) + bool BoolWizardPage::isComplete() const + { + for(BooleanFunctionEdit* lineEdit : mEditFunctions) { - BooleanFunctionEdit* lineEdit = static_cast(mLayout->itemAtPosition(i, 1)->widget()); - connect(lineEdit, &BooleanFunctionEdit::editingFinished, this, &BoolWizardPage::completeChanged); if(!lineEdit->isValid()) { return false;