1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:47:34 +00:00

Everywhere: Replace Vector<T*> with nonnull entries with Vector<T&>

This commit is contained in:
Ali Mohammad Pur 2021-06-08 19:36:27 +04:30 committed by Andreas Kling
parent 3d94b5051d
commit 7ac196974d
22 changed files with 92 additions and 94 deletions

View file

@ -112,14 +112,14 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
for (auto& type_name : CellType::names())
g_types.append(type_name);
Vector<Cell*> cells;
Vector<Cell&> cells;
for (auto& position : positions) {
if (auto cell = sheet.at(position))
cells.append(cell);
cells.append(*cell);
}
if (cells.size() == 1) {
auto& cell = *cells.first();
auto& cell = cells.first();
m_format = cell.type_metadata().format;
m_length = cell.type_metadata().length;
m_type = &cell.type();

View file

@ -115,18 +115,18 @@ void Sheet::update()
return;
}
m_visited_cells_in_update.clear();
Vector<Cell*> cells_copy;
Vector<Cell&> cells_copy;
// Grab a copy as updates might insert cells into the table.
for (auto& it : m_cells) {
if (it.value->dirty()) {
cells_copy.append(it.value);
cells_copy.append(*it.value);
m_workbook.set_dirty(true);
}
}
for (auto& cell : cells_copy)
update(*cell);
update(cell);
m_visited_cells_in_update.clear();
}

View file

@ -171,11 +171,11 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
m_current_cell_label->set_enabled(true);
m_current_cell_label->set_text(builder.string_view());
Vector<Cell*> cells;
Vector<Cell&> cells;
for (auto& position : selection)
cells.append(&sheet.ensure(position));
cells.append(sheet.ensure(position));
auto first_cell = cells.first();
auto& first_cell = cells.first();
m_cell_value_editor->on_change = nullptr;
m_cell_value_editor->set_text("");
m_should_change_selected_cells = false;
@ -191,14 +191,14 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
// FIXME: Lines?
auto offset = m_cell_value_editor->cursor().column();
try_generate_tip_for_input_expression(text, offset);
for (auto* cell : cells)
cell->set_data(text);
for (auto& cell : cells)
cell.set_data(text);
sheet.update();
update();
}
};
m_cell_value_editor->set_enabled(true);
static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(first_cell);
static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(&first_cell);
};
m_selected_view->on_selection_dropped = [&]() {
m_cell_value_editor->set_enabled(false);