Fix model/view bug: do not delete all rows when deleting in a filtered view

This commit is contained in:
Klaus Basan
2018-03-31 00:37:00 +02:00
parent 63e5f75a1d
commit 37814d3f08

View File

@@ -1070,21 +1070,21 @@ namespace BlackGui
if (this->isEmpty()) { return 0; } if (this->isEmpty()) { return 0; }
const int currentRows = this->rowCount(); const int currentRows = this->rowCount();
if (currentRows == selectedRowCount()) if (!this->hasFilter() && currentRows == this->selectedRowCount())
{ {
this->clear(); // shortcut if all are selected
this->clear(); // clear all
return currentRows; return currentRows;
} }
const ContainerType selected(selectedObjects()); const ContainerType selected(selectedObjects());
ContainerType newObjects(container()); ContainerType unselectedObjects(container());
for (const ObjectType &obj : selected) for (const ObjectType &obj : selected)
{ {
newObjects.remove(obj); unselectedObjects.remove(obj);
} }
const int delta = currentRows - unselectedObjects.size();
const int delta = currentRows - newObjects.size(); this->updateContainerMaybeAsync(unselectedObjects);
this->updateContainerMaybeAsync(newObjects);
return delta; return delta;
} }