mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:17:35 +00:00
LibGUI: Move GUI::Model::Role to GUI::ModelRole
This is preparation for using ModelRole in the ModelIndex API.
This commit is contained in:
parent
f6d7204689
commit
a1e381a0f8
66 changed files with 201 additions and 167 deletions
|
@ -157,25 +157,25 @@ static Optional<ColorPair> color_pair_for(const InstructionData& insn)
|
|||
return ColorPair { background, foreground };
|
||||
}
|
||||
|
||||
GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
auto& insn = m_instructions[index.row()];
|
||||
|
||||
if (role == Role::BackgroundColor) {
|
||||
if (role == GUI::ModelRole::BackgroundColor) {
|
||||
auto colors = color_pair_for(insn);
|
||||
if (!colors.has_value())
|
||||
return {};
|
||||
return colors.value().background;
|
||||
}
|
||||
|
||||
if (role == Role::ForegroundColor) {
|
||||
if (role == GUI::ModelRole::ForegroundColor) {
|
||||
auto colors = color_pair_for(insn);
|
||||
if (!colors.has_value())
|
||||
return {};
|
||||
return colors.value().foreground;
|
||||
}
|
||||
|
||||
if (role == Role::Display) {
|
||||
if (role == GUI::ModelRole::Display) {
|
||||
if (index.column() == Column::SampleCount) {
|
||||
if (m_profile.show_percentages())
|
||||
return ((float)insn.event_count / (float)m_node.event_count()) * 100.0f;
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
|
||||
virtual String column_name(int) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
|
||||
virtual void update() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -108,14 +108,14 @@ String ProfileModel::column_name(int column) const
|
|||
}
|
||||
}
|
||||
|
||||
GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
auto* node = static_cast<ProfileNode*>(index.internal_data());
|
||||
if (role == Role::TextAlignment) {
|
||||
if (role == GUI::ModelRole::TextAlignment) {
|
||||
if (index.column() == Column::SampleCount || index.column() == Column::SelfCount)
|
||||
return Gfx::TextAlignment::CenterRight;
|
||||
}
|
||||
if (role == Role::Icon) {
|
||||
if (role == GUI::ModelRole::Icon) {
|
||||
if (index.column() == Column::StackFrame) {
|
||||
if (node->address() >= 0xc0000000)
|
||||
return m_kernel_frame_icon;
|
||||
|
@ -123,7 +123,7 @@ GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, Role role) const
|
|||
}
|
||||
return {};
|
||||
}
|
||||
if (role == Role::Display) {
|
||||
if (role == GUI::ModelRole::Display) {
|
||||
if (index.column() == Column::SampleCount) {
|
||||
if (m_profile.show_percentages())
|
||||
return ((float)node->event_count() / (float)m_profile.filtered_event_count()) * 100.0f;
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual String column_name(int) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
|
||||
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override;
|
||||
virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
|
||||
virtual void update() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue