CrudModel::removeRows now works for count > 1

This allows for efficient removal of blocks of rows. If you would remove
row by row the repeated beginRemoveRows and endRemoveRows calls will generate
additional overhead.
This commit is contained in:
eelke 2018-12-08 13:55:43 +01:00
parent 266e479344
commit 255b2ec970
2 changed files with 88 additions and 47 deletions

View file

@ -297,18 +297,25 @@ private:
/// \return The values of the primary key column. If this is a new row it will return an empty list
///
PKeyValues getPKeyForRow(int row) const;
Pgsql::Params getPKeyParamsForRow(int row) const;
bool savePendingChanges();
std::tuple<QString, Pgsql::Params> createUpdateQuery(const PKeyValues &pkey_values, const PendingRow &pending_row);
std::tuple<QString, Pgsql::Params> createInsertQuery(const PendingRow &pending_row);
std::tuple<QString, Pgsql::Params> createDeleteStatement(const PKeyValues &pkey_values);
QString createDeleteStatement() const;
std::tuple<bool, ModifiedRow> updateRow(const PendingRow &pending_row);
void appendNewRow();
int lastRowKey = 0;
int allocNewRowKey() { return ++lastRowKey; }
/// Convert an attnum from the database catalog to the corresponding column in the model
///
/// \todo still assumes columns are in order, all being shown and no special column like oid shown.
int attNumToCol(int attnum) const { return attnum - 1; }
private slots:
void connectionStateChanged(ASyncDBConnection::State state);