mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 18:15:09 +00:00
LibGUI: Expand GModelIndex a bit, adding internal data and model pointers.
This will be useful for implementing more complicated models.
This commit is contained in:
parent
12ec55ee74
commit
d02238af48
10 changed files with 94 additions and 34 deletions
|
@ -1,9 +1,44 @@
|
|||
#include <LibGUI/GTreeView.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
|
||||
class TestModel : public GModel {
|
||||
public:
|
||||
static Retained<TestModel> create() { return adopt(*new TestModel); }
|
||||
|
||||
virtual int row_count(const GModelIndex& = GModelIndex()) const;
|
||||
virtual int column_count(const GModelIndex& = GModelIndex()) const;
|
||||
virtual GVariant data(const GModelIndex&, Role = Role::Display) const;
|
||||
virtual void update();
|
||||
virtual ColumnMetadata column_metadata(int) const { return { 100 }; }
|
||||
};
|
||||
|
||||
int TestModel::row_count(const GModelIndex& index) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TestModel::column_count(const GModelIndex&) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void TestModel::update()
|
||||
{
|
||||
}
|
||||
|
||||
GVariant TestModel::data(const GModelIndex&, Role) const
|
||||
{
|
||||
return { };
|
||||
}
|
||||
|
||||
GTreeView::GTreeView(GWidget* parent)
|
||||
: GAbstractView(parent)
|
||||
{
|
||||
set_frame_shape(GFrame::Shape::Container);
|
||||
set_frame_shadow(GFrame::Shadow::Sunken);
|
||||
set_frame_thickness(2);
|
||||
|
||||
set_model(TestModel::create());
|
||||
}
|
||||
|
||||
GTreeView::~GTreeView()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue