| 1 |
/* |
| 2 |
* Copyright (C) 2008, Pino Toscano <[email protected]> |
| 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-qt5.h> |
| 22 |
|
| 23 |
#include <QtWidgets/QTreeView> |
| 24 |
|
| 25 |
OptContentDock::OptContentDock(QWidget *parent) : AbstractInfoDock(parent) |
| 26 |
{ |
| 27 |
m_view = new QTreeView(this); |
| 28 |
setWidget(m_view); |
| 29 |
setWindowTitle(tr("Optional content")); |
| 30 |
m_view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); |
| 31 |
} |
| 32 |
|
| 33 |
OptContentDock::~OptContentDock() = default; |
| 34 |
|
| 35 |
void OptContentDock::documentLoaded() |
| 36 |
{ |
| 37 |
AbstractInfoDock::documentLoaded(); |
| 38 |
if (document()->pageMode() == Poppler::Document::UseOC) { |
| 39 |
show(); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
void OptContentDock::fillInfo() |
| 44 |
{ |
| 45 |
if (!document()->hasOptionalContent()) { |
| 46 |
return; |
| 47 |
} |
| 48 |
|
| 49 |
m_view->setModel(document()->optionalContentModel()); |
| 50 |
connect(m_view->model(), &QAbstractItemModel::dataChanged, this, &OptContentDock::reloadImage); |
| 51 |
m_view->expandToDepth(1); |
| 52 |
} |
| 53 |
|
| 54 |
void OptContentDock::documentClosed() |
| 55 |
{ |
| 56 |
m_view->setModel(nullptr); |
| 57 |
AbstractInfoDock::documentClosed(); |
| 58 |
} |
| 59 |
|
| 60 |
void OptContentDock::reloadImage() |
| 61 |
{ |
| 62 |
reloadPage(); |
| 63 |
} |