Spreadsheet: Add programmatic selection of cells

Implement modifying the current selection programmatically via the
ViewProvider object in both C++ and Python. This enables unit testing of
GUI tasks that require a selection, and improves scriptability of
Spreadsheet.
This commit is contained in:
Chris Hennes
2021-11-12 17:31:38 -06:00
parent 640ecca830
commit 37dbcf7f66
4 changed files with 50 additions and 0 deletions

View File

@@ -419,6 +419,16 @@ QModelIndexList SheetView::selectedIndexes() const
return ui->cells->selectionModel()->selectedIndexes();
}
void SpreadsheetGui::SheetView::select(App::CellAddress cell, QItemSelectionModel::SelectionFlags flags)
{
ui->cells->selectionModel()->select(model->index(cell.row(), cell.col()), flags);
}
void SpreadsheetGui::SheetView::select(App::CellAddress topLeft, App::CellAddress bottomRight, QItemSelectionModel::SelectionFlags flags)
{
ui->cells->selectionModel()->select(QItemSelection(model->index(topLeft.row(), topLeft.col()), model->index(bottomRight.row(), bottomRight.col())), flags);
}
void SheetView::deleteSelection()
{
ui->cells->deleteSelection();