UI: TableView: Set current cell on select-all

This commit is contained in:
Nodir Temirkhodjaev 2024-01-12 16:59:26 +03:00
parent 704be268cb
commit 9151d882cf
2 changed files with 14 additions and 0 deletions

View File

@ -88,6 +88,18 @@ void TableView::selectCell(int row, int column)
this->scrollTo(index); this->scrollTo(index);
} }
void TableView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
QTableView::selectionChanged(selected, deselected);
if (selected.isEmpty())
return;
if (!currentIndex().isValid()) {
setCurrentIndex(selected.indexes().first());
}
}
void TableView::currentChanged(const QModelIndex &current, const QModelIndex &previous) void TableView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{ {
QTableView::currentChanged(current, previous); QTableView::currentChanged(current, previous);

View File

@ -28,6 +28,8 @@ public slots:
void selectCell(int row, int column = 0); void selectCell(int row, int column = 0);
protected: protected:
void selectionChanged(
const QItemSelection &selected, const QItemSelection &deselected) override;
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override; void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
void contextMenuEvent(QContextMenuEvent *event) override; void contextMenuEvent(QContextMenuEvent *event) override;