diff --git a/src/apps/debuganalyzer/gui/table/Table.cpp b/src/apps/debuganalyzer/gui/table/Table.cpp index fd37a385df..b7773f37b2 100644 --- a/src/apps/debuganalyzer/gui/table/Table.cpp +++ b/src/apps/debuganalyzer/gui/table/Table.cpp @@ -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(row->GetField(k)); + k++) { + field->SetRowIndex(i); + } + } +} + + int32 Table::_ModelIndexOfRow(BRow* row) { diff --git a/src/apps/debuganalyzer/gui/table/Table.h b/src/apps/debuganalyzer/gui/table/Table.h index cd734517ff..57901c713b 100644 --- a/src/apps/debuganalyzer/gui/table/Table.h +++ b/src/apps/debuganalyzer/gui/table/Table.h @@ -135,6 +135,7 @@ private: private: virtual void ItemInvoked(); + void _UpdateRowIndices(int32 fromIndex); int32 _ModelIndexOfRow(BRow* row); private: