Remove NotifyNodesCleared() again.
- For various reasons this one can be error prone, since it relies on the model being able to provide the correct row count, which won't be the case if the subclass calls it after having already removed all its nodes. - Optimize Table's RowsRemoved() similarly to TreeTable's for the remove all rows case.
This commit is contained in:
parent
01636e8f2a
commit
1d897b8a54
|
@ -124,17 +124,6 @@ TableModel::NotifyRowsChanged(int32 rowIndex, int32 count)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
TableModel::NotifyRowsCleared()
|
||||
{
|
||||
int32 listenerCount = fListeners.CountItems();
|
||||
for (int32 i = listenerCount - 1; i >= 0; i--) {
|
||||
TableModelListener* listener = fListeners.ItemAt(i);
|
||||
listener->TableRowsRemoved(this, 0, CountRows());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TableModel::NotifyTableModelReset()
|
||||
{
|
||||
|
@ -644,6 +633,12 @@ Table::TableRowsAdded(TableModel* model, int32 rowIndex, int32 count)
|
|||
void
|
||||
Table::TableRowsRemoved(TableModel* model, int32 rowIndex, int32 count)
|
||||
{
|
||||
if (rowIndex == 0 && count == fRows.CountItems()) {
|
||||
fRows.MakeEmpty();
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32 i = rowIndex + count - 1; i >= rowIndex; i--) {
|
||||
if (BRow* row = fRows.RemoveItemAt(i)) {
|
||||
RemoveRow(row);
|
||||
|
|
|
@ -52,7 +52,6 @@ protected:
|
|||
void NotifyRowsAdded(int32 rowIndex, int32 count);
|
||||
void NotifyRowsRemoved(int32 rowIndex, int32 count);
|
||||
void NotifyRowsChanged(int32 rowIndex, int32 count);
|
||||
void NotifyRowsCleared();
|
||||
void NotifyTableModelReset();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -233,18 +233,6 @@ TreeTableModel::NotifyNodesChanged(const TreeTablePath& path, int32 childIndex,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
TreeTableModel::NotifyNodesCleared()
|
||||
{
|
||||
int32 listenerCount = fListeners.CountItems();
|
||||
for (int32 i = listenerCount - 1; i >= 0; i--) {
|
||||
TreeTableModelListener* listener = fListeners.ItemAt(i);
|
||||
listener->TableNodesRemoved(this, TreeTablePath(), 0,
|
||||
CountChildren(Root()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeTableModel::NotifyTableModelReset()
|
||||
{
|
||||
|
|
|
@ -94,7 +94,6 @@ protected:
|
|||
int32 childIndex, int32 count);
|
||||
void NotifyNodesChanged(const TreeTablePath& path,
|
||||
int32 childIndex, int32 count);
|
||||
void NotifyNodesCleared();
|
||||
void NotifyTableModelReset();
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue