1/*
2 * Copyright (C) 2008-2009, 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 "permissions.h"
20
21#include <poppler-qt6.h>
22
23#include <QtWidgets/QListWidget>
24
25PermissionsDock::PermissionsDock(QWidget *parent) : AbstractInfoDock(parent)
26{
27 m_table = new QListWidget(this);
28 setWidget(m_table);
29 setWindowTitle(tr(s: "Permissions"));
30 m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
31}
32
33PermissionsDock::~PermissionsDock() { }
34
35void PermissionsDock::fillInfo()
36{
37#define ADD_ROW(title, function) \
38 do { \
39 QListWidgetItem *item = new QListWidgetItem(); \
40 item->setFlags(item->flags() & ~Qt::ItemIsEnabled); \
41 item->setText(QStringLiteral(title)); \
42 item->setCheckState(document()->function() ? Qt::Checked : Qt::Unchecked); \
43 m_table->addItem(item); \
44 } while (0)
45 ADD_ROW("Print", okToPrint);
46 ADD_ROW("PrintHiRes", okToPrintHighRes);
47 ADD_ROW("Change", okToChange);
48 ADD_ROW("Copy", okToCopy);
49 ADD_ROW("Add Notes", okToAddNotes);
50 ADD_ROW("Fill Forms", okToFillForm);
51 ADD_ROW("Create Forms", okToCreateFormFields);
52 ADD_ROW("Extract for accessibility", okToExtractForAccessibility);
53 ADD_ROW("Assemble", okToAssemble);
54#undef ADD_ROW
55}
56
57void PermissionsDock::documentClosed()
58{
59 m_table->clear();
60 AbstractInfoDock::documentClosed();
61}
62

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