mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGUI: Add formatter for ModelIndex.
This commit is contained in:
parent
a7533eb29c
commit
93d04b9f8d
Notes:
sideshowbarker
2024-07-19 02:01:31 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/93d04b9f8db Pull-request: https://github.com/SerenityOS/serenity/pull/3696 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/emanuele6
2 changed files with 21 additions and 0 deletions
|
@ -47,3 +47,17 @@ const LogStream& operator<<(const LogStream& stream, const ModelIndex& value)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
void Formatter<GUI::ModelIndex>::format(TypeErasedFormatParams& params, FormatBuilder& builder, const GUI::ModelIndex& value)
|
||||
{
|
||||
Formatter<StringView> 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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,8 +80,15 @@ const LogStream& operator<<(const LogStream&, const ModelIndex&);
|
|||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<>
|
||||
struct Formatter<GUI::ModelIndex> : Formatter<StringView> {
|
||||
void format(TypeErasedFormatParams&, FormatBuilder&, const GUI::ModelIndex&);
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Traits<GUI::ModelIndex> : public GenericTraits<GUI::ModelIndex> {
|
||||
static unsigned hash(const GUI::ModelIndex& index) { return pair_int_hash(index.row(), index.column()); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue