Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/GateLibraryManager' into…
Browse files Browse the repository at this point in the history
… feature/GateLibraryManager
  • Loading branch information
joern274 committed Sep 30, 2024
2 parents 95bb43a + 9c6baa1 commit dc671f2
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ namespace hal {
bool isComplete() const override;
void setData(GateType* gate);
std::unordered_map<std::string, BooleanFunction> getBoolFunctions();
Q_SIGNALS:
void hasChanged();
private Q_SLOTS:
void handleStateChanged(const QString& stat);

void handleTextChanged(const QString& txt);
private:
QGridLayout* mLayout;
GateLibraryWizard* mWizard;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ namespace hal {
void initializePage() override;
void setData(GateType* gate);
bool isComplete() const override;

Q_SIGNALS:
void hasChanged();
public Q_SLOTS:
void handleTextChanged(const QString& txt);
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace hal {
QString getName();
QList<GateTypeProperty> getProperties() const;
bool isComplete() const override;
void initializePage() override;

QString disabledIconStyle() const { return mDisabledIconStyle; }
QString enabledIconStyle() const { return mEnabledIconStyle; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@
namespace hal {
class InitWizardPage:public QWizardPage{
friend class GateLibraryWizard;
Q_OBJECT
public:
InitWizardPage(QWidget* parent = nullptr);
//void initializePage() override;
//int nextId() const override;
void initializePage() override;
bool isComplete() const override;
void setData(GateType* gate);

private Q_SLOTS:
void handleTextChanged(const QString& txt);
void handleTextEditChanged();

private:
GateLibraryWizard* mWizard;
QGridLayout* mLayout;

QLineEdit* mCategory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <QLabel>

namespace hal {
class GateLibraryWizard;
class LatchWizardPage:public QWizardPage{
friend class GateLibraryWizard;
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace hal {
QList<RAMPort> getRamPorts();
void setData(GateType* gate);
void initializePage() override;
bool isComplete() const override;

private:
GateLibraryWizard* mWizard;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ namespace hal
{
Q_OBJECT

friend class RAMPortWizardPage;
friend class GeneralInfoWizardPage;
friend class PinsWizardPage;
friend class FlipFlopWizardPage;
friend class StateWizardPage;
friend class BoolWizardPage;
friend class LatchWizardPage;

friend class RAMPortWizardPage;
friend class StateWizardPage;
friend class InitWizardPage;
public:
enum PAGE
{
Expand Down Expand Up @@ -95,5 +99,7 @@ namespace hal
PinModel* mPinModel;
GateType* mNewGateType;
bool mWasEdited;
bool mEditMode;
QString mTitle;
};
}
11 changes: 9 additions & 2 deletions plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,17 @@ namespace hal
{
if(mReadOnly)
return;
mWizard = new GateLibraryWizard(mGateLibrary, mTableModel->getGateTypeAtIndex(index.row()));
GateType* gtEditable = mTableModel->getGateTypeAtIndex(index.row());
mWizard = new GateLibraryWizard(mGateLibrary, gtEditable);
connect(mWizard, &GateLibraryWizard::triggerUnsavedChanges, mContentWidget, &GatelibraryContentWidget::handleUnsavedChanges);

mWizard->exec();
initialize(mGateLibrary);

mContentWidget->mTableView->selectRow(index.row());
for (int r=0; r<mTableModel->rowCount(); r++) {
if(mTableModel->getGateTypeAtIndex(r) == gtEditable)
mContentWidget->mTableView->selectRow(r);
}
mContentWidget->setGateLibrary(mGateLibrary);
mContentWidget->setGateLibraryPath(mPath);
}
Expand Down Expand Up @@ -235,7 +239,10 @@ namespace hal
void GateLibraryManager::handleCancelClicked()
{
if(!gFileStatusManager->isGatelibModified())
{
window()->setWindowTitle("HAL");
Q_EMIT close();
}
else
{
callUnsavedChangesWindow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace hal
}
if (mState != nextState)
setState(nextState);

}
//--------------------------------------------
BoolWizardPage::BoolWizardPage(QWidget* parent)
Expand Down Expand Up @@ -113,7 +114,8 @@ namespace hal
{
lineEdit->setText(QString::fromStdString(bf->second.to_string()));
}
connect(lineEdit,&BooleanFunctionEdit::stateChanged,this,&BoolWizardPage::handleStateChanged);
connect(lineEdit, &BooleanFunctionEdit::stateChanged,this,&BoolWizardPage::handleStateChanged);
connect(lineEdit, &BooleanFunctionEdit::textChanged, this, &BoolWizardPage::handleTextChanged);
mEditFunctions.append(lineEdit);
mOutputPins.append(label->text());
boolFuncCnt++;
Expand Down Expand Up @@ -144,6 +146,7 @@ namespace hal
mLayout->addWidget(label, rowCount, 0);
mLayout->addWidget(lineEdit, rowCount, 1);
connect(lineEdit,&BooleanFunctionEdit::stateChanged,this,&BoolWizardPage::handleStateChanged);
connect(lineEdit, &BooleanFunctionEdit::textChanged, this, &BoolWizardPage::handleTextChanged);
mEditFunctions.append(lineEdit);
mOutputPins.append(label->text());
rowCount++;
Expand All @@ -155,6 +158,8 @@ namespace hal
}

setLayout(mLayout);
Q_EMIT completeChanged();
mWizard->mEditMode = true;
}

void BoolWizardPage::setData(GateType *gate)
Expand All @@ -166,6 +171,23 @@ namespace hal
{
Q_UNUSED(stat);
Q_EMIT completeChanged();
if(mWizard->mEditMode) Q_EMIT hasChanged();
}

void BoolWizardPage::handleTextChanged(const QString& txt)
{
Q_UNUSED(txt);

//explicitly needed here because isComplete() is called
//before mWasEdited is changed in the wizard
//

Q_EMIT completeChanged();
if(mWizard->mEditMode)
{
mWizard->mWasEdited = true;
Q_EMIT hasChanged();
}
}

bool BoolWizardPage::isComplete() const
Expand All @@ -177,7 +199,8 @@ namespace hal
return false;
}
}
if(!mWizard->mWasEdited) return false;
if(isFinalPage() && !mWizard->mWasEdited) return false;
mWizard->mEditMode = false;
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,14 @@ namespace hal
}

Q_EMIT completeChanged();

mWizard->mEditMode = true;
}

void FlipFlopWizardPage::handleTextChanged(const QString& text){
Q_UNUSED(text);
mWizard = static_cast<GateLibraryWizard*>(wizard());

if(mASet->text().isEmpty() || mAReset->text().isEmpty())
{
mIntState->clear();
Expand All @@ -132,8 +136,9 @@ namespace hal
mIntState->setDisabled(false);
mNegIntState->setDisabled(false);
}

Q_EMIT completeChanged();

if(mWizard->mEditMode) Q_EMIT hasChanged();
}

void FlipFlopWizardPage::setData(GateType *gate){
Expand Down Expand Up @@ -187,6 +192,7 @@ namespace hal
mNegIntState->text().toStdString() != enum_to_string(AsyncSetResetBehavior::X))
return false;
}
mWizard->mEditMode = false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ namespace hal
mName->setValidator(mValidator);
}

void GeneralInfoWizardPage::initializePage()
{
mWizard = static_cast<GateLibraryWizard*>(wizard());
mWizard->mEditMode = true;
}

void GeneralInfoWizardPage::setData(QString name, const std::vector<GateTypeProperty>& properties)
{
mName->setText(name);
Expand Down Expand Up @@ -185,6 +191,7 @@ namespace hal
if (QString::fromStdString(it.first) == mName->text())
return false;
}
mWizard->mEditMode = false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ namespace hal
mLayout->addWidget(mIdentifiers, 1, 1);

setLayout(mLayout);

connect(mCategory, &QLineEdit::textChanged, this, &InitWizardPage::handleTextChanged);
connect(mIdentifiers, &QTextEdit::textChanged, this, &InitWizardPage::handleTextEditChanged);
}

void InitWizardPage::initializePage()
{
mWizard = static_cast<GateLibraryWizard*>(wizard());
mWizard->mEditMode = true;
}

void InitWizardPage::setData(GateType *gate){
Expand All @@ -47,4 +56,34 @@ namespace hal
}
}
}

void InitWizardPage::handleTextChanged(const QString& txt)
{
Q_UNUSED(txt);
mWizard = static_cast<GateLibraryWizard*>(wizard());

//explicitly needed here because isComplete() is called
//before mWasEdited is changed in the wizard
if(mWizard->mEditMode) mWizard->mWasEdited = true;

Q_EMIT completeChanged();
}

void InitWizardPage::handleTextEditChanged()
{
mWizard = static_cast<GateLibraryWizard*>(wizard());

//explicitly needed here because isComplete() is called
//before mWasEdited is changed in the wizard
if(mWizard->mEditMode) mWizard->mWasEdited = true;

Q_EMIT completeChanged();
}

bool InitWizardPage::isComplete() const
{
if(isFinalPage() && !mWizard->mWasEdited) return false;
mWizard->mEditMode = false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ namespace hal

setLayout(mLayout);

connect(mDataIn, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged);
connect(mEnableOn, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged);
connect(mAReset, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged);
connect(mASet, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged);
connect(mIntState, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged);
connect(mNegIntState, &QLineEdit::textChanged, this, &LatchWizardPage::completeChanged);
}

void LatchWizardPage::setData(GateType *gate){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace hal

setLayout(mLayout);

connect(mAscending, &QCheckBox::stateChanged, this, &LUTWizardPage::completeChanged);
}

void LUTWizardPage::setData(GateType *gate){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace hal
{
mWizard = static_cast<GateLibraryWizard*>(wizard());
mWizard->mPinModel = mPinModel;
mWizard->mEditMode = true;

if(!mGateset)
{
Expand Down Expand Up @@ -70,6 +71,7 @@ namespace hal
}
}
}
mWizard->mEditMode = false;
return hasPingroup;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@ void RAMPortWizardPage::initializePage(){
rp.isWritePort->setChecked(ram_port->is_write_port());
}
mRamPortEdits.append(rp);

connect(rp.dataGroup, &QLineEdit::textChanged, this, &RAMPortWizardPage::completeChanged);
connect(rp.addressGroup, &QLineEdit::textChanged, this, &RAMPortWizardPage::completeChanged);
connect(rp.clockFunction, &QLineEdit::textChanged, this, &RAMPortWizardPage::completeChanged);
connect(rp.enableFunciton, &QLineEdit::textChanged, this, &RAMPortWizardPage::completeChanged);
connect(rp.isWritePort, &QCheckBox::stateChanged, this, &RAMPortWizardPage::completeChanged);
}
}

mWizard->mEditMode = true;
setLayout(mLayout);
}

Expand All @@ -79,4 +86,10 @@ void RAMPortWizardPage::initializePage(){
QList<RAMPortWizardPage::RAMPort> RAMPortWizardPage::getRamPorts(){
return mRamPortEdits;
}

bool RAMPortWizardPage::isComplete() const
{
mWizard->mEditMode = false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace hal

setLayout(mLayout);

connect(mBitSize, &QLineEdit::textChanged, this, &RAMWizardPage::completeChanged);
}

void RAMWizardPage::setData(GateType *gate){
Expand Down
Loading

0 comments on commit dc671f2

Please sign in to comment.