Add missing optimisation when deleting triplet

This commit is contained in:
G.K.MacGregor
2021-09-09 17:18:15 +01:00
parent 64943f01c5
commit b921d14dbf

View File

@@ -127,12 +127,18 @@ DeleteTripletCommand::DeleteTripletCommand(TeletextDocument *teletextDocument, X
void DeleteTripletCommand::redo() void DeleteTripletCommand::redo()
{ {
bool changingSubPage = (m_teletextDocument->currentSubPageIndex() != m_subPageIndex);
if (changingSubPage) {
m_teletextDocument->emit aboutToChangeSubPage(); m_teletextDocument->emit aboutToChangeSubPage();
m_teletextDocument->selectSubPageIndex(m_subPageIndex); m_teletextDocument->selectSubPageIndex(m_subPageIndex);
} else
m_x26Model->beginRemoveRows(QModelIndex(), m_row, m_row+m_count-1); m_x26Model->beginRemoveRows(QModelIndex(), m_row, m_row+m_count-1);
for (int i=0; i<m_count; i++) for (int i=0; i<m_count; i++)
m_teletextDocument->currentSubPage()->enhancements()->removeAt(m_row); m_teletextDocument->currentSubPage()->enhancements()->removeAt(m_row);
if (!changingSubPage)
m_x26Model->endRemoveRows(); m_x26Model->endRemoveRows();
// Preserve pointers to local object definitions that have moved // Preserve pointers to local object definitions that have moved
@@ -146,7 +152,10 @@ void DeleteTripletCommand::redo()
} }
} }
if (changingSubPage)
m_teletextDocument->emit subPageSelected(); m_teletextDocument->emit subPageSelected();
else
m_teletextDocument->emit refreshNeeded();
} }
void DeleteTripletCommand::undo() void DeleteTripletCommand::undo()