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:
Rene Gollent 2013-05-15 20:12:28 -04:00
parent 01636e8f2a
commit 1d897b8a54
4 changed files with 6 additions and 25 deletions

View File

@ -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);

View File

@ -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:

View File

@ -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()
{

View File

@ -94,7 +94,6 @@ protected:
int32 childIndex, int32 count);
void NotifyNodesChanged(const TreeTablePath& path,
int32 childIndex, int32 count);
void NotifyNodesCleared();
void NotifyTableModelReset();
protected: