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:
@@ -24,6 +24,11 @@ public:
|
|||||||
return fRowIndex;
|
return fRowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetRowIndex(int32 rowIndex)
|
||||||
|
{
|
||||||
|
fRowIndex = rowIndex;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32 fRowIndex;
|
int32 fRowIndex;
|
||||||
};
|
};
|
||||||
@@ -508,18 +513,27 @@ Table::TableRowsAdded(TableModel* model, int32 rowIndex, int32 count)
|
|||||||
|
|
||||||
AddRow(row, i);
|
AddRow(row, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// re-index the subsequent rows
|
||||||
|
_UpdateRowIndices(endRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Table::TableRowsRemoved(TableModel* model, int32 rowIndex, int32 count)
|
Table::TableRowsRemoved(TableModel* model, int32 rowIndex, int32 count)
|
||||||
{
|
{
|
||||||
|
int32 rowsRemoved = 0;
|
||||||
|
|
||||||
for (int32 i = rowIndex + count - 1; i >= rowIndex; i--) {
|
for (int32 i = rowIndex + count - 1; i >= rowIndex; i--) {
|
||||||
if (BRow* row = fRows.RemoveItemAt(i)) {
|
if (BRow* row = fRows.RemoveItemAt(i)) {
|
||||||
RemoveRow(row);
|
RemoveRow(row);
|
||||||
delete 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
|
int32
|
||||||
Table::_ModelIndexOfRow(BRow* row)
|
Table::_ModelIndexOfRow(BRow* row)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
virtual void ItemInvoked();
|
virtual void ItemInvoked();
|
||||||
|
|
||||||
|
void _UpdateRowIndices(int32 fromIndex);
|
||||||
int32 _ModelIndexOfRow(BRow* row);
|
int32 _ModelIndexOfRow(BRow* row);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user