mirror of https://github.com/JakubMelka/PDF4QT.git
Issue #76: Modify document, when bookmarks are changed
This commit is contained in:
parent
bf53e7419b
commit
73024fbe99
|
@ -522,6 +522,12 @@ void PDFOutlineTreeItemModel::setDestination(const QModelIndex& index, const PDF
|
|||
}
|
||||
}
|
||||
|
||||
const PDFOutlineItem* PDFOutlineTreeItemModel::getRootOutlineItem() const
|
||||
{
|
||||
PDFOutlineTreeItem* item = static_cast<PDFOutlineTreeItem*>(m_rootItem.get());
|
||||
return item->getOutlineItem();
|
||||
}
|
||||
|
||||
bool PDFOutlineTreeItemModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (!m_editable || !index.isValid() || role != Qt::EditRole)
|
||||
|
|
|
@ -211,6 +211,8 @@ public:
|
|||
void setFontItalics(const QModelIndex& index, bool value);
|
||||
void setDestination(const QModelIndex& index, const PDFDestination& destination);
|
||||
|
||||
const PDFOutlineItem* getRootOutlineItem() const;
|
||||
|
||||
private:
|
||||
QIcon m_icon;
|
||||
bool m_editable;
|
||||
|
|
|
@ -285,6 +285,7 @@ public:
|
|||
void performSaveAs();
|
||||
|
||||
void onActionTriggered(const pdf::PDFAction* action);
|
||||
void onDocumentModified(pdf::PDFModifiedDocument document);
|
||||
void updateActionsAvailability();
|
||||
|
||||
bool getIsBusy() const;
|
||||
|
@ -356,7 +357,6 @@ private:
|
|||
void onDrawSpaceChanged();
|
||||
void onPageLayoutChanged();
|
||||
void onDocumentReadingFinished();
|
||||
void onDocumentModified(pdf::PDFModifiedDocument document);
|
||||
void onDocumentUndoRedo(pdf::PDFModifiedDocument document);
|
||||
void onQueryPasswordRequest(QString* password, bool* ok);
|
||||
void onPageRenderingErrorsChanged(pdf::PDFInteger pageIndex, int errorsCount);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "pdfexception.h"
|
||||
#include "pdfsignaturehandler.h"
|
||||
#include "pdfdrawspacecontroller.h"
|
||||
#include "pdfdocumentbuilder.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
@ -88,6 +89,10 @@ PDFSidebarWidget::PDFSidebarWidget(pdf::PDFDrawWidgetProxy* proxy,
|
|||
ui->bookmarksTreeView->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
ui->bookmarksTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->bookmarksTreeView, &QTreeView::customContextMenuRequested, this, &PDFSidebarWidget::onBookmarksTreeViewContextMenuRequested);
|
||||
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);
|
||||
|
@ -862,6 +867,19 @@ void PDFSidebarWidget::onBookmarksTreeViewContextMenuRequested(const QPoint& pos
|
|||
contextMenu.exec(ui->bookmarksTreeView->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void PDFSidebarWidget::onOutlineItemsChanged()
|
||||
{
|
||||
if (m_document)
|
||||
{
|
||||
pdf::PDFDocumentBuilder builder(m_document);
|
||||
builder.setOutline(m_outlineTreeModel->getRootOutlineItem());
|
||||
|
||||
pdf::PDFDocumentPointer pointer(new pdf::PDFDocument(builder.build()));
|
||||
pdf::PDFModifiedDocument document(qMove(pointer), m_optionalContentActivity, pdf::PDFModifiedDocument::None);
|
||||
Q_EMIT documentModified(qMove(document));
|
||||
}
|
||||
}
|
||||
|
||||
void PDFSidebarWidget::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
|
||||
signals:
|
||||
void actionTriggered(const pdf::PDFAction* action);
|
||||
void documentModified(pdf::PDFModifiedDocument document);
|
||||
|
||||
private:
|
||||
void updateGUI(Page preferredPage);
|
||||
|
@ -113,6 +114,7 @@ private:
|
|||
void onThumbnailClicked(const QModelIndex& index);
|
||||
void onSignatureCustomContextMenuRequested(const QPoint &pos);
|
||||
void onBookmarksTreeViewContextMenuRequested(const QPoint &pos);
|
||||
void onOutlineItemsChanged();
|
||||
|
||||
struct PageInfo
|
||||
{
|
||||
|
|
|
@ -261,6 +261,7 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
|
|||
addDockWidget(Qt::LeftDockWidgetArea, m_sidebarDockWidget);
|
||||
m_sidebarDockWidget->hide();
|
||||
connect(m_sidebarWidget, &PDFSidebarWidget::actionTriggered, m_programController, &PDFProgramController::onActionTriggered);
|
||||
connect(m_sidebarWidget, &PDFSidebarWidget::documentModified, m_programController, &PDFProgramController::onDocumentModified);
|
||||
|
||||
m_advancedFindWidget = new PDFAdvancedFindWidget(m_programController->getPdfWidget()->getDrawWidgetProxy(), this);
|
||||
m_advancedFindDockWidget = new QDockWidget(tr("Advanced find"), this);
|
||||
|
|
|
@ -196,6 +196,7 @@ PDFViewerMainWindowLite::PDFViewerMainWindowLite(QWidget* parent) :
|
|||
addDockWidget(Qt::LeftDockWidgetArea, m_sidebarDockWidget);
|
||||
m_sidebarDockWidget->hide();
|
||||
connect(m_sidebarWidget, &PDFSidebarWidget::actionTriggered, m_programController, &PDFProgramController::onActionTriggered);
|
||||
connect(m_sidebarWidget, &PDFSidebarWidget::documentModified, m_programController, &PDFProgramController::onDocumentModified);
|
||||
|
||||
ui->menuView->addSeparator();
|
||||
ui->menuView->addAction(m_sidebarDockWidget->toggleViewAction());
|
||||
|
|
Loading…
Reference in New Issue