Disable editing of cells in views in Browse Data tab when not enabled

See issue #2091.
This commit is contained in:
Martin Kleusberg
2020-01-16 17:20:19 +01:00
parent a657d2bff6
commit 54866e1827

View File

@@ -744,7 +744,12 @@ void TableBrowser::updateRecordsetLabel()
}
ui->labelRecordset->setText(txt);
enableEditing(m_model->rowCountAvailable() != SqliteTableModel::RowCount::Unknown);
// Enable editing only for tables or views with editing unlocked for which the row count is already available
sqlb::ObjectIdentifier current_table = currentlyBrowsedTableName();
bool is_table_or_unlocked_view = !m_model->query().empty() && db->getObjectByName(current_table) && (
(db->getObjectByName(current_table)->type() == sqlb::Object::View && m_model->hasPseudoPk()) ||
(db->getObjectByName(current_table)->type() == sqlb::Object::Table));
enableEditing(m_model->rowCountAvailable() != SqliteTableModel::RowCount::Unknown && is_table_or_unlocked_view);
}
void TableBrowser::applySettings(const BrowseDataTableSettings& storedData, bool skipFilters)