From c1c59139b540e2098240839e4d168638f8c72097 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Wed, 13 Dec 2023 20:14:33 +0100 Subject: [PATCH] Issue #54: Rename bookmarks --- Pdf4QtDocPageOrganizer/CMakeLists.txt | 6 +- Pdf4QtDocPageOrganizer/mainwindow.cpp | 20 +++--- Pdf4QtDocPageOrganizer/mainwindow.h | 2 +- Pdf4QtDocPageOrganizer/mainwindow.ui | 8 +-- Pdf4QtDocPageOrganizer/pageitemmodel.cpp | 2 +- Pdf4QtDocPageOrganizer/pageitemmodel.h | 2 +- Pdf4QtDocPageOrganizer/resources.qrc | 2 +- ...roup-bookmarks.svg => regroup-outline.svg} | 0 ...g.cpp => selectoutlinetoregroupdialog.cpp} | 70 +++++++++---------- ...ialog.h => selectoutlinetoregroupdialog.h} | 16 ++--- ...log.ui => selectoutlinetoregroupdialog.ui} | 12 ++-- .../sources/pdfdocumentsanitizer.cpp | 6 +- Pdf4QtLibCore/sources/pdfdocumentsanitizer.h | 4 +- Pdf4QtViewer/pdf4qtviewer.qrc | 2 +- Pdf4QtViewer/pdfsanitizedocumentdialog.cpp | 2 +- Pdf4QtViewer/pdfsidebarwidget.cpp | 44 ++++++------ Pdf4QtViewer/pdfsidebarwidget.h | 4 +- Pdf4QtViewer/pdfsidebarwidget.ui | 12 ++-- .../resources/{bookmark.svg => outline.svg} | 0 19 files changed, 107 insertions(+), 107 deletions(-) rename Pdf4QtDocPageOrganizer/resources/{regroup-bookmarks.svg => regroup-outline.svg} (100%) rename Pdf4QtDocPageOrganizer/{selectbookmarkstoregroupdialog.cpp => selectoutlinetoregroupdialog.cpp} (52%) rename Pdf4QtDocPageOrganizer/{selectbookmarkstoregroupdialog.h => selectoutlinetoregroupdialog.h} (77%) rename Pdf4QtDocPageOrganizer/{selectbookmarkstoregroupdialog.ui => selectoutlinetoregroupdialog.ui} (80%) rename Pdf4QtViewer/resources/{bookmark.svg => outline.svg} (100%) diff --git a/Pdf4QtDocPageOrganizer/CMakeLists.txt b/Pdf4QtDocPageOrganizer/CMakeLists.txt index e803d2e..6372289 100644 --- a/Pdf4QtDocPageOrganizer/CMakeLists.txt +++ b/Pdf4QtDocPageOrganizer/CMakeLists.txt @@ -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 ) diff --git a/Pdf4QtDocPageOrganizer/mainwindow.cpp b/Pdf4QtDocPageOrganizer/mainwindow.cpp index 53a4fd4..6bddb87 100644 --- a/Pdf4QtDocPageOrganizer/mainwindow.cpp +++ b/Pdf4QtDocPageOrganizer/mainwindow.cpp @@ -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 breakPageIndices; std::vector 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); } } } diff --git a/Pdf4QtDocPageOrganizer/mainwindow.h b/Pdf4QtDocPageOrganizer/mainwindow.h index 4404421..6e04e92 100644 --- a/Pdf4QtDocPageOrganizer/mainwindow.h +++ b/Pdf4QtDocPageOrganizer/mainwindow.h @@ -91,7 +91,7 @@ public: RegroupEvenOdd, RegroupPaired, - RegroupBookmarks, + RegroupOutline, RegroupAlternatingPages, RegroupAlternatingPagesReversed, diff --git a/Pdf4QtDocPageOrganizer/mainwindow.ui b/Pdf4QtDocPageOrganizer/mainwindow.ui index 5461425..acabce7 100644 --- a/Pdf4QtDocPageOrganizer/mainwindow.ui +++ b/Pdf4QtDocPageOrganizer/mainwindow.ui @@ -138,7 +138,7 @@ - + @@ -533,13 +533,13 @@ Regroup by Page Pairs - + - :/pdfdocpage/resources/regroup-bookmarks.svg:/pdfdocpage/resources/regroup-bookmarks.svg + :/pdfdocpage/resources/regroup-outline.svg:/pdfdocpage/resources/regroup-outline.svg - Regroup by Bookmarks + Regroup by Outline diff --git a/Pdf4QtDocPageOrganizer/pageitemmodel.cpp b/Pdf4QtDocPageOrganizer/pageitemmodel.cpp index 3fab2a6..edec5cd 100644 --- a/Pdf4QtDocPageOrganizer/pageitemmodel.cpp +++ b/Pdf4QtDocPageOrganizer/pageitemmodel.cpp @@ -703,7 +703,7 @@ void PageItemModel::regroupPaired(const QModelIndexList& list) } } -void PageItemModel::regroupBookmarks(const QModelIndexList& list, const std::vector& indices) +void PageItemModel::regroupOutline(const QModelIndexList& list, const std::vector& indices) { if (list.empty()) { diff --git a/Pdf4QtDocPageOrganizer/pageitemmodel.h b/Pdf4QtDocPageOrganizer/pageitemmodel.h index 11833cc..07a07ec 100644 --- a/Pdf4QtDocPageOrganizer/pageitemmodel.h +++ b/Pdf4QtDocPageOrganizer/pageitemmodel.h @@ -191,7 +191,7 @@ public: void regroupEvenOdd(const QModelIndexList& list); void regroupPaired(const QModelIndexList& list); - void regroupBookmarks(const QModelIndexList& list, const std::vector& indices); + void regroupOutline(const QModelIndexList& list, const std::vector& indices); void regroupAlternatingPages(const QModelIndexList& list, bool reversed); bool canUndo() const { return !m_undoSteps.empty(); } diff --git a/Pdf4QtDocPageOrganizer/resources.qrc b/Pdf4QtDocPageOrganizer/resources.qrc index ca37f56..c3703c6 100644 --- a/Pdf4QtDocPageOrganizer/resources.qrc +++ b/Pdf4QtDocPageOrganizer/resources.qrc @@ -33,12 +33,12 @@ resources/invert-selection.svg resources/regroup-alternating.svg resources/regroup-alternating-reversed.svg - resources/regroup-bookmarks.svg resources/regroup-even-odd.svg resources/regroup-pairs.svg resources/undo.svg resources/redo.svg resources/bookmark.svg resources/wallet.svg + resources/regroup-outline.svg diff --git a/Pdf4QtDocPageOrganizer/resources/regroup-bookmarks.svg b/Pdf4QtDocPageOrganizer/resources/regroup-outline.svg similarity index 100% rename from Pdf4QtDocPageOrganizer/resources/regroup-bookmarks.svg rename to Pdf4QtDocPageOrganizer/resources/regroup-outline.svg diff --git a/Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.cpp b/Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.cpp similarity index 52% rename from Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.cpp rename to Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.cpp index 59a4ed9..0483b82 100644 --- a/Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.cpp +++ b/Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.cpp @@ -15,8 +15,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with PDF4QT. If not, see . -#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(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 SelectBookmarksToRegroupDialog::getSelectedOutlineItems() const +std::vector 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& manipulator) { if (index.isValid()) @@ -98,7 +98,7 @@ void SelectBookmarksToRegroupDialog::manipulateTree(const QModelIndex& index, } } -std::function SelectBookmarksToRegroupDialog::createCheckByDepthManipulator(int targetDepth) const +std::function SelectOutlineToRegroupDialog::createCheckByDepthManipulator(int targetDepth) const { auto manipulator = [this, targetDepth](QModelIndex index) { @@ -119,42 +119,42 @@ std::function 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); }); } diff --git a/Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.h b/Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.h similarity index 77% rename from Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.h rename to Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.h index 023f43d..9864738 100644 --- a/Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.h +++ b/Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.h @@ -15,8 +15,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with PDF4QT. If not, see . -#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 getSelectedOutlineItems() const; @@ -62,7 +62,7 @@ private: std::function 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 diff --git a/Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.ui b/Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.ui similarity index 80% rename from Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.ui rename to Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.ui index d7e5a99..8a15a9c 100644 --- a/Pdf4QtDocPageOrganizer/selectbookmarkstoregroupdialog.ui +++ b/Pdf4QtDocPageOrganizer/selectoutlinetoregroupdialog.ui @@ -1,7 +1,7 @@ - SelectBookmarksToRegroupDialog - + SelectOutlineToRegroupDialog + 0 @@ -11,11 +11,11 @@ - Select Bookmarks + Select Outline - + @@ -34,7 +34,7 @@ buttonBox accepted() - SelectBookmarksToRegroupDialog + SelectOutlineToRegroupDialog accept() @@ -50,7 +50,7 @@ buttonBox rejected() - SelectBookmarksToRegroupDialog + SelectOutlineToRegroupDialog reject() diff --git a/Pdf4QtLibCore/sources/pdfdocumentsanitizer.cpp b/Pdf4QtLibCore/sources/pdfdocumentsanitizer.cpp index a6d4b74..4926bbf 100644 --- a/Pdf4QtLibCore/sources/pdfdocumentsanitizer.cpp +++ b/Pdf4QtLibCore/sources/pdfdocumentsanitizer.cpp @@ -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()); diff --git a/Pdf4QtLibCore/sources/pdfdocumentsanitizer.h b/Pdf4QtLibCore/sources/pdfdocumentsanitizer.h index 7eb2de7..828822a 100644 --- a/Pdf4QtLibCore/sources/pdfdocumentsanitizer.h +++ b/Pdf4QtLibCore/sources/pdfdocumentsanitizer.h @@ -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(); diff --git a/Pdf4QtViewer/pdf4qtviewer.qrc b/Pdf4QtViewer/pdf4qtviewer.qrc index cca5713..9633962 100644 --- a/Pdf4QtViewer/pdf4qtviewer.qrc +++ b/Pdf4QtViewer/pdf4qtviewer.qrc @@ -15,7 +15,6 @@ resources/settings.svg resources/zoom-in.svg resources/zoom-out.svg - resources/bookmark.svg resources/security.svg resources/zoom-fit.svg resources/zoom-fit-horizontal.svg @@ -104,5 +103,6 @@ resources/sidebar-speech.svg resources/sidebar-thumbnails.svg resources/sidebar-visibility.svg + resources/outline.svg diff --git a/Pdf4QtViewer/pdfsanitizedocumentdialog.cpp b/Pdf4QtViewer/pdfsanitizedocumentdialog.cpp index 93e34e3..0fa4c6d 100644 --- a/Pdf4QtViewer/pdfsanitizedocumentdialog.cpp +++ b/Pdf4QtViewer/pdfsanitizedocumentdialog.cpp @@ -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); diff --git a/Pdf4QtViewer/pdfsidebarwidget.cpp b/Pdf4QtViewer/pdfsidebarwidget.cpp index fe3d6dc..babe0a2 100644 --- a/Pdf4QtViewer/pdfsidebarwidget.cpp +++ b/Pdf4QtViewer/pdfsidebarwidget.cpp @@ -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() diff --git a/Pdf4QtViewer/pdfsidebarwidget.h b/Pdf4QtViewer/pdfsidebarwidget.h index 1a215e3..e65aee4 100644 --- a/Pdf4QtViewer/pdfsidebarwidget.h +++ b/Pdf4QtViewer/pdfsidebarwidget.h @@ -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 diff --git a/Pdf4QtViewer/pdfsidebarwidget.ui b/Pdf4QtViewer/pdfsidebarwidget.ui index 6e148b0..f6f6d9f 100644 --- a/Pdf4QtViewer/pdfsidebarwidget.ui +++ b/Pdf4QtViewer/pdfsidebarwidget.ui @@ -29,7 +29,7 @@ - + 96 @@ -42,7 +42,7 @@ - Bookmarks + Outline @@ -243,11 +243,11 @@ - 2 + 1 - - + + 0 @@ -264,7 +264,7 @@ 0 - + diff --git a/Pdf4QtViewer/resources/bookmark.svg b/Pdf4QtViewer/resources/outline.svg similarity index 100% rename from Pdf4QtViewer/resources/bookmark.svg rename to Pdf4QtViewer/resources/outline.svg