1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

Spreadsheet: Get rid of the "row numbers" column

Let's use TableView's row headers for this instead. :^)
This commit is contained in:
Andreas Kling 2020-08-26 16:03:45 +02:00
parent 447b65bf7b
commit 695b283b8c
3 changed files with 10 additions and 26 deletions

View file

@ -38,10 +38,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
return {};
if (role == GUI::ModelRole::Display) {
if (index.column() == 0)
return String::number(index.row());
const auto* value = m_sheet->at({ m_sheet->column(index.column() - 1), (size_t)index.row() });
const auto* value = m_sheet->at({ m_sheet->column(index.column()), (size_t)index.row() });
if (!value)
return String::empty();
@ -51,12 +48,8 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
return value->data;
}
if (role == GUI::ModelRole::TextAlignment) {
if (index.column() == 0)
return {};
if (role == GUI::ModelRole::TextAlignment)
return {};
}
return {};
}
@ -66,10 +59,7 @@ String SheetModel::column_name(int index) const
if (index < 0)
return {};
if (index == 0)
return "";
return m_sheet->column(index - 1);
return m_sheet->column(index);
}
bool SheetModel::is_editable(const GUI::ModelIndex& index) const
@ -77,9 +67,6 @@ bool SheetModel::is_editable(const GUI::ModelIndex& index) const
if (!index.is_valid())
return false;
if (index.column() == 0)
return false;
return true;
}
@ -88,10 +75,7 @@ void SheetModel::set_data(const GUI::ModelIndex& index, const GUI::Variant& valu
if (!index.is_valid())
return;
if (index.column() == 0)
return;
auto& cell = m_sheet->ensure({ m_sheet->column(index.column() - 1), (size_t)index.row() });
auto& cell = m_sheet->ensure({ m_sheet->column(index.column()), (size_t)index.row() });
cell.set_data(value.to_string());
update();
}