Skip to content

Commit

Permalink
Implemented validation for Boolean Function WizardPage
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneela committed Jun 5, 2024
1 parent 5c13b82 commit f7dd78c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace hal {
public:
BoolWizardPage(QWidget* parent = nullptr);
void initializePage() override;
bool validatePage() override;
void setData(GateType* gate);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ namespace hal {
QStringList getProperties();
void setMode(bool edit);
bool validatePage() override;
//int nextId() const override;
public Q_SLOTS:
void addProperty();
void deleteProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ namespace hal
return;
GateLibraryWizard wiz(mEditableGatelibrary, mTableModel->getGateTypeAtIndex(index.row()));
wiz.exec();
wiz.accept();
}

void GateLibraryManager::handleAddWizard()
{
GateLibraryWizard wiz(mEditableGatelibrary);
wiz.exec();
wiz.accept();
}

void GateLibraryManager::handleDeleteType(QModelIndex index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,24 @@ namespace hal
void BoolWizardPage::setData(GateType *gate){
mGate = gate;
}

bool BoolWizardPage::validatePage(){

int rowCount = 0;
QList<PinItem*> inputPins = mWizard->mPinModel->getInputPins();
QList<PinItem*> outputPins = mWizard->mPinModel->getOutputPins();
while(mLayout->itemAtPosition(rowCount, 1) != nullptr){
QLabel* label = static_cast<QLabel*>(mLayout->itemAtPosition(rowCount, 1)->widget());
auto bfres = BooleanFunction::from_string(label->text().toStdString());
if(bfres.is_error()) return false;
BooleanFunction bf = bfres.get();
std::set<std::string> names = bf.get_variable_names();
for(auto item : inputPins)
{
if(names.find(item->getName().toStdString()) == names.end()) return false;
}
rowCount++;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,4 @@ namespace hal
}
return true;
}
// int GeneralInfoWizardPage::nextId() const
// {
// auto parentWizard = wizard();
// if(!parentWizard)
// return -1;
// return static_cast<GateLibraryWizard*>(parentWizard)->getNextPageId(GateLibraryWizard::GeneralInfo);
// }
}

0 comments on commit f7dd78c

Please sign in to comment.