When rows are added to/removed from the model, we need to adjust the row

indices we store in the fields of subsequent BRows. Fixes the broken threads
list in Debugger (should be some ticket -- can't access Trac ATM).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33539 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-10-12 03:14:34 +00:00
parent c5e5cd3b04
commit a7fb35d93d
2 changed files with 28 additions and 0 deletions

View File

@ -24,6 +24,11 @@ public:
return fRowIndex;
}
void SetRowIndex(int32 rowIndex)
{
fRowIndex = rowIndex;
}
private:
int32 fRowIndex;
};
@ -508,18 +513,27 @@ Table::TableRowsAdded(TableModel* model, int32 rowIndex, int32 count)
AddRow(row, i);
}
// re-index the subsequent rows
_UpdateRowIndices(endRow);
}
void
Table::TableRowsRemoved(TableModel* model, int32 rowIndex, int32 count)
{
int32 rowsRemoved = 0;
for (int32 i = rowIndex + count - 1; i >= rowIndex; i--) {
if (BRow* row = fRows.RemoveItemAt(i)) {
RemoveRow(row);
delete row;
rowsRemoved++;
}
}
// re-index the subsequent rows
_UpdateRowIndices(rowIndex);
}
@ -550,6 +564,19 @@ Table::ItemInvoked()
}
void
Table::_UpdateRowIndices(int32 fromIndex)
{
for (int32 i = fromIndex; BRow* row = fRows.ItemAt(i); i++) {
for (int32 k = 0;
TableField* field = dynamic_cast<TableField*>(row->GetField(k));
k++) {
field->SetRowIndex(i);
}
}
}
int32
Table::_ModelIndexOfRow(BRow* row)
{

View File

@ -135,6 +135,7 @@ private:
private:
virtual void ItemInvoked();
void _UpdateRowIndices(int32 fromIndex);
int32 _ModelIndexOfRow(BRow* row);
private: