summaryrefslogtreecommitdiff
path: root/Userland/Applications/PDFViewer/SidebarWidget.h
blob: 5d0657c726d01ea28d7de5b60d3b362d0e2c9a43 (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
/*
 * Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "OutlineModel.h"
#include <LibGUI/TreeView.h>
#include <LibGUI/Widget.h>

class SidebarWidget final : public GUI::Widget {
    C_OBJECT(SidebarWidget)

public:
    ~SidebarWidget() override = default;

    void set_outline(RefPtr<PDF::OutlineDict> outline)
    {
        if (outline) {
            m_model = OutlineModel::create(outline.release_nonnull());
            m_outline_tree_view->set_model(m_model);
        } else {
            m_model = RefPtr<OutlineModel> {};
            m_outline_tree_view->set_model({});
        }
    }

private:
    SidebarWidget();

    RefPtr<OutlineModel> m_model;
    RefPtr<GUI::TreeView> m_outline_tree_view;
};