summaryrefslogtreecommitdiff
path: root/LibGUI/GAbstractView.cpp
blob: 34c73b4ab629bb1a8a828b530e5498c6ca4c11b2 (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
#include <LibGUI/GAbstractView.h>
#include <LibGUI/GModel.h>
#include <LibGUI/GScrollBar.h>
#include <SharedGraphics/Painter.h>
#include <Kernel/KeyCode.h>

GAbstractView::GAbstractView(GWidget* parent)
    : GScrollableWidget(parent)
{
}

GAbstractView::~GAbstractView()
{
}

void GAbstractView::set_model(RetainPtr<GModel>&& model)
{
    if (model.ptr() == m_model.ptr())
        return;
    if (m_model)
        m_model->unregister_view(Badge<GAbstractView>(), *this);
    m_model = move(model);
    if (m_model)
        m_model->register_view(Badge<GAbstractView>(), *this);
    did_update_model();
}

void GAbstractView::model_notification(const GModelNotification& notification)
{
    if (on_model_notification)
        on_model_notification(notification);
}

void GAbstractView::did_update_model()
{
    model_notification(GModelNotification(GModelNotification::ModelUpdated));
}