File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3571,7 +3571,7 @@ void MainWindow::updateInsertDeleteRecordButton()
35713571 // at least one row to be selected. For the insert button there is an extra rule to disable it when we are browsing a view because inserting
35723572 // into a view isn't supported yet.
35733573 bool isEditable = m_browseTableModel->isEditable () && !db.readOnly ();
3574- ui->buttonNewRecord ->setEnabled (isEditable && m_browseTableModel->pseudoPk (). isEmpty ());
3574+ ui->buttonNewRecord ->setEnabled (isEditable && ! m_browseTableModel->hasPseudoPk ());
35753575 ui->buttonDeleteRecord ->setEnabled (isEditable && rows != 0 );
35763576
35773577 if (rows > 1 )
Original file line number Diff line number Diff line change @@ -159,10 +159,8 @@ void SqliteTableModel::setQuery(const sqlb::Query& query)
159159 if (!allOk)
160160 {
161161 QString sColumnQuery = QString::fromUtf8 (" SELECT * FROM %1;" ).arg (query.table ().toString ());
162- if (pseudoPk ().isEmpty ())
162+ if (m_query. rowIdColumn ().empty ())
163163 m_query.setRowIdColumn (" rowid" );
164- else
165- m_query.setRowIdColumn (pseudoPk ().toStdString ());
166164 m_headers.push_back (" rowid" );
167165 m_headers.append (getColumns (nullptr , sColumnQuery , m_vDataTypes));
168166 }
@@ -803,6 +801,11 @@ void SqliteTableModel::setPseudoPk(const QString& pseudoPk)
803801 buildQuery ();
804802}
805803
804+ bool SqliteTableModel::hasPseudoPk () const
805+ {
806+ return !(m_query.rowIdColumn () == " rowid" || m_query.rowIdColumn () == " _rowid_" );
807+ }
808+
806809bool SqliteTableModel::isEditable () const
807810{
808811 return !m_query.table ().isEmpty () &&
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ class SqliteTableModel : public QAbstractTableModel
9898
9999 // The pseudo-primary key is exclusively for editing views
100100 void setPseudoPk (const QString& pseudoPk);
101+ bool hasPseudoPk () const ;
101102 QString pseudoPk () const { return QString::fromStdString (m_query.rowIdColumn ()); }
102103
103104 sqlb::ForeignKeyClause getForeignKeyClause (int column) const ;
You can’t perform that action at this time.
0 commit comments