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:
parent
c5e5cd3b04
commit
a7fb35d93d
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -135,6 +135,7 @@ private:
|
|||
private:
|
||||
virtual void ItemInvoked();
|
||||
|
||||
void _UpdateRowIndices(int32 fromIndex);
|
||||
int32 _ModelIndexOfRow(BRow* row);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue