diff --git a/Libraries/LibGUI/ModelIndex.cpp b/Libraries/LibGUI/ModelIndex.cpp index 1c31d3f3bf..982969f0c3 100644 --- a/Libraries/LibGUI/ModelIndex.cpp +++ b/Libraries/LibGUI/ModelIndex.cpp @@ -47,3 +47,17 @@ const LogStream& operator<<(const LogStream& stream, const ModelIndex& value) } } + +namespace AK { + +void Formatter::format(TypeErasedFormatParams& params, FormatBuilder& builder, const GUI::ModelIndex& value) +{ + Formatter formatter { *this }; + + if (value.internal_data()) + formatter.format(params, builder, String::formatted("ModelIndex({},{},{:p})", value.row(), value.column(), value.internal_data())); + else + formatter.format(params, builder, String::formatted("ModelIndex({},{})", value.row(), value.column())); +} + +} diff --git a/Libraries/LibGUI/ModelIndex.h b/Libraries/LibGUI/ModelIndex.h index 6c2c449f8f..222ea7f1b7 100644 --- a/Libraries/LibGUI/ModelIndex.h +++ b/Libraries/LibGUI/ModelIndex.h @@ -80,8 +80,15 @@ const LogStream& operator<<(const LogStream&, const ModelIndex&); } namespace AK { + +template<> +struct Formatter : Formatter { + void format(TypeErasedFormatParams&, FormatBuilder&, const GUI::ModelIndex&); +}; + template<> struct Traits : public GenericTraits { static unsigned hash(const GUI::ModelIndex& index) { return pair_int_hash(index.row(), index.column()); } }; + }