mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +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:
parent
f384aff510
commit
20dbbdf90c
1 changed files with 4 additions and 6 deletions
|
@ -274,10 +274,13 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
||||||
auto& sheet = *sheet_ptr;
|
auto& sheet = *sheet_ptr;
|
||||||
|
|
||||||
VERIFY(!selection.is_empty());
|
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) {
|
if (selection.size() == 1) {
|
||||||
auto& position = selection.first();
|
auto& position = selection.first();
|
||||||
m_current_cell_label->set_enabled(true);
|
|
||||||
m_current_cell_label->set_text(position.to_cell_identifier(sheet));
|
m_current_cell_label->set_text(position.to_cell_identifier(sheet));
|
||||||
|
|
||||||
auto& cell = sheet.ensure(position);
|
auto& cell = sheet.ensure(position);
|
||||||
|
@ -292,9 +295,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
||||||
sheet.update();
|
sheet.update();
|
||||||
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);
|
static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(&cell);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
||||||
// There are many cells selected, change all of them.
|
// There are many cells selected, change all of them.
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.appendff("<{}>", selection.size());
|
builder.appendff("<{}>", selection.size());
|
||||||
m_current_cell_label->set_enabled(true);
|
|
||||||
m_current_cell_label->set_text(builder.string_view());
|
m_current_cell_label->set_text(builder.string_view());
|
||||||
|
|
||||||
Vector<Cell&> cells;
|
Vector<Cell&> cells;
|
||||||
|
@ -331,7 +330,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
||||||
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_selected_view->on_selection_dropped = [&]() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue