summaryrefslogtreecommitdiff
path: root/LibGUI/GTreeView.cpp
blob: 031efc55e52a7533299fb01b7902b72ecfe748a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#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()
{
}

void GTreeView::paint_event(GPaintEvent& event)
{
    GFrame::paint_event(event);
    GPainter painter(*this);
    painter.set_clip_rect(frame_inner_rect());
    painter.set_clip_rect(event.rect());

    painter.fill_rect(event.rect(), Color::White);
}