diff --git a/copasi/UI/CQCompartmentDM.cpp b/copasi/UI/CQCompartmentDM.cpp index da15bfe95a..48e46a262b 100644 --- a/copasi/UI/CQCompartmentDM.cpp +++ b/copasi/UI/CQCompartmentDM.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -376,10 +376,10 @@ bool CQCompartmentDM::removeRows(QModelIndexList rows, const QModelIndex& index) // Build the list of items to be deleted // before actually deleting any item. QList names; - + for (const auto& index : rows) if (index.isValid() - && !isDefaultRow(index)) + && !isDefaultRow(index) && index.row() < (int) mpCompartments->size()) { names.append(mpCompartments->operator[](index.row()).getObjectName()); } diff --git a/copasi/UI/CQCompartmentsWidget.cpp b/copasi/UI/CQCompartmentsWidget.cpp index 0466cabef4..b61055ef80 100644 --- a/copasi/UI/CQCompartmentsWidget.cpp +++ b/copasi/UI/CQCompartmentsWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -119,6 +119,7 @@ void CQCompartmentsWidget::deleteSelectedCompartments() {return;} mpCompartmentDM->removeRows(mappedSelRows); + enterProtected(); } void CQCompartmentsWidget::slotBtnClearClicked() diff --git a/copasi/UI/CQEventDM.cpp b/copasi/UI/CQEventDM.cpp index 4193e8a1f4..9828c9b7a2 100644 --- a/copasi/UI/CQEventDM.cpp +++ b/copasi/UI/CQEventDM.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -312,7 +312,7 @@ bool CQEventDM::removeRows(QModelIndexList rows, const QModelIndex& index) for (i = rows.begin(); i != rows.end(); ++i) if (i->isValid() - && !isDefaultRow(*i)) + && !isDefaultRow(*i) && i->row() < (int) mpEvents->size()) { Events.append(&mpEvents->operator[](i->row())); } diff --git a/copasi/UI/CQEventsWidget.cpp b/copasi/UI/CQEventsWidget.cpp index 154b2c4b55..32dfd12ef0 100644 --- a/copasi/UI/CQEventsWidget.cpp +++ b/copasi/UI/CQEventsWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -118,6 +118,7 @@ void CQEventsWidget::deleteSelectedEvents() {return;} mpEventDM->removeRows(mappedSelRows); + enterProtected(); } void CQEventsWidget::slotBtnClearClicked() @@ -188,7 +189,6 @@ void CQEventsWidget::dataChanged(const QModelIndex &C_UNUSED(topLeft), { mpTblEvents->resizeColumnsToContents(); } - } void CQEventsWidget::slotDoubleClicked(const QModelIndex proxyIndex) diff --git a/copasi/UI/CQGlobalQuantitiesWidget.cpp b/copasi/UI/CQGlobalQuantitiesWidget.cpp index fc629bd860..2a551f422e 100644 --- a/copasi/UI/CQGlobalQuantitiesWidget.cpp +++ b/copasi/UI/CQGlobalQuantitiesWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -118,6 +118,7 @@ void CQGlobalQuantitiesWidget::deleteSelectedGlobalQuantities() {return;} mpGlobalQuantityDM->removeRows(mappedSelRows); + enterProtected(); } void CQGlobalQuantitiesWidget::slotBtnClearClicked() @@ -129,7 +130,6 @@ void CQGlobalQuantitiesWidget::slotBtnClearClicked() { mpGlobalQuantityDM->clear(); } - } bool CQGlobalQuantitiesWidget::updateProtected(ListViews::ObjectType objectType, ListViews::Action action, const CRegisteredCommonName & cn) diff --git a/copasi/UI/CQGlobalQuantityDM.cpp b/copasi/UI/CQGlobalQuantityDM.cpp index 4d217b5d1a..10fb9c0c79 100644 --- a/copasi/UI/CQGlobalQuantityDM.cpp +++ b/copasi/UI/CQGlobalQuantityDM.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -378,12 +378,11 @@ bool CQGlobalQuantityDM::removeRows(QModelIndexList rows, const QModelIndex& ind for (i = rows.begin(); i != rows.end(); ++i) if (i->isValid() - && !isDefaultRow(*i)) + && !isDefaultRow(*i) && i->row() < (int) mpGlobalQuantities->size()) { names.append(mpGlobalQuantities->operator[](i->row()).getObjectName()); } - for (auto& objName : names) { auto index = mpGlobalQuantities->getIndex(objName); diff --git a/copasi/UI/CQReactionDM.cpp b/copasi/UI/CQReactionDM.cpp index 4921012885..81701a47a0 100644 --- a/copasi/UI/CQReactionDM.cpp +++ b/copasi/UI/CQReactionDM.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -323,7 +323,7 @@ bool CQReactionDM::removeRows(QModelIndexList rows, const QModelIndex& index) for (i = rows.begin(); i != rows.end(); ++i) { if (i->isValid() - && !isDefaultRow(*i)) + && !isDefaultRow(*i) && i->row() < (int) mpReactions->size()) Reactions.append(&mpReactions->operator[](i->row())); } diff --git a/copasi/UI/CQReactionsWidget.cpp b/copasi/UI/CQReactionsWidget.cpp index 91ac91bdf9..e26d427eac 100644 --- a/copasi/UI/CQReactionsWidget.cpp +++ b/copasi/UI/CQReactionsWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -99,7 +99,6 @@ void CQReactionsWidget::slotBtnDeleteClicked(bool needFocus) { if (!needFocus || mpTblReactions->hasFocus()) {deleteSelectedReactions();} - } void CQReactionsWidget::slotBtnClearClicked() @@ -111,7 +110,6 @@ void CQReactionsWidget::slotBtnClearClicked() { mpReactionDM->clear(); } - } bool CQReactionsWidget::updateProtected(ListViews::ObjectType objectType, ListViews::Action action, const CRegisteredCommonName & cn) @@ -162,7 +160,6 @@ bool CQReactionsWidget::enterProtected() return true; } - void CQReactionsWidget::dataChanged(const QModelIndex &C_UNUSED(topLeft), const QModelIndex &C_UNUSED(bottomRight)) { @@ -282,4 +279,5 @@ void CQReactionsWidget::deleteSelectedReactions() {return;} mpReactionDM->removeRows(mappedSelRows); + enterProtected(); } diff --git a/copasi/UI/CQSpecieDM.cpp b/copasi/UI/CQSpecieDM.cpp index a6347f7c4d..2e30b3525d 100644 --- a/copasi/UI/CQSpecieDM.cpp +++ b/copasi/UI/CQSpecieDM.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -586,18 +586,18 @@ bool CQSpecieDM::removeRows(QModelIndexList rows, const QModelIndex & parent) //Build the list of items to be deleted //before actually deleting any item. QList names; - + size_t numSpecies = mpMetabolites->size(); for (const auto& index : rows) { - if (index.isValid() && !isDefaultRow(index)) + if (index.isValid() && !isDefaultRow(index) && index.row() < (int) mpMetabolites->size()) names.append(mpMetabolites->operator[](index.row()).getStringCN()); } - + for (auto& objectCn : names) { - CMetab* pSpecies = const_cast< CMetab* >( dynamic_cast (mpMetabolites->getObjectDataModel()->getObject(CRegisteredCommonName(objectCn)))); + CMetab* pSpecies = const_cast< CMetab* >(dynamic_cast (mpMetabolites->getObjectDataModel()->getObject(CRegisteredCommonName(objectCn)))); if (!pSpecies) continue; @@ -611,6 +611,6 @@ bool CQSpecieDM::removeRows(QModelIndexList rows, const QModelIndex & parent) removeRows(mpMetabolites->getIndex(pSpecies), 1); } } - + return true; } diff --git a/copasi/UI/CQSpeciesWidget.cpp b/copasi/UI/CQSpeciesWidget.cpp index 0836f85af9..32f91daba0 100644 --- a/copasi/UI/CQSpeciesWidget.cpp +++ b/copasi/UI/CQSpeciesWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 - 2024 by Pedro Mendes, Rector and Visitors of the +// Copyright (C) 2019 - 2025 by Pedro Mendes, Rector and Visitors of the // University of Virginia, University of Heidelberg, and University // of Connecticut School of Medicine. // All rights reserved. @@ -106,7 +106,6 @@ void CQSpeciesWidget::slotBtnDeleteClicked(bool needFocus) { if (!needFocus || mpTblSpecies->hasFocus()) {deleteSelectedSpecies();} - } void CQSpeciesWidget::deleteSelectedSpecies() @@ -127,6 +126,7 @@ void CQSpeciesWidget::deleteSelectedSpecies() {return;} mpSpecieDM->removeRows(mappedSelRows); + enterProtected(); } void CQSpeciesWidget::slotBtnClearClicked() @@ -138,7 +138,6 @@ void CQSpeciesWidget::slotBtnClearClicked() { mpSpecieDM->clear(); } - } bool CQSpeciesWidget::updateProtected(ListViews::ObjectType objectType, ListViews::Action action, const CRegisteredCommonName & cn) @@ -189,7 +188,6 @@ bool CQSpeciesWidget::enterProtected() return true; } - void CQSpeciesWidget::dataChanged(const QModelIndex &C_UNUSED(topLeft), const QModelIndex &C_UNUSED(bottomRight)) {