Skip to content

Commit 5fbf5ca

Browse files
committed
Change label of "Delete record" button to reflect number of records
Change the label of the "Delete record" button in the Browse Data tab to "Delete records" when multiple records are selected. See issue #856.
1 parent 75d35c6 commit 5fbf5ca

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/MainWindow.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,24 @@ void MainWindow::populateTable()
462462
reconnectSelectionSignals = true;
463463
ui->dataTable->setModel(m_browseTableModel);
464464
if(reconnectSelectionSignals)
465+
{
465466
connect(ui->dataTable->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(dataTableSelectionChanged(QModelIndex)));
466467

468+
// Lambda function for updating the delete record button to reflect number of selected records
469+
connect(ui->dataTable->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection&, const QItemSelection&) {
470+
// NOTE: We're assuming here that the selection is always contiguous, i.e. that there are never two selected rows with a non-selected
471+
// row in between.
472+
int rows = 0;
473+
if(ui->dataTable->selectionModel()->selectedIndexes().count())
474+
rows = ui->dataTable->selectionModel()->selectedIndexes().last().row() - ui->dataTable->selectionModel()->selectedIndexes().first().row() + 1;
475+
476+
if(rows > 1)
477+
ui->buttonDeleteRecord->setText(tr("Delete records"));
478+
else
479+
ui->buttonDeleteRecord->setText(tr("Delete record"));
480+
});
481+
}
482+
467483
// Search stored table settings for this table
468484
bool storedDataFound = browseTableSettings.contains(tablename);
469485

0 commit comments

Comments
 (0)