bookmarkPosition function

This commit is contained in:
Marco Martin 2012-10-12 11:05:31 +02:00
parent f59404ed02
commit 6de4500fd1
2 changed files with 20 additions and 0 deletions

View file

@ -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);

View file

@ -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
*/