Allow header row editing

This commit is contained in:
Gavin MacGregor
2025-03-18 14:48:03 +00:00
parent 1d462f4355
commit 0493f0e270
8 changed files with 89 additions and 15 deletions

View File

@@ -68,6 +68,7 @@ TeletextDocument::TeletextDocument()
m_undoStack = new QUndoStack(this);
m_cursorRow = 1;
m_cursorColumn = 0;
m_rowZeroAllowed = false;
m_selectionCornerRow = m_selectionCornerColumn = -1;
m_selectionSubPage = nullptr;
@@ -252,7 +253,7 @@ void TeletextDocument::cursorUp(bool shiftKey)
if (shiftKey && !selectionActive())
setSelectionCorner(m_cursorRow, m_cursorColumn);
if (--m_cursorRow == 0)
if (--m_cursorRow == 0 - (int)m_rowZeroAllowed)
m_cursorRow = 24;
if (shiftKey)
@@ -269,7 +270,7 @@ void TeletextDocument::cursorDown(bool shiftKey)
setSelectionCorner(m_cursorRow, m_cursorColumn);
if (++m_cursorRow == 25)
m_cursorRow = 1;
m_cursorRow = (int)!m_rowZeroAllowed;
if (shiftKey)
emit selectionMoved();
@@ -333,6 +334,13 @@ void TeletextDocument::moveCursor(int cursorRow, int cursorColumn, bool selectio
emit cursorMoved();
}
void TeletextDocument::setRowZeroAllowed(bool allowed)
{
m_rowZeroAllowed = allowed;
if (m_cursorRow == 0 && !allowed)
cursorDown();
}
void TeletextDocument::setSelectionCorner(int row, int column)
{
if (m_selectionCornerRow != row || m_selectionCornerColumn != column) {