Always debounce modelDirty() with dirty() timer.

Took 29 minutes

Took 3 minutes
This commit is contained in:
Lukas Brübach 2026-04-30 15:05:34 +02:00
parent 78a8f9104d
commit 97d3843501
3 changed files with 11 additions and 16 deletions

View file

@ -10,7 +10,10 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
setSortCaseSensitivity(Qt::CaseInsensitive);
dirtyTimer.setSingleShot(true);
connect(&dirtyTimer, &QTimer::timeout, this, &CardDatabaseDisplayModel::invalidate);
connect(&dirtyTimer, &QTimer::timeout, this, [this]() {
invalidate();
emit modelDirty();
});
loadedRowCount = 0;
}
@ -19,13 +22,9 @@ void CardDatabaseDisplayModel::setSourceModel(QAbstractItemModel *model)
{
QSortFilterProxyModel::setSourceModel(model);
connect(model, &QAbstractItemModel::rowsInserted, this, [this]() {
dirty();
});
connect(model, &QAbstractItemModel::rowsInserted, this, [this]() { dirty(); });
connect(model, &QAbstractItemModel::rowsRemoved, this, [this]() {
dirty();
});
connect(model, &QAbstractItemModel::rowsRemoved, this, [this]() { dirty(); });
connect(model, &QAbstractItemModel::modelReset, this, [this]() {
loadedRowCount = 0;