Removing redundant data from DataTable.Row

This commit is contained in:
Darren Burns
2023-01-26 14:05:31 +00:00
parent 297119d9b6
commit aee100ff10
3 changed files with 174 additions and 183 deletions

View File

@@ -117,7 +117,6 @@ class Row:
key: RowKey
height: int
y: int
cell_renderables: list[RenderableType] = field(default_factory=list)
@@ -606,13 +605,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
column.key: cell
for column, cell in zip_longest(self._ordered_columns, cells)
}
self.rows[row_key] = Row(row_key, height, self._line_no)
# for line_no in range(height):
# self._y_offsets.append((row_key, line_no))
self._line_no += height
self.rows[row_key] = Row(row_key, height)
self._new_rows.add(row_index)
self._require_update_dimensions = True
self.cursor_cell = self.cursor_cell
@@ -754,7 +747,6 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
# Ensure we order the cells in the row based on current column ordering
row_key = self._row_locations.get_key(row_index)
cell_mapping: dict[ColumnKey, CellType] = self.data.get(row_key)
print(row_index, cell_mapping.values())
ordered_row: list[CellType] = []
for column in ordered_columns:
@@ -823,7 +815,6 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
style += Style.from_meta({"row": row_index, "column": column_index})
height = self.header_height if is_header_row else self.rows[row_key].height
cell = self._get_row_renderables(row_index)[column_index]
print(f"CELL = {cell}")
lines = self.app.console.render_lines(
Padding(cell, (0, 1)),
self.app.console.options.update_dimensions(width, height),

File diff suppressed because one or more lines are too long

View File

@@ -165,7 +165,7 @@ async def test_add_rows_user_defined_keys():
third_row = {key_a: ROWS[2][0], key_b: ROWS[2][1]}
assert table.data[auto_key] == third_row
first_row = Row(algernon_key, height=1, y=0)
first_row = Row(algernon_key, height=1)
assert table.rows[algernon_key] == first_row
assert table.rows["algernon"] == first_row