mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-06 20:09:54 -05:00
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:
+11
-2
@@ -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());
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ private:
|
||||
void enableEditing(bool enable_edit, bool enable_insertdelete);
|
||||
void loadExtensionsFromSettings();
|
||||
void saveAsView(QString query);
|
||||
void duplicateRecord(int currentRow);
|
||||
|
||||
sqlb::ObjectIdentifier currentlyBrowsedTableName() const;
|
||||
|
||||
|
||||
@@ -512,7 +512,9 @@ QModelIndex SqliteTableModel::dittoRecord(int old_row)
|
||||
if(!isEditable())
|
||||
return QModelIndex();
|
||||
|
||||
insertRow(rowCount());
|
||||
if (!insertRow(rowCount()))
|
||||
return QModelIndex();
|
||||
|
||||
int firstEditedColumn = 0;
|
||||
int new_row = rowCount() - 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user