Separate finding of mosaics within selection

This commit is contained in:
Gavin MacGregor
2024-12-08 14:08:13 +00:00
parent cf4f85cc51
commit 900c2a79b2
2 changed files with 13 additions and 5 deletions

View File

@@ -391,17 +391,24 @@ void TeletextWidget::toggleCharacterBit(unsigned char bitToToggle)
m_teletextDocument->undoStack()->push(new ToggleMosaicBitCommand(m_teletextDocument, bitToToggle)); m_teletextDocument->undoStack()->push(new ToggleMosaicBitCommand(m_teletextDocument, bitToToggle));
} }
void TeletextWidget::shiftMosaics(int key) QSet<QPair<int, int>> TeletextWidget::findMosaics()
{ {
if (!m_teletextDocument->selectionActive()) QSet<QPair<int, int>> result;
return;
QSet<QPair<int, int>> mosaicList; if (!m_teletextDocument->selectionActive())
return result;
for (int r=m_teletextDocument->selectionTopRow(); r<=m_teletextDocument->selectionBottomRow(); r++) for (int r=m_teletextDocument->selectionTopRow(); r<=m_teletextDocument->selectionBottomRow(); r++)
for (int c=m_teletextDocument->selectionLeftColumn(); c<=m_teletextDocument->selectionRightColumn(); c++) for (int c=m_teletextDocument->selectionLeftColumn(); c<=m_teletextDocument->selectionRightColumn(); c++)
if (m_pageDecode.level1MosaicChar(r, c)) if (m_pageDecode.level1MosaicChar(r, c))
mosaicList.insert(qMakePair(r, c)); result.insert(qMakePair(r, c));
return result;
}
void TeletextWidget::shiftMosaics(int key)
{
const QSet<QPair<int, int>> mosaicList = findMosaics();
if (!mosaicList.isEmpty()) if (!mosaicList.isEmpty())
switch (key) { switch (key) {

View File

@@ -102,6 +102,7 @@ private:
int m_flashTiming, m_flashPhase; int m_flashTiming, m_flashPhase;
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
QSet<QPair<int, int>> findMosaics();
void shiftMosaics(int key); void shiftMosaics(int key);
void selectionToClipboard(); void selectionToClipboard();