1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:57:45 +00:00

LibGUI: Implement persistent indices for models

This patch adds persistent indices to models.  A PersistentModelIndex is
a ModelIndex that will survive most model updates (provided that the
data the PersistentModelIndex points to has not been removed by the
model's data store).  PersistentModelIndex objects can be safely held
by objects outside the model they originated from.
This commit is contained in:
sin-ack 2021-05-13 09:07:43 +00:00 committed by Andreas Kling
parent 1408aa1295
commit d73116e5d5
7 changed files with 221 additions and 1 deletions

View file

@ -77,7 +77,10 @@ struct Formatter<GUI::ModelIndex> : Formatter<FormatString> {
template<>
struct Traits<GUI::ModelIndex> : public GenericTraits<GUI::ModelIndex> {
static unsigned hash(const GUI::ModelIndex& index) { return pair_int_hash(index.row(), index.column()); }
static unsigned hash(const GUI::ModelIndex& index)
{
return pair_int_hash(pair_int_hash(index.row(), index.column()), reinterpret_cast<FlatPtr>(index.internal_data()));
}
};
}