Issue #54: Rename bookmarks

This commit is contained in:
Jakub Melka 2023-12-13 20:14:33 +01:00
parent 27cccbedcb
commit c1c59139b5
19 changed files with 107 additions and 107 deletions

View File

@ -27,12 +27,12 @@ add_executable(Pdf4QtDocPageOrganizer
pageitemdelegate.h
pageitemmodel.cpp
pageitemmodel.h
selectbookmarkstoregroupdialog.cpp
selectbookmarkstoregroupdialog.h
selectoutlinetoregroupdialog.cpp
selectoutlinetoregroupdialog.h
aboutdialog.ui
assembleoutputsettingsdialog.ui
mainwindow.ui
selectbookmarkstoregroupdialog.ui
selectoutlinetoregroupdialog.ui
resources.qrc
icon.rc
)

View File

@ -20,7 +20,7 @@
#include "aboutdialog.h"
#include "assembleoutputsettingsdialog.h"
#include "selectbookmarkstoregroupdialog.h"
#include "selectoutlinetoregroupdialog.h"
#include "pdfaction.h"
#include "pdfwidgetutils.h"
@ -94,7 +94,7 @@ MainWindow::MainWindow(QWidget* parent) :
ui->actionInvert_Selection->setData(int(Operation::InvertSelection));
ui->actionRegroup_Even_Odd->setData(int(Operation::RegroupEvenOdd));
ui->actionRegroup_by_Page_Pairs->setData(int(Operation::RegroupPaired));
ui->actionRegroup_by_Bookmarks->setData(int(Operation::RegroupBookmarks));
ui->actionRegroup_by_Outline->setData(int(Operation::RegroupOutline));
ui->actionRegroup_by_Alternating_Pages->setData(int(Operation::RegroupAlternatingPages));
ui->actionRegroup_by_Alternating_Pages_Reversed_Order->setData(int(Operation::RegroupAlternatingPagesReversed));
ui->actionPrepare_Icon_Theme->setData(int(Operation::PrepareIconTheme));
@ -132,7 +132,7 @@ MainWindow::MainWindow(QWidget* parent) :
m_iconTheme.registerAction(ui->actionClear, ":/pdfdocpage/resources/clear.svg");
m_iconTheme.registerAction(ui->actionRegroup_Even_Odd, ":/pdfdocpage/resources/regroup-even-odd.svg");
m_iconTheme.registerAction(ui->actionRegroup_by_Page_Pairs, ":/pdfdocpage/resources/regroup-pairs.svg");
m_iconTheme.registerAction(ui->actionRegroup_by_Bookmarks, ":/pdfdocpage/resources/regroup-bookmarks.svg");
m_iconTheme.registerAction(ui->actionRegroup_by_Outline, ":/pdfdocpage/resources/regroup-outline.svg");
m_iconTheme.registerAction(ui->actionRegroup_by_Alternating_Pages, ":/pdfdocpage/resources/regroup-alternating.svg");
m_iconTheme.registerAction(ui->actionRegroup_by_Alternating_Pages_Reversed_Order, ":/pdfdocpage/resources/regroup-alternating-reversed.svg");
m_iconTheme.registerAction(ui->actionInvert_Selection, ":/pdfdocpage/resources/invert-selection.svg");
@ -162,7 +162,7 @@ MainWindow::MainWindow(QWidget* parent) :
selectToolbar->addActions({ ui->actionSelect_None, ui->actionSelect_All, ui->actionSelect_Even, ui->actionSelect_Odd, ui->actionSelect_Portrait, ui->actionSelect_Landscape, ui->actionInvert_Selection });
QToolBar* regroupToolbar = addToolBar(tr("Regroup"));
regroupToolbar->setObjectName("regroup_toolbar");
regroupToolbar->addActions({ ui->actionRegroup_Even_Odd, ui->actionRegroup_by_Page_Pairs, ui->actionRegroup_by_Bookmarks, ui->actionRegroup_by_Alternating_Pages, ui->actionRegroup_by_Alternating_Pages_Reversed_Order });
regroupToolbar->addActions({ ui->actionRegroup_Even_Odd, ui->actionRegroup_by_Page_Pairs, ui->actionRegroup_by_Outline, ui->actionRegroup_by_Alternating_Pages, ui->actionRegroup_by_Alternating_Pages_Reversed_Order });
QToolBar* zoomToolbar = addToolBar(tr("Zoom"));
zoomToolbar->setObjectName("zoom_toolbar");
zoomToolbar->addActions({ ui->actionZoom_In, ui->actionZoom_Out });
@ -283,7 +283,7 @@ void MainWindow::onWorkspaceCustomContextMenuRequested(const QPoint& point)
regroupMenu->addAction(ui->actionRegroup_by_Alternating_Pages);
regroupMenu->addAction(ui->actionRegroup_by_Alternating_Pages_Reversed_Order);
regroupMenu->addAction(ui->actionRegroup_by_Page_Pairs);
regroupMenu->addAction(ui->actionRegroup_by_Bookmarks);
regroupMenu->addAction(ui->actionRegroup_by_Outline);
contextMenu->addSeparator();
contextMenu->addAction(ui->actionGroup);
contextMenu->addAction(ui->actionUngroup);
@ -482,7 +482,7 @@ bool MainWindow::canPerformOperation(Operation operation) const
case Operation::RegroupPaired:
return !isModelEmpty && !selection.isEmpty();
case Operation::RegroupBookmarks:
case Operation::RegroupOutline:
{
PageItemModel::SelectionInfo info = m_model->getSelectionInfo(selection);
return info.isSingleDocument();
@ -916,7 +916,7 @@ void MainWindow::performOperation(Operation operation)
break;
}
case Operation::RegroupBookmarks:
case Operation::RegroupOutline:
{
QModelIndexList indexes = ui->documentItemsView->selectionModel()->selection().indexes();
@ -929,9 +929,9 @@ void MainWindow::performOperation(Operation operation)
if (it != documents.end())
{
const pdf::PDFDocument* document = &it->second.document;
SelectBookmarksToRegroupDialog dialog(document, this);
SelectOutlineToRegroupDialog dialog(document, this);
if (dialog.exec() == SelectBookmarksToRegroupDialog::Accepted)
if (dialog.exec() == SelectOutlineToRegroupDialog::Accepted)
{
std::vector<pdf::PDFInteger> breakPageIndices;
std::vector<const pdf::PDFOutlineItem*> outlineItems = dialog.getSelectedOutlineItems();
@ -972,7 +972,7 @@ void MainWindow::performOperation(Operation operation)
std::sort(breakPageIndices.begin(), breakPageIndices.end());
breakPageIndices.erase(std::unique(breakPageIndices.begin(), breakPageIndices.end()), breakPageIndices.end());
m_model->regroupBookmarks(indexes, breakPageIndices);
m_model->regroupOutline(indexes, breakPageIndices);
}
}
}

View File

@ -91,7 +91,7 @@ public:
RegroupEvenOdd,
RegroupPaired,
RegroupBookmarks,
RegroupOutline,
RegroupAlternatingPages,
RegroupAlternatingPagesReversed,

View File

@ -138,7 +138,7 @@
</property>
<addaction name="actionRegroup_Even_Odd"/>
<addaction name="actionRegroup_by_Page_Pairs"/>
<addaction name="actionRegroup_by_Bookmarks"/>
<addaction name="actionRegroup_by_Outline"/>
<addaction name="actionRegroup_by_Alternating_Pages"/>
<addaction name="actionRegroup_by_Alternating_Pages_Reversed_Order"/>
</widget>
@ -533,13 +533,13 @@
<string>Regroup by Page Pairs</string>
</property>
</action>
<action name="actionRegroup_by_Bookmarks">
<action name="actionRegroup_by_Outline">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/pdfdocpage/resources/regroup-bookmarks.svg</normaloff>:/pdfdocpage/resources/regroup-bookmarks.svg</iconset>
<normaloff>:/pdfdocpage/resources/regroup-outline.svg</normaloff>:/pdfdocpage/resources/regroup-outline.svg</iconset>
</property>
<property name="text">
<string>Regroup by Bookmarks</string>
<string>Regroup by Outline</string>
</property>
</action>
<action name="actionRegroup_by_Alternating_Pages">

View File

@ -703,7 +703,7 @@ void PageItemModel::regroupPaired(const QModelIndexList& list)
}
}
void PageItemModel::regroupBookmarks(const QModelIndexList& list, const std::vector<pdf::PDFInteger>& indices)
void PageItemModel::regroupOutline(const QModelIndexList& list, const std::vector<pdf::PDFInteger>& indices)
{
if (list.empty())
{

View File

@ -191,7 +191,7 @@ public:
void regroupEvenOdd(const QModelIndexList& list);
void regroupPaired(const QModelIndexList& list);
void regroupBookmarks(const QModelIndexList& list, const std::vector<pdf::PDFInteger>& indices);
void regroupOutline(const QModelIndexList& list, const std::vector<pdf::PDFInteger>& indices);
void regroupAlternatingPages(const QModelIndexList& list, bool reversed);
bool canUndo() const { return !m_undoSteps.empty(); }

View File

@ -33,12 +33,12 @@
<file>resources/invert-selection.svg</file>
<file>resources/regroup-alternating.svg</file>
<file>resources/regroup-alternating-reversed.svg</file>
<file>resources/regroup-bookmarks.svg</file>
<file>resources/regroup-even-odd.svg</file>
<file>resources/regroup-pairs.svg</file>
<file>resources/undo.svg</file>
<file>resources/redo.svg</file>
<file>resources/bookmark.svg</file>
<file>resources/wallet.svg</file>
<file>resources/regroup-outline.svg</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -15,8 +15,8 @@
// You should have received a copy of the GNU Lesser General Public License
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
#include "selectbookmarkstoregroupdialog.h"
#include "ui_selectbookmarkstoregroupdialog.h"
#include "selectoutlinetoregroupdialog.h"
#include "ui_selectoutlinetoregroupdialog.h"
#include "pdfitemmodels.h"
#include "pdfwidgetutils.h"
@ -26,9 +26,9 @@
namespace pdfdocpage
{
SelectBookmarksToRegroupDialog::SelectBookmarksToRegroupDialog(const pdf::PDFDocument* document, QWidget* parent) :
SelectOutlineToRegroupDialog::SelectOutlineToRegroupDialog(const pdf::PDFDocument* document, QWidget* parent) :
QDialog(parent),
ui(new Ui::SelectBookmarksToRegroupDialog),
ui(new Ui::SelectOutlineToRegroupDialog),
m_document(document),
m_model(nullptr)
{
@ -36,53 +36,53 @@ SelectBookmarksToRegroupDialog::SelectBookmarksToRegroupDialog(const pdf::PDFDoc
QIcon bookmarkIcon(":/pdfdocpage/resources/bookmark.svg");
m_model = new pdf::PDFSelectableOutlineTreeItemModel(qMove(bookmarkIcon), this);
ui->bookmarksView->setModel(m_model);
ui->bookmarksView->header()->hide();
ui->outlineView->setModel(m_model);
ui->outlineView->header()->hide();
m_model->setDocument(pdf::PDFModifiedDocument(const_cast<pdf::PDFDocument*>(document), nullptr));
ui->bookmarksView->expandToDepth(2);
ui->bookmarksView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->bookmarksView, &QTreeView::customContextMenuRequested, this, &SelectBookmarksToRegroupDialog::onViewContextMenuRequested);
ui->outlineView->expandToDepth(2);
ui->outlineView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->outlineView, &QTreeView::customContextMenuRequested, this, &SelectOutlineToRegroupDialog::onViewContextMenuRequested);
QSize size = pdf::PDFWidgetUtils::scaleDPI(this, QSize(400, 600));
setMinimumSize(size);
pdf::PDFWidgetUtils::style(this);
}
SelectBookmarksToRegroupDialog::~SelectBookmarksToRegroupDialog()
SelectOutlineToRegroupDialog::~SelectOutlineToRegroupDialog()
{
delete ui;
}
std::vector<const pdf::PDFOutlineItem*> SelectBookmarksToRegroupDialog::getSelectedOutlineItems() const
std::vector<const pdf::PDFOutlineItem*> SelectOutlineToRegroupDialog::getSelectedOutlineItems() const
{
return m_model->getSelectedItems();
}
void SelectBookmarksToRegroupDialog::onViewContextMenuRequested(const QPoint& pos)
void SelectOutlineToRegroupDialog::onViewContextMenuRequested(const QPoint& pos)
{
QMenu menu;
menu.addAction(tr("Select All"), this, &SelectBookmarksToRegroupDialog::selectAll);
menu.addAction(tr("Deselect All"), this, &SelectBookmarksToRegroupDialog::deselectAll);
menu.addAction(tr("Invert Selection"), this, &SelectBookmarksToRegroupDialog::invertSelection);
menu.addAction(tr("Select All"), this, &SelectOutlineToRegroupDialog::selectAll);
menu.addAction(tr("Deselect All"), this, &SelectOutlineToRegroupDialog::deselectAll);
menu.addAction(tr("Invert Selection"), this, &SelectOutlineToRegroupDialog::invertSelection);
menu.addSeparator();
menu.addAction(tr("Select Level 1"), this, &SelectBookmarksToRegroupDialog::selectLevel1);
menu.addAction(tr("Select Level 2"), this, &SelectBookmarksToRegroupDialog::selectLevel2);
menu.addAction(tr("Select Level 1"), this, &SelectOutlineToRegroupDialog::selectLevel1);
menu.addAction(tr("Select Level 2"), this, &SelectOutlineToRegroupDialog::selectLevel2);
QModelIndex index = ui->bookmarksView->indexAt(pos);
QModelIndex index = ui->outlineView->indexAt(pos);
if (index.isValid())
{
m_menuIndex = index;
menu.addSeparator();
menu.addAction(tr("Select subtree"), this, &SelectBookmarksToRegroupDialog::selectSubtree);
menu.addAction(tr("Deselect subtree"), this, &SelectBookmarksToRegroupDialog::deselectSubtree);
menu.addAction(tr("Select subtree"), this, &SelectOutlineToRegroupDialog::selectSubtree);
menu.addAction(tr("Deselect subtree"), this, &SelectOutlineToRegroupDialog::deselectSubtree);
}
menu.exec(ui->bookmarksView->mapToGlobal(pos));
menu.exec(ui->outlineView->mapToGlobal(pos));
}
void SelectBookmarksToRegroupDialog::manipulateTree(const QModelIndex& index,
void SelectOutlineToRegroupDialog::manipulateTree(const QModelIndex& index,
const std::function<void (QModelIndex)>& manipulator)
{
if (index.isValid())
@ -98,7 +98,7 @@ void SelectBookmarksToRegroupDialog::manipulateTree(const QModelIndex& index,
}
}
std::function<void (QModelIndex)> SelectBookmarksToRegroupDialog::createCheckByDepthManipulator(int targetDepth) const
std::function<void (QModelIndex)> SelectOutlineToRegroupDialog::createCheckByDepthManipulator(int targetDepth) const
{
auto manipulator = [this, targetDepth](QModelIndex index)
{
@ -119,42 +119,42 @@ std::function<void (QModelIndex)> SelectBookmarksToRegroupDialog::createCheckByD
return manipulator;
}
void SelectBookmarksToRegroupDialog::selectAll()
void SelectOutlineToRegroupDialog::selectAll()
{
manipulateTree(ui->bookmarksView->rootIndex(), [this](QModelIndex index) { m_model->setData(index, Qt::Checked, Qt::CheckStateRole); });
manipulateTree(ui->outlineView->rootIndex(), [this](QModelIndex index) { m_model->setData(index, Qt::Checked, Qt::CheckStateRole); });
}
void SelectBookmarksToRegroupDialog::deselectAll()
void SelectOutlineToRegroupDialog::deselectAll()
{
manipulateTree(ui->bookmarksView->rootIndex(), [this](QModelIndex index) { m_model->setData(index, Qt::Unchecked, Qt::CheckStateRole); });
manipulateTree(ui->outlineView->rootIndex(), [this](QModelIndex index) { m_model->setData(index, Qt::Unchecked, Qt::CheckStateRole); });
}
void SelectBookmarksToRegroupDialog::invertSelection()
void SelectOutlineToRegroupDialog::invertSelection()
{
auto manipulator = [this](QModelIndex index)
{
const bool isChecked = index.data(Qt::CheckStateRole).toInt() == Qt::Checked;
m_model->setData(index, isChecked ? Qt::Unchecked : Qt::Checked, Qt::CheckStateRole);
};
manipulateTree(ui->bookmarksView->rootIndex(), manipulator);
manipulateTree(ui->outlineView->rootIndex(), manipulator);
}
void SelectBookmarksToRegroupDialog::selectLevel1()
void SelectOutlineToRegroupDialog::selectLevel1()
{
manipulateTree(ui->bookmarksView->rootIndex(), createCheckByDepthManipulator(1));
manipulateTree(ui->outlineView->rootIndex(), createCheckByDepthManipulator(1));
}
void SelectBookmarksToRegroupDialog::selectLevel2()
void SelectOutlineToRegroupDialog::selectLevel2()
{
manipulateTree(ui->bookmarksView->rootIndex(), createCheckByDepthManipulator(2));
manipulateTree(ui->outlineView->rootIndex(), createCheckByDepthManipulator(2));
}
void SelectBookmarksToRegroupDialog::selectSubtree()
void SelectOutlineToRegroupDialog::selectSubtree()
{
manipulateTree(m_menuIndex, [this](QModelIndex index) { m_model->setData(index, Qt::Checked, Qt::CheckStateRole); });
}
void SelectBookmarksToRegroupDialog::deselectSubtree()
void SelectOutlineToRegroupDialog::deselectSubtree()
{
manipulateTree(m_menuIndex, [this](QModelIndex index) { m_model->setData(index, Qt::Unchecked, Qt::CheckStateRole); });
}

View File

@ -15,8 +15,8 @@
// You should have received a copy of the GNU Lesser General Public License
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
#ifndef PDFDOCPAGEORGANIZER_SELECTBOOKMARKSTOREGROUPDIALOG_H
#define PDFDOCPAGEORGANIZER_SELECTBOOKMARKSTOREGROUPDIALOG_H
#ifndef PDFDOCPAGEORGANIZER_SELECTOUTLINETOREGROUPDIALOG_H
#define PDFDOCPAGEORGANIZER_SELECTOUTLINETOREGROUPDIALOG_H
#include "pdfdocument.h"
@ -24,7 +24,7 @@
namespace Ui
{
class SelectBookmarksToRegroupDialog;
class SelectOutlineToRegroupDialog;
}
namespace pdf
@ -35,13 +35,13 @@ class PDFSelectableOutlineTreeItemModel;
namespace pdfdocpage
{
class SelectBookmarksToRegroupDialog : public QDialog
class SelectOutlineToRegroupDialog : public QDialog
{
Q_OBJECT
public:
explicit SelectBookmarksToRegroupDialog(const pdf::PDFDocument* document, QWidget* parent);
virtual ~SelectBookmarksToRegroupDialog() override;
explicit SelectOutlineToRegroupDialog(const pdf::PDFDocument* document, QWidget* parent);
virtual ~SelectOutlineToRegroupDialog() override;
std::vector<const pdf::PDFOutlineItem*> getSelectedOutlineItems() const;
@ -62,7 +62,7 @@ private:
std::function<void (QModelIndex)> createCheckByDepthManipulator(int targetDepth) const;
Ui::SelectBookmarksToRegroupDialog* ui;
Ui::SelectOutlineToRegroupDialog* ui;
const pdf::PDFDocument* m_document;
pdf::PDFSelectableOutlineTreeItemModel* m_model;
QModelIndex m_menuIndex;
@ -70,4 +70,4 @@ private:
} // namespace pdfdocpage
#endif // PDFDOCPAGEORGANIZER_SELECTBOOKMARKSTOREGROUPDIALOG_H
#endif // PDFDOCPAGEORGANIZER_SELECTOUTLINETOREGROUPDIALOG_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SelectBookmarksToRegroupDialog</class>
<widget class="QDialog" name="SelectBookmarksToRegroupDialog">
<class>SelectOutlineToRegroupDialog</class>
<widget class="QDialog" name="SelectOutlineToRegroupDialog">
<property name="geometry">
<rect>
<x>0</x>
@ -11,11 +11,11 @@
</rect>
</property>
<property name="windowTitle">
<string>Select Bookmarks</string>
<string>Select Outline</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeView" name="bookmarksView"/>
<widget class="QTreeView" name="outlineView"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
@ -34,7 +34,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SelectBookmarksToRegroupDialog</receiver>
<receiver>SelectOutlineToRegroupDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@ -50,7 +50,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SelectBookmarksToRegroupDialog</receiver>
<receiver>SelectOutlineToRegroupDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">

View File

@ -86,9 +86,9 @@ void PDFDocumentSanitizer::sanitize()
performSanitizeMetadata();
}
if (m_flags.testFlag(Bookmarks))
if (m_flags.testFlag(Outline))
{
performSanitizeBookmarks();
performSanitizeOutline();
}
if (m_flags.testFlag(FileAttachments))
@ -163,7 +163,7 @@ void PDFDocumentSanitizer::performSanitizeMetadata()
Q_EMIT sanitizationProgress(tr("Metadata streams removed: %1").arg(counter));
}
void PDFDocumentSanitizer::performSanitizeBookmarks()
void PDFDocumentSanitizer::performSanitizeOutline()
{
PDFDocumentBuilder builder(m_storage, PDFVersion(2, 0));
PDFObject catalogObject = builder.getObjectByReference(builder.getCatalogReference());

View File

@ -38,7 +38,7 @@ public:
None = 0x0000, ///< No sanitization is performed
DocumentInfo = 0x0001, ///< Remove document information
Metadata = 0x0002, ///< Remove all metadata streams in all objects
Bookmarks = 0x0004, ///< Remove bookmarks
Outline = 0x0004, ///< Remove outline
FileAttachments = 0x0008, ///< Remove file attachments
EmbeddedSearchIndex = 0x0010, ///< Remove embedded search index
MarkupAnnotations = 0x0020, ///< Remove markup annotations from all pages
@ -82,7 +82,7 @@ signals:
private:
void performSanitizeDocumentInfo();
void performSanitizeMetadata();
void performSanitizeBookmarks();
void performSanitizeOutline();
void performSanitizeFileAttachments();
void performSanitizeEmbeddedSearchIndex();
void performSanitizeMarkupAnnotations();

View File

@ -15,7 +15,6 @@
<file>resources/settings.svg</file>
<file>resources/zoom-in.svg</file>
<file>resources/zoom-out.svg</file>
<file>resources/bookmark.svg</file>
<file>resources/security.svg</file>
<file>resources/zoom-fit.svg</file>
<file>resources/zoom-fit-horizontal.svg</file>
@ -104,5 +103,6 @@
<file>resources/sidebar-speech.svg</file>
<file>resources/sidebar-thumbnails.svg</file>
<file>resources/sidebar-visibility.svg</file>
<file>resources/outline.svg</file>
</qresource>
</RCC>

View File

@ -51,7 +51,7 @@ PDFSanitizeDocumentDialog::PDFSanitizeDocumentDialog(const pdf::PDFDocument* doc
addCheckBox(tr("Remove document info"), pdf::PDFDocumentSanitizer::DocumentInfo);
addCheckBox(tr("Remove all metadata"), pdf::PDFDocumentSanitizer::Metadata);
addCheckBox(tr("Remove outline (bookmarks)"), pdf::PDFDocumentSanitizer::Bookmarks);
addCheckBox(tr("Remove outline"), pdf::PDFDocumentSanitizer::Outline);
addCheckBox(tr("Remove file attachments"), pdf::PDFDocumentSanitizer::FileAttachments);
addCheckBox(tr("Remove embedded search index"), pdf::PDFDocumentSanitizer::EmbeddedSearchIndex);
addCheckBox(tr("Remove comments and other markup annotations"), pdf::PDFDocumentSanitizer::MarkupAnnotations);

View File

@ -81,26 +81,26 @@ PDFSidebarWidget::PDFSidebarWidget(pdf::PDFDrawWidgetProxy* proxy,
setStyleSheet(STYLESHEET);
// Outline
QIcon bookmarkIcon(":/resources/bookmark.svg");
m_outlineTreeModel = new pdf::PDFOutlineTreeItemModel(qMove(bookmarkIcon), editableOutline, this);
ui->bookmarksTreeView->setModel(m_outlineTreeModel);
ui->bookmarksTreeView->header()->hide();
QIcon outlineIcon(":/resources/outline.svg");
m_outlineTreeModel = new pdf::PDFOutlineTreeItemModel(qMove(outlineIcon), editableOutline, this);
ui->outlineTreeView->setModel(m_outlineTreeModel);
ui->outlineTreeView->header()->hide();
if (editableOutline)
{
ui->bookmarksTreeView->setDragEnabled(true);
ui->bookmarksTreeView->setAcceptDrops(true);
ui->bookmarksTreeView->setDropIndicatorShown(true);
ui->bookmarksTreeView->setDragDropMode(QAbstractItemView::InternalMove);
ui->bookmarksTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->bookmarksTreeView, &QTreeView::customContextMenuRequested, this, &PDFSidebarWidget::onBookmarksTreeViewContextMenuRequested);
ui->outlineTreeView->setDragEnabled(true);
ui->outlineTreeView->setAcceptDrops(true);
ui->outlineTreeView->setDropIndicatorShown(true);
ui->outlineTreeView->setDragDropMode(QAbstractItemView::InternalMove);
ui->outlineTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->outlineTreeView, &QTreeView::customContextMenuRequested, this, &PDFSidebarWidget::onOutlineTreeViewContextMenuRequested);
connect(m_outlineTreeModel, &pdf::PDFOutlineTreeItemModel::dataChanged, this, &PDFSidebarWidget::onOutlineItemsChanged);
connect(m_outlineTreeModel, &pdf::PDFOutlineTreeItemModel::rowsInserted, this, &PDFSidebarWidget::onOutlineItemsChanged);
connect(m_outlineTreeModel, &pdf::PDFOutlineTreeItemModel::rowsRemoved, this, &PDFSidebarWidget::onOutlineItemsChanged);
connect(m_outlineTreeModel, &pdf::PDFOutlineTreeItemModel::rowsMoved, this, &PDFSidebarWidget::onOutlineItemsChanged);
}
connect(ui->bookmarksTreeView, &QTreeView::clicked, this, &PDFSidebarWidget::onOutlineItemClicked);
connect(ui->outlineTreeView, &QTreeView::clicked, this, &PDFSidebarWidget::onOutlineItemClicked);
// Thumbnails
m_thumbnailsModel = new pdf::PDFThumbnailsItemModel(proxy, this);
@ -128,7 +128,7 @@ PDFSidebarWidget::PDFSidebarWidget(pdf::PDFDrawWidgetProxy* proxy,
m_pageInfo[Invalid] = { nullptr, ui->emptyPage };
m_pageInfo[OptionalContent] = { ui->optionalContentButton, ui->optionalContentPage };
m_pageInfo[Bookmarks] = { ui->bookmarksButton, ui->bookmarksPage };
m_pageInfo[Outline] = { ui->outlineButton, ui->outlinePage };
m_pageInfo[Thumbnails] = { ui->thumbnailsButton, ui->thumbnailsPage };
m_pageInfo[Attachments] = { ui->attachmentsButton, ui->attachmentsPage };
m_pageInfo[Speech] = { ui->speechButton, ui->speechPage };
@ -189,7 +189,7 @@ void PDFSidebarWidget::setDocument(const pdf::PDFModifiedDocument& document, con
switch (pageMode)
{
case pdf::PageMode::UseOutlines:
preferred = Bookmarks;
preferred = Outline;
break;
case pdf::PageMode::UseThumbnails:
@ -210,7 +210,7 @@ void PDFSidebarWidget::setDocument(const pdf::PDFModifiedDocument& document, con
switch (nonFullscreenPageMode)
{
case pdf::PDFViewerPreferences::NonFullScreenPageMode::UseOutline:
preferred = Bookmarks;
preferred = Outline;
break;
case pdf::PDFViewerPreferences::NonFullScreenPageMode::UseThumbnails:
@ -259,7 +259,7 @@ bool PDFSidebarWidget::isEmpty(Page page) const
case Invalid:
return true;
case Bookmarks:
case Outline:
return m_outlineTreeModel->isEmpty() && (!m_document || !m_outlineTreeModel->isEditable());
case Thumbnails:
@ -764,11 +764,11 @@ void PDFSidebarWidget::onSignatureCustomContextMenuRequested(const QPoint& pos)
}
}
void PDFSidebarWidget::onBookmarksTreeViewContextMenuRequested(const QPoint& pos)
void PDFSidebarWidget::onOutlineTreeViewContextMenuRequested(const QPoint& pos)
{
QMenu contextMenu;
QModelIndex index = ui->bookmarksTreeView->indexAt(pos);
QModelIndex index = ui->outlineTreeView->indexAt(pos);
auto onFollow = [this, index]()
{
@ -779,22 +779,22 @@ void PDFSidebarWidget::onBookmarksTreeViewContextMenuRequested(const QPoint& pos
{
if (index.isValid())
{
ui->bookmarksTreeView->model()->insertRow(index.row() + 1, index.parent());
ui->outlineTreeView->model()->insertRow(index.row() + 1, index.parent());
}
else
{
ui->bookmarksTreeView->model()->insertRow(ui->bookmarksTreeView->model()->rowCount());
ui->outlineTreeView->model()->insertRow(ui->outlineTreeView->model()->rowCount());
}
};
auto onDelete = [this, index]()
{
ui->bookmarksTreeView->model()->removeRow(index.row(), index.parent());
ui->outlineTreeView->model()->removeRow(index.row(), index.parent());
};
auto onRename = [this, index]()
{
ui->bookmarksTreeView->edit(index);
ui->outlineTreeView->edit(index);
};
QAction* followAction = contextMenu.addAction(tr("Follow"), onFollow);
@ -927,7 +927,7 @@ void PDFSidebarWidget::onBookmarksTreeViewContextMenuRequested(const QPoint& pos
submenu->addAction(tr("Fit Bounding Box Vertically"), createOnSetTarget(pdf::DestinationType::FitBV));
submenu->addAction(tr("XYZ"), createOnSetTarget(pdf::DestinationType::XYZ));
contextMenu.exec(ui->bookmarksTreeView->mapToGlobal(pos));
contextMenu.exec(ui->outlineTreeView->mapToGlobal(pos));
}
void PDFSidebarWidget::onOutlineItemsChanged()

View File

@ -72,7 +72,7 @@ public:
{
Invalid,
_BEGIN,
Bookmarks = _BEGIN,
Outline = _BEGIN,
Thumbnails,
OptionalContent,
Attachments,
@ -113,7 +113,7 @@ private:
void onAttachmentCustomContextMenuRequested(const QPoint& pos);
void onThumbnailClicked(const QModelIndex& index);
void onSignatureCustomContextMenuRequested(const QPoint &pos);
void onBookmarksTreeViewContextMenuRequested(const QPoint &pos);
void onOutlineTreeViewContextMenuRequested(const QPoint &pos);
void onOutlineItemsChanged();
struct PageInfo

View File

@ -29,7 +29,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="bookmarksButton">
<widget class="QToolButton" name="outlineButton">
<property name="minimumSize">
<size>
<width>96</width>
@ -42,7 +42,7 @@
</font>
</property>
<property name="text">
<string>Bookmarks</string>
<string>Outline</string>
</property>
<property name="icon">
<iconset resource="pdf4qtviewer.qrc">
@ -243,11 +243,11 @@
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="emptyPage"/>
<widget class="QWidget" name="bookmarksPage">
<layout class="QVBoxLayout" name="bookmarksPageLayout">
<widget class="QWidget" name="outlinePage">
<layout class="QVBoxLayout" name="outlinePageLayout">
<property name="spacing">
<number>0</number>
</property>
@ -264,7 +264,7 @@
<number>0</number>
</property>
<item>
<widget class="QTreeView" name="bookmarksTreeView"/>
<widget class="QTreeView" name="outlineTreeView"/>
</item>
</layout>
</widget>

View File

Before

Width:  |  Height:  |  Size: 718 B

After

Width:  |  Height:  |  Size: 718 B