Spreadsheet: Make cell metadata hint return String

This commit is contained in:
Karol Kosek 2023-06-03 23:43:15 +02:00 committed by Andreas Kling
parent 4836d33ae4
commit 9c923f20f4
Notes: sideshowbarker 2024-07-16 20:12:13 +09:00
10 changed files with 15 additions and 15 deletions

View file

@ -39,10 +39,10 @@ JS::ThrowCompletionOr<JS::Value> DateCell::js_value(Cell& cell, CellTypeMetadata
return JS::Value(value / 1000); // Turn it to seconds
}
DeprecatedString DateCell::metadata_hint(MetadataName metadata) const
String DateCell::metadata_hint(MetadataName metadata) const
{
if (metadata == MetadataName::Format)
return "Date format string as supported by `strftime'";
return "Date format string as supported by `strftime'"_string;
return {};
}

View file

@ -18,7 +18,7 @@ public:
virtual ~DateCell() override = default;
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
DeprecatedString metadata_hint(MetadataName) const override;
virtual String metadata_hint(MetadataName) const override;
};
}

View file

@ -30,12 +30,12 @@ JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, CellTypeMeta
return cell.js_data();
}
DeprecatedString IdentityCell::metadata_hint(MetadataName metadata) const
String IdentityCell::metadata_hint(MetadataName metadata) const
{
if (metadata == MetadataName::Length)
return "Ignored";
return "Ignored"_string;
if (metadata == MetadataName::Format)
return "JavaScript expression, `value' refers to the cell's value";
return "JavaScript expression, `value' refers to the cell's value"_string;
return {};
}

View file

@ -17,7 +17,7 @@ public:
virtual ~IdentityCell() override = default;
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
DeprecatedString metadata_hint(MetadataName) const override;
virtual String metadata_hint(MetadataName) const override;
};
}

View file

@ -43,10 +43,10 @@ JS::ThrowCompletionOr<JS::Value> NumericCell::js_value(Cell& cell, CellTypeMetad
});
}
DeprecatedString NumericCell::metadata_hint(MetadataName metadata) const
String NumericCell::metadata_hint(MetadataName metadata) const
{
if (metadata == MetadataName::Format)
return "Format string as accepted by `printf', all numeric formats refer to the same value (the cell's value)";
return "Format string as accepted by `printf', all numeric formats refer to the same value (the cell's value)"_string;
return {};
}

View file

@ -28,7 +28,7 @@ public:
virtual ~NumericCell() override = default;
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
DeprecatedString metadata_hint(MetadataName) const override;
virtual String metadata_hint(MetadataName) const override;
};
}

View file

@ -32,10 +32,10 @@ JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, CellTypeMetada
return JS::PrimitiveString::create(vm, string);
}
DeprecatedString StringCell::metadata_hint(MetadataName metadata) const
String StringCell::metadata_hint(MetadataName metadata) const
{
if (metadata == MetadataName::Format)
return "Ignored";
return "Ignored"_string;
return {};
}

View file

@ -17,7 +17,7 @@ public:
virtual ~StringCell() override = default;
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const override;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override;
DeprecatedString metadata_hint(MetadataName) const override;
virtual String metadata_hint(MetadataName) const override;
};
}

View file

@ -37,7 +37,7 @@ public:
virtual JS::ThrowCompletionOr<DeprecatedString> display(Cell&, CellTypeMetadata const&) const = 0;
virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const = 0;
virtual DeprecatedString metadata_hint(MetadataName) const { return {}; }
virtual String metadata_hint(MetadataName) const { return {}; }
virtual ~CellType() = default;
DeprecatedString const& name() const { return m_name; }

View file

@ -153,7 +153,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
m_type = CellType::get_by_name(g_types.at(index.row()));
if (auto* editor = right_side.find_descendant_of_type_named<GUI::TextEditor>("format_editor"))
editor->set_tooltip_deprecated(m_type->metadata_hint(MetadataName::Format));
editor->set_tooltip(m_type->metadata_hint(MetadataName::Format));
};
{