QSqlQueryModel: suppress insert and remove signals while resetting
There is no need to emit signals for inserting and removing rows and columns while resetting the model. Suppress these signals in such a way that subclasses can benefit without worrying about it. Change-Id: I04447c87173be54a7323b97608cdd40ae245b80b Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
c194b7f345
commit
a3963d8bbc
@ -78,11 +78,9 @@ void QSqlQueryModelPrivate::prefetch(int limit)
|
||||
atEnd = true; // this is the end.
|
||||
}
|
||||
if (newBottom.row() >= 0 && newBottom.row() > bottom.row()) {
|
||||
if (!nestedResetLevel)
|
||||
q->beginInsertRows(QModelIndex(), bottom.row() + 1, newBottom.row());
|
||||
q->beginInsertRows(QModelIndex(), bottom.row() + 1, newBottom.row());
|
||||
bottom = newBottom;
|
||||
if (!nestedResetLevel)
|
||||
q->endInsertRows();
|
||||
q->endInsertRows();
|
||||
} else {
|
||||
bottom = newBottom;
|
||||
}
|
||||
@ -210,6 +208,78 @@ bool QSqlQueryModel::canFetchMore(const QModelIndex &parent) const
|
||||
return (!parent.isValid() && !d->atEnd);
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::beginInsertRows(const QModelIndex &parent, int first, int last)
|
||||
{
|
||||
Q_D(QSqlQueryModel);
|
||||
if (!d->nestedResetLevel)
|
||||
QAbstractTableModel::beginInsertRows(parent, first, last);
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::endInsertRows()
|
||||
{
|
||||
Q_D(QSqlQueryModel);
|
||||
if (!d->nestedResetLevel)
|
||||
QAbstractTableModel::endInsertRows();
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::beginRemoveRows(const QModelIndex &parent, int first, int last)
|
||||
{
|
||||
Q_D(QSqlQueryModel);
|
||||
if (!d->nestedResetLevel)
|
||||
QAbstractTableModel::beginRemoveRows(parent, first, last);
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::endRemoveRows()
|
||||
{
|
||||
Q_D(QSqlQueryModel);
|
||||
if (!d->nestedResetLevel)
|
||||
QAbstractTableModel::endRemoveRows();
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::beginInsertColumns(const QModelIndex &parent, int first, int last)
|
||||
{
|
||||
Q_D(QSqlQueryModel);
|
||||
if (!d->nestedResetLevel)
|
||||
QAbstractTableModel::beginInsertColumns(parent, first, last);
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::endInsertColumns()
|
||||
{
|
||||
Q_D(QSqlQueryModel);
|
||||
if (!d->nestedResetLevel)
|
||||
QAbstractTableModel::endInsertColumns();
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::beginRemoveColumns(const QModelIndex &parent, int first, int last)
|
||||
{
|
||||
Q_D(QSqlQueryModel);
|
||||
if (!d->nestedResetLevel)
|
||||
QAbstractTableModel::beginRemoveColumns(parent, first, last);
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::endRemoveColumns()
|
||||
{
|
||||
Q_D(QSqlQueryModel);
|
||||
if (!d->nestedResetLevel)
|
||||
QAbstractTableModel::endRemoveColumns();
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::beginResetModel()
|
||||
|
@ -90,6 +90,18 @@ public:
|
||||
bool canFetchMore(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
protected:
|
||||
void beginInsertRows(const QModelIndex &parent, int first, int last);
|
||||
void endInsertRows();
|
||||
|
||||
void beginRemoveRows(const QModelIndex &parent, int first, int last);
|
||||
void endRemoveRows();
|
||||
|
||||
void beginInsertColumns(const QModelIndex &parent, int first, int last);
|
||||
void endInsertColumns();
|
||||
|
||||
void beginRemoveColumns(const QModelIndex &parent, int first, int last);
|
||||
void endRemoveColumns();
|
||||
|
||||
void beginResetModel();
|
||||
void endResetModel();
|
||||
virtual void queryChange();
|
||||
|
Loading…
Reference in New Issue
Block a user