1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:37:35 +00:00

Spreadsheet: Simplify enabling actions on selection

Since the function will *always* be called with some selection, we can
straight up enable actions.
This commit is contained in:
Karol Kosek 2022-02-27 11:40:55 +01:00 committed by Ali Mohammad Pur
parent f384aff510
commit 20dbbdf90c

View file

@ -274,10 +274,13 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
auto& sheet = *sheet_ptr;
VERIFY(!selection.is_empty());
m_cut_action->set_enabled(true);
m_copy_action->set_enabled(true);
m_current_cell_label->set_enabled(true);
m_cell_value_editor->set_enabled(true);
if (selection.size() == 1) {
auto& position = selection.first();
m_current_cell_label->set_enabled(true);
m_current_cell_label->set_text(position.to_cell_identifier(sheet));
auto& cell = sheet.ensure(position);
@ -292,9 +295,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
sheet.update();
update();
};
m_cell_value_editor->set_enabled(true);
m_cut_action->set_enabled(true);
m_copy_action->set_enabled(true);
static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(&cell);
return;
}
@ -302,7 +302,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
// There are many cells selected, change all of them.
StringBuilder builder;
builder.appendff("<{}>", selection.size());
m_current_cell_label->set_enabled(true);
m_current_cell_label->set_text(builder.string_view());
Vector<Cell&> cells;
@ -331,7 +330,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
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);
};
m_selected_view->on_selection_dropped = [&]() {