Implement row insertion and deletion

This commit is contained in:
G.K.MacGregor
2020-10-27 15:17:54 +00:00
parent 01dcff944d
commit abba8127d9
4 changed files with 155 additions and 3 deletions

View File

@@ -324,6 +324,20 @@ void MainWindow::createActions()
*/
#endif // !QT_NO_CLIPBOARD
QAction *insertBlankRowAct = editMenu->addAction(tr("Insert blank row"));
insertBlankRowAct->setStatusTip(tr("Insert a blank row at the cursor position"));
connect(insertBlankRowAct, &QAction::triggered, [=]() { insertRow(false); } );
QAction *insertCopyRowAct = editMenu->addAction(tr("Insert copy row"));
insertCopyRowAct->setStatusTip(tr("Insert a row that's a copy of the row at the cursor position"));
connect(insertCopyRowAct, &QAction::triggered, [=]() { insertRow(true); } );
QAction *deleteRowAct = editMenu->addAction(tr("Delete row"));
deleteRowAct->setStatusTip(tr("Delete the row at the cursor position"));
connect(deleteRowAct, &QAction::triggered, this, &MainWindow::deleteRow);
editMenu->addSeparator();
QAction *insertBeforeAct = editMenu->addAction(tr("&Insert subpage before"));
insertBeforeAct->setStatusTip(tr("Insert a blank subpage before this subpage"));
connect(insertBeforeAct, &QAction::triggered, [=]() { insertSubPage(false, false); });
@@ -538,6 +552,20 @@ void MainWindow::setSceneDimensions()
}
}
void MainWindow::insertRow(bool copyRow)
{
if (m_textWidget->document()->cursorRow() == 24)
return;
QUndoCommand *insertRowCommand = new InsertRowCommand(m_textWidget->document(), copyRow);
m_textWidget->document()->undoStack()->push(insertRowCommand);
}
void MainWindow::deleteRow()
{
QUndoCommand *deleteRowCommand = new DeleteRowCommand(m_textWidget->document());
m_textWidget->document()->undoStack()->push(deleteRowCommand);
}
void MainWindow::insertSubPage(bool afterCurrentSubPage, bool copyCurrentSubPage)
{
QUndoCommand *insertSubPageCommand = new InsertSubPageCommand(m_textWidget->document(), afterCurrentSubPage, copyCurrentSubPage);