1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +00:00

PDFViewer: Add a tab bar with outlines and thumbnails

Outlines are in theory implemented (though I'm having trouble finding
a simple PDF with outlines to test it on), and thumbnails are not.
This commit is contained in:
Matthew Olsson 2021-05-23 21:34:06 -07:00 committed by Ali Mohammad Pur
parent 67b65dffa8
commit cea7dbce42
7 changed files with 250 additions and 7 deletions

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Model.h>
#include <LibGUI/TreeView.h>
#include <LibPDF/Document.h>
class OutlineModel final : public GUI::Model {
public:
static NonnullRefPtr<OutlineModel> create(const NonnullRefPtr<PDF::OutlineDict>& outline);
void set_index_open_state(const GUI::ModelIndex& index, bool is_open);
virtual int row_count(const GUI::ModelIndex&) const override;
virtual int column_count(const GUI::ModelIndex&) const override;
virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override;
virtual void update() override;
virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
private:
OutlineModel(const NonnullRefPtr<PDF::OutlineDict>& outline);
GUI::Icon m_closed_item_icon;
GUI::Icon m_open_item_icon;
NonnullRefPtr<PDF::OutlineDict> m_outline;
HashTable<PDF::OutlineItem*> m_open_outline_items;
};