1/*
2 * Copyright (C) 2008, Pino Toscano <pino@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include "optcontent.h"
20
21#include <poppler-qt6.h>
22
23#include <QtWidgets/QTreeView>
24
25OptContentDock::OptContentDock(QWidget *parent) : AbstractInfoDock(parent)
26{
27 m_view = new QTreeView(this);
28 setWidget(m_view);
29 setWindowTitle(tr(s: "Optional content"));
30 m_view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
31}
32
33OptContentDock::~OptContentDock() { }
34
35void OptContentDock::documentLoaded()
36{
37 AbstractInfoDock::documentLoaded();
38 if (document()->pageMode() == Poppler::Document::UseOC) {
39 show();
40 }
41}
42
43void OptContentDock::fillInfo()
44{
45 if (!document()->hasOptionalContent()) {
46 return;
47 }
48
49 m_view->setModel(document()->optionalContentModel());
50 connect(sender: m_view->model(), signal: &QAbstractItemModel::dataChanged, context: this, slot: &OptContentDock::reloadImage);
51 m_view->expandToDepth(depth: 1);
52}
53
54void OptContentDock::documentClosed()
55{
56 m_view->setModel(nullptr);
57 AbstractInfoDock::documentClosed();
58}
59
60void OptContentDock::reloadImage()
61{
62 reloadPage();
63}
64

source code of poppler/qt6/demos/optcontent.cpp