From b90286b43d2ad4e99554e8b198aa7f5de220e8d4 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 24 Dec 2020 15:55:48 -0500 Subject: [PATCH] Add support for only clearing selected atoms Signed-off-by: Geoff Hutchison --- avogadro/qtplugins/copypaste/copypaste.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/avogadro/qtplugins/copypaste/copypaste.cpp b/avogadro/qtplugins/copypaste/copypaste.cpp index 50d47ddf5d..3903f6f1c7 100644 --- a/avogadro/qtplugins/copypaste/copypaste.cpp +++ b/avogadro/qtplugins/copypaste/copypaste.cpp @@ -129,7 +129,13 @@ void CopyPaste::cut() void CopyPaste::clear() { - m_molecule->undoMolecule()->clearAtoms(); + if (m_molecule->isSelectionEmpty()) + m_molecule->undoMolecule()->clearAtoms(); + else { + for (Index i = 0; i < m_molecule->atomCount(); ++i) + if (m_molecule->atomSelected(i)) + m_molecule->undoMolecule()->removeAtom(i); + } m_molecule->emitChanged(QtGui::Molecule::Atoms | QtGui::Molecule::Bonds | QtGui::Molecule::Removed); }