diff --git a/Pdf4QtViewer/pdfsidebarwidget.cpp b/Pdf4QtViewer/pdfsidebarwidget.cpp index 4d7de7a..c2469b4 100644 --- a/Pdf4QtViewer/pdfsidebarwidget.cpp +++ b/Pdf4QtViewer/pdfsidebarwidget.cpp @@ -939,13 +939,39 @@ void PDFSidebarWidget::onOutlineTreeViewContextMenuRequested(const QPoint& pos) auto onInsert = [this, proxyIndex]() { + QModelIndex insertProxyIndex; + + QAbstractItemModel* model = ui->outlineTreeView->model(); if (proxyIndex.isValid()) { - ui->outlineTreeView->model()->insertRow(proxyIndex.row() + 1, proxyIndex.parent()); + if (model->insertRow(proxyIndex.row() + 1, proxyIndex.parent())) + { + insertProxyIndex = proxyIndex.sibling(proxyIndex.row() + 1, 0); + } } else { - ui->outlineTreeView->model()->insertRow(ui->outlineTreeView->model()->rowCount()); + if (model->insertRow(model->rowCount())) + { + insertProxyIndex = model->index(model->rowCount() - 1, 0); + } + } + + if (insertProxyIndex.isValid()) + { + std::vector pages = m_proxy->getWidget()->getDrawWidget()->getCurrentPages(); + + if (!pages.empty()) + { + QModelIndex sourceInsertIndex = m_outlineSortProxyTreeModel->mapToSource(insertProxyIndex); + + pdf::PDFDestination destination; + destination.setDestinationType(pdf::DestinationType::Fit); + destination.setPageIndex(pages.front()); + destination.setPageReference(m_document->getCatalog()->getPage(pages.front())->getPageReference()); + destination.setZoom(m_proxy->getZoom()); + m_outlineTreeModel->setDestination(sourceInsertIndex, destination); + } } }; diff --git a/RELEASES.txt b/RELEASES.txt index d202b20..a492edc 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -1,4 +1,5 @@ CURRENT: + - Issue #140: New bookmarks created empty? - Issue #139: Changing page layout reset the current page - Issue #137: Redaction - Cannot convert '#000000' to color value - Issue #134: Add search bar for actions