From 36f515309116c34ecaefc2ed9f49dbf1ba7d48b3 Mon Sep 17 00:00:00 2001 From: eelke Date: Sun, 18 Feb 2018 12:10:09 +0100 Subject: [PATCH] Only allow editing of tables that have a primary key. --- pglab/CrudModel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pglab/CrudModel.cpp b/pglab/CrudModel.cpp index 337782b..ded9fd6 100644 --- a/pglab/CrudModel.cpp +++ b/pglab/CrudModel.cpp @@ -205,7 +205,11 @@ void CrudModel::connectionStateChanged(ASyncDBConnection::State state) Qt::ItemFlags CrudModel::flags(const QModelIndex &) const { - return Qt::ItemIsSelectable + Qt::ItemIsEditable + Qt::ItemIsEnabled; + Qt::ItemFlags flags = Qt::ItemIsSelectable + Qt::ItemIsEnabled; + if (m_primaryKey) { + flags += Qt::ItemIsEditable; + } + return flags; } bool CrudModel::setData(const QModelIndex &index, const QVariant &value, int role)