diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index 7e068bfe6c..67704fc6a6 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -33,6 +33,31 @@ #include #include +template +class RoleModel final : public GUI::ItemListModel { +public: + static ErrorOr> try_create(Vector const& data) + { + return adopt_nonnull_ref_or_enomem(new (nothrow) RoleModel(data)); + } + + virtual GUI::Variant data(GUI::ModelIndex const& index, GUI::ModelRole role) const override + { + if (role == GUI::ModelRole::Display) + return Gfx::to_string(this->m_data[index.row()]); + if (role == GUI::ModelRole::Custom) + return this->m_data[index.row()]; + + return GUI::ItemListModel::data(index, role); + } + +private: + explicit RoleModel(Vector const& data) + : GUI::ItemListModel(data) + { + } +}; + class ColorRoleModel final : public GUI::ItemListModel { public: explicit ColorRoleModel(Vector const& data)