diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-21 19:36:09 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-21 19:55:44 +0200 |
commit | 2e03bded43344d4dd2d4f19d4d963646aaa77e40 (patch) | |
tree | 28f044c3485c240307abb8c289cbdb28831dfb80 /DevTools | |
parent | 3c819b8ff4d8c1cefceeb65ee0e89e3858a11bb5 (diff) | |
download | serenity-2e03bded43344d4dd2d4f19d4d963646aaa77e40.zip |
LibGUI: Add Model::Role::TextAlignment and remove from ColumnMetadata
Diffstat (limited to 'DevTools')
-rw-r--r-- | DevTools/HackStudio/FindInFilesWidget.cpp | 10 | ||||
-rw-r--r-- | DevTools/ProfileViewer/DisassemblyModel.cpp | 7 | ||||
-rw-r--r-- | DevTools/ProfileViewer/DisassemblyModel.h | 1 | ||||
-rw-r--r-- | DevTools/ProfileViewer/ProfileModel.cpp | 11 | ||||
-rw-r--r-- | DevTools/ProfileViewer/ProfileModel.h | 1 | ||||
-rw-r--r-- | DevTools/VisualBuilder/VBWidgetPropertyModel.cpp | 7 |
6 files changed, 11 insertions, 26 deletions
diff --git a/DevTools/HackStudio/FindInFilesWidget.cpp b/DevTools/HackStudio/FindInFilesWidget.cpp index af9adf1361..966865eeb0 100644 --- a/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/DevTools/HackStudio/FindInFilesWidget.cpp @@ -75,6 +75,8 @@ public: virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override { + if (role == Role::TextAlignment) + return Gfx::TextAlignment::CenterLeft; if (role == Role::Font) { if (index.column() == Column::MatchedText) return Gfx::Font::default_fixed_width_font(); @@ -94,14 +96,6 @@ public: return {}; } - virtual ColumnMetadata column_metadata(int column) const override - { - if (column == Column::MatchedText) { - return { 0, Gfx::TextAlignment::CenterLeft }; - } - return {}; - } - virtual void update() override { } virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override { return create_index(row, column, &m_matches.at(row)); } diff --git a/DevTools/ProfileViewer/DisassemblyModel.cpp b/DevTools/ProfileViewer/DisassemblyModel.cpp index 4807a1207a..3386ba946d 100644 --- a/DevTools/ProfileViewer/DisassemblyModel.cpp +++ b/DevTools/ProfileViewer/DisassemblyModel.cpp @@ -138,13 +138,6 @@ String DisassemblyModel::column_name(int column) const } } -GUI::Model::ColumnMetadata DisassemblyModel::column_metadata(int column) const -{ - if (column == Column::SampleCount) - return ColumnMetadata { 0, Gfx::TextAlignment::CenterRight }; - return {}; -} - struct ColorPair { Color background; Color foreground; diff --git a/DevTools/ProfileViewer/DisassemblyModel.h b/DevTools/ProfileViewer/DisassemblyModel.h index de45415f8d..499a980997 100644 --- a/DevTools/ProfileViewer/DisassemblyModel.h +++ b/DevTools/ProfileViewer/DisassemblyModel.h @@ -61,7 +61,6 @@ 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 ColumnMetadata column_metadata(int) const override; virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; diff --git a/DevTools/ProfileViewer/ProfileModel.cpp b/DevTools/ProfileViewer/ProfileModel.cpp index fa77ac2a73..1d628e66c0 100644 --- a/DevTools/ProfileViewer/ProfileModel.cpp +++ b/DevTools/ProfileViewer/ProfileModel.cpp @@ -108,16 +108,13 @@ String ProfileModel::column_name(int column) const } } -GUI::Model::ColumnMetadata ProfileModel::column_metadata(int column) const -{ - if (column == Column::SampleCount || column == Column::SelfCount) - return ColumnMetadata { 0, Gfx::TextAlignment::CenterRight }; - return {}; -} - GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, Role role) const { auto* node = static_cast<ProfileNode*>(index.internal_data()); + if (role == Role::TextAlignment) { + if (index.column() == Column::SampleCount || index.column() == Column::SelfCount) + return Gfx::TextAlignment::CenterRight; + } if (role == Role::Icon) { if (index.column() == Column::StackFrame) { if (node->address() >= 0xc0000000) diff --git a/DevTools/ProfileViewer/ProfileModel.h b/DevTools/ProfileViewer/ProfileModel.h index 9e816ec2ea..a25520ec3c 100644 --- a/DevTools/ProfileViewer/ProfileModel.h +++ b/DevTools/ProfileViewer/ProfileModel.h @@ -50,7 +50,6 @@ 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 ColumnMetadata column_metadata(int) const override; virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) 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; diff --git a/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp b/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp index d871780602..d59ffdf615 100644 --- a/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp +++ b/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp @@ -61,12 +61,15 @@ GUI::Model::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) co { UNUSED_PARAM(column); if (column == Column::Name) - return { 110, Gfx::TextAlignment::CenterLeft }; - return { 90, Gfx::TextAlignment::CenterLeft }; + return { 110 }; + return { 90 }; } GUI::Variant VBWidgetPropertyModel::data(const GUI::ModelIndex& index, Role role) const { + if (role == Role::TextAlignment) { + return Gfx::TextAlignment::CenterLeft; + } if (role == Role::Font) { if (index.column() == Column::Name) return Gfx::Font::default_bold_font(); |