Skip to content
Browse files
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.
  • Loading branch information
MKleusberg committed Nov 17, 2017
1 parent 75d35c6 commit 5fbf5ca1b28373323591f05a339f18b58e9c283c
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/MainWindow.cpp
@@ -462,8 +462,24 @@ void MainWindow::populateTable()
reconnectSelectionSignals = true;
connect(ui->dataTable->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(dataTableSelectionChanged(QModelIndex)));

// Lambda function for updating the delete record button to reflect number of selected records
connect(ui->dataTable->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection&, const QItemSelection&) {
// NOTE: We're assuming here that the selection is always contiguous, i.e. that there are never two selected rows with a non-selected
// row in between.
int rows = 0;
rows = ui->dataTable->selectionModel()->selectedIndexes().last().row() - ui->dataTable->selectionModel()->selectedIndexes().first().row() + 1;

if(rows > 1)
ui->buttonDeleteRecord->setText(tr("Delete records"));
ui->buttonDeleteRecord->setText(tr("Delete record"));

// Search stored table settings for this table
bool storedDataFound = browseTableSettings.contains(tablename);

0 comments on commit 5fbf5ca

Please sign in to comment.