Do not ignore error when inserting rows in 'Duplicate record'

That avoids overwriting existing record as reported in issue #1255.

This doesn't improve the underlying situation, that is inserting empty rows
before duplicating the content. But it is safer to not ignore the error in
the initial row insertion.
This commit is contained in:
mgrojo
2017-12-10 15:34:05 +01:00
parent 5807c0be6b
commit 7ed1b1db05
3 changed files with 15 additions and 3 deletions

View File

@@ -192,7 +192,7 @@ void MainWindow::init()
connect(dittoRecordShortcut, &QShortcut::activated, [this]() {
int currentRow = ui->dataTable->currentIndex().row();
auto row = m_browseTableModel->dittoRecord(currentRow);
ui->dataTable->setCurrentIndex(row);
duplicateRecord(currentRow);
});
// Add menu item for log dock
@@ -2450,7 +2450,7 @@ void MainWindow::showRecordPopupMenu(const QPoint& pos)
popupRecordMenu.addAction(action);
connect(action, &QAction::triggered, [&]() {
m_browseTableModel->dittoRecord(row);
duplicateRecord(row);
});
popupRecordMenu.exec(ui->dataTable->verticalHeader()->mapToGlobal(pos));
@@ -2767,3 +2767,12 @@ void MainWindow::saveFilterAsView()
else
QMessageBox::information(this, qApp->applicationName(), tr("There is no filter set for this table. View will not be created."));
}
void MainWindow::duplicateRecord(int currentRow)
{
auto row = m_browseTableModel->dittoRecord(currentRow);
if (row.isValid())
ui->dataTable->setCurrentIndex(row);
else
QMessageBox::warning(this, qApp->applicationName(), db.lastError());
}