1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

LibGUI: Add ModelIndex::data(ModelRole)

This is a convenience API that makes accessing model data easier.
This commit is contained in:
Andreas Kling 2020-08-16 16:02:01 +02:00
parent a1e381a0f8
commit f882424869
3 changed files with 16 additions and 2 deletions

View file

@ -28,6 +28,7 @@
#include <AK/Traits.h>
#include <LibGUI/Forward.h>
#include <LibGUI/ModelRole.h>
namespace GUI {
@ -35,7 +36,7 @@ class ModelIndex {
friend class Model;
public:
ModelIndex() {}
ModelIndex() { }
bool is_valid() const { return m_row != -1 && m_column != -1; }
int row() const { return m_row; }
@ -57,6 +58,8 @@ public:
const Model* model() const { return m_model; }
Variant data(ModelRole = ModelRole::Display) const;
private:
ModelIndex(const Model& model, int row, int column, void* internal_data)
: m_model(&model)