Skip to content


Browse files Browse the repository at this point in the history
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 5fbf5ca
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/MainWindow.cpp
Expand Up @@ -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);

Expand Down

0 comments on commit 5fbf5ca

Please sign in to comment.