Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable atom type and master term remove functionality #1883

Closed
wants to merge 10 commits into from
50 changes: 49 additions & 1 deletion src/gui/forcefieldTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ ForcefieldTab::ForcefieldTab(DissolveWindow *dissolveWindow, Dissolve &dissolve,
SLOT(masterTorsionsDataChanged(const QModelIndex &, const QModelIndex &)));
connect(&masterImpropersTableModel_, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this,
SLOT(masterImpropersDataChanged(const QModelIndex &, const QModelIndex &)));
connect(ui_.MasterBondsTable->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SLOT(masterBondsSelectionChanged(const QItemSelection &, const QItemSelection &)));
connect(ui_.MasterAnglesTable->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SLOT(masterAnglesSelectionChanged(const QItemSelection &, const QItemSelection &)));
connect(ui_.MasterTorsionsTable->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SLOT(masterTorsionsSelectionChanged(const QItemSelection &, const QItemSelection &)));
connect(ui_.MasterImpropersTable->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SLOT(masterImpropersSelectionChanged(const QItemSelection &, const QItemSelection &)));

/*
* Atom Types
Expand Down Expand Up @@ -283,10 +291,30 @@ void ForcefieldTab::on_AtomTypeAddButton_clicked(bool checked)
dissolveWindow_->setModified();
}

void ForcefieldTab::on_AtomTypeRemoveButton_clicked(bool checked) { Messenger::error("NOT IMPLEMENTED YET.\n"); }
void ForcefieldTab::on_AtomTypeRemoveButton_clicked(bool checked)
{
auto index = ui_.AtomTypesTable->currentIndex();
if (!index.isValid())
return;

// Get selected atomtype
auto at = atomTypesModel_.rawData(index);
if (!at)
return;

dissolve_.coreData().removeAtomType(at);

Locker refreshLocker(refreshLock_);

atomTypesModel_.setData(dissolve_.coreData().atomTypes());
ui_.AtomTypesTable->resizeColumnsToContents();

dissolveWindow_->setModified();
}

void ForcefieldTab::atomTypeSelectionChanged(const QItemSelection &current, const QItemSelection &previous)
{
ui_.AtomTypeRemoveButton->setEnabled(!current.empty());
ui_.AtomTypeDuplicateButton->setEnabled(!current.empty());
}

Expand Down Expand Up @@ -470,6 +498,26 @@ void ForcefieldTab::masterImpropersDataChanged(const QModelIndex &, const QModel
dissolveWindow_->setModified();
}

void ForcefieldTab::masterBondsSelectionChanged(const QItemSelection &current, const QItemSelection &previous)
{
ui_.MasterTermRemoveBondButton->setEnabled(!current.empty());
}

void ForcefieldTab::masterAnglesSelectionChanged(const QItemSelection &current, const QItemSelection &previous)
{
ui_.MasterTermRemoveAngleButton->setEnabled(!current.empty());
}

void ForcefieldTab::masterTorsionsSelectionChanged(const QItemSelection &current, const QItemSelection &previous)
{
ui_.MasterTermRemoveTorsionButton->setEnabled(!current.empty());
}

void ForcefieldTab::masterImpropersSelectionChanged(const QItemSelection &current, const QItemSelection &previous)
{
ui_.MasterTermRemoveImproperButton->setEnabled(!current.empty());
}

void ForcefieldTab::on_MasterTermAddBondButton_clicked(bool checked)
{
dissolve_.coreData().addMasterBond(
Expand Down
4 changes: 4 additions & 0 deletions src/gui/forcefieldTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class ForcefieldTab : public QWidget, public MainTab
void masterAnglesDataChanged(const QModelIndex &, const QModelIndex &);
void masterTorsionsDataChanged(const QModelIndex &, const QModelIndex &);
void masterImpropersDataChanged(const QModelIndex &, const QModelIndex &);
void masterBondsSelectionChanged(const QItemSelection &, const QItemSelection &);
void masterAnglesSelectionChanged(const QItemSelection &, const QItemSelection &);
void masterTorsionsSelectionChanged(const QItemSelection &, const QItemSelection &);
void masterImpropersSelectionChanged(const QItemSelection &, const QItemSelection &);
void on_MasterTermAddBondButton_clicked(bool checked);
void on_MasterTermRemoveBondButton_clicked(bool checked);
void on_MasterTermAddAngleButton_clicked(bool checked);
Expand Down