diff --git a/active/components/pageitem.cpp b/active/components/pageitem.cpp index 4b55375aa..1a29142fa 100644 --- a/active/components/pageitem.cpp +++ b/active/components/pageitem.cpp @@ -220,6 +220,18 @@ void PageItem::goToBookmark(const QString &bookmark) } } +QPointF PageItem::bookmarkPosition(const QString &bookmark) const +{ + Okular::DocumentViewport viewPort(KUrl(bookmark).htmlRef()); + + if (viewPort.pageNumber != m_viewPort.pageNumber) { + return QPointF(-1, -1); + } + + return QPointF(qMax((qreal)0, width() - m_flickable.data()->width()) * viewPort.rePos.normalizedX, + qMax((qreal)0, height() - m_flickable.data()->height()) * viewPort.rePos.normalizedY); +} + void PageItem::setBookmarkAtPos(qreal x, qreal y) { Okular::DocumentViewport viewPort(m_viewPort); diff --git a/active/components/pageitem.h b/active/components/pageitem.h index a54468470..80780fd2e 100644 --- a/active/components/pageitem.h +++ b/active/components/pageitem.h @@ -111,6 +111,14 @@ public: */ Q_INVOKABLE void goToBookmark(const QString &bookmark); + /** + * Returns the position in the page for a bookmark + * QPointF(-1,-1) if doesn't belong to this page + * + * @param bookmark Url for the bookmark + */ + Q_INVOKABLE QPointF bookmarkPosition(const QString &bookmark) const; + /** * Add a new bookmark ar a given position of the current page */