diff --git a/active/app/package/contents/ui/Bookmarks.qml b/active/app/package/contents/ui/Bookmarks.qml index 55702ade9..a51e7b3fe 100644 --- a/active/app/package/contents/ui/Bookmarks.qml +++ b/active/app/package/contents/ui/Bookmarks.qml @@ -22,4 +22,7 @@ import QtQuick 1.1 ThumbnailsBase { model: documentItem.bookmarkedPages + onPageClicked: { + pageArea.delegate.pageItem.goToBookmark(pageArea.delegate.pageItem.bookmarks[0]) + } } \ No newline at end of file diff --git a/active/app/package/contents/ui/FullScreenDelegate.qml b/active/app/package/contents/ui/FullScreenDelegate.qml index f94b32cfe..7b4c4369e 100644 --- a/active/app/package/contents/ui/FullScreenDelegate.qml +++ b/active/app/package/contents/ui/FullScreenDelegate.qml @@ -45,6 +45,7 @@ MouseEventListener { property bool pageSwitchEnabled: false property alias document: mainPage.document property alias pageNumber: mainPage.pageNumber + property Item pageItem: mainPage property string label: model["label"] diff --git a/active/app/package/contents/ui/ThumbnailsBase.qml b/active/app/package/contents/ui/ThumbnailsBase.qml index 5f2435943..d6350b027 100644 --- a/active/app/package/contents/ui/ThumbnailsBase.qml +++ b/active/app/package/contents/ui/ThumbnailsBase.qml @@ -25,9 +25,11 @@ import org.kde.plasma.extras 0.1 as PlasmaExtras import org.kde.plasma.mobilecomponents 0.1 as MobileComponents PlasmaComponents.Page { + id: root property alias contentY: resultsGrid.contentY property alias contentHeight: resultsGrid.contentHeight property alias model: resultsGrid.model + signal pageClicked(int pageNumber) anchors.fill: parent @@ -88,6 +90,7 @@ PlasmaComponents.Page { documentItem.currentPage = modelData resourceBrowser.open = false + root.pageClicked(modelData) } } } diff --git a/active/components/pageitem.cpp b/active/components/pageitem.cpp index 1a29142fa..a04a8dc3b 100644 --- a/active/components/pageitem.cpp +++ b/active/components/pageitem.cpp @@ -46,6 +46,8 @@ PageItem::PageItem(QDeclarativeItem *parent) m_observerId = PAGEVIEW_ID; setFlag(QGraphicsItem::ItemHasNoContents, false); + m_viewPort.rePos.enabled = true; + m_redrawTimer = new QTimer(this); m_redrawTimer->setInterval(REDRAW_TIMEOUT); m_redrawTimer->setSingleShot(true); @@ -189,7 +191,7 @@ void PageItem::setBookmarked(bool bookmarked) } if (bookmarked) { - m_documentItem.data()->document()->bookmarkManager()->addBookmark(m_viewPort.pageNumber); + m_documentItem.data()->document()->bookmarkManager()->addBookmark(m_viewPort); } else { m_documentItem.data()->document()->bookmarkManager()->removeBookmark(m_viewPort.pageNumber); } @@ -239,6 +241,29 @@ void PageItem::setBookmarkAtPos(qreal x, qreal y) viewPort.rePos.normalizedY = y; m_documentItem.data()->document()->bookmarkManager()->addBookmark(viewPort); + + if (!m_bookmarked) { + m_bookmarked = true; + emit bookmarkedChanged(); + } + + emit bookmarksChanged(); +} + +void PageItem::removeBookmarkAtPos(qreal x, qreal y) +{ + Okular::DocumentViewport viewPort(m_viewPort); + viewPort.rePos.enabled = true; + viewPort.rePos.normalizedX = x; + viewPort.rePos.normalizedY = y; + + m_documentItem.data()->document()->bookmarkManager()->addBookmark(viewPort); + + if (m_bookmarked && m_documentItem.data()->document()->bookmarkManager()->bookmarks(m_viewPort.pageNumber).count() == 0) { + m_bookmarked = false; + emit bookmarkedChanged(); + } + emit bookmarksChanged(); } @@ -344,7 +369,7 @@ void PageItem::contentXChanged() return; } - m_viewPort.rePos.normalizedX = m_flickable.data()->property("contentX").toReal(); + m_viewPort.rePos.normalizedX = m_flickable.data()->property("contentX").toReal() / (width() - m_flickable.data()->width()); } void PageItem::contentYChanged() @@ -353,7 +378,7 @@ void PageItem::contentYChanged() return; } - m_viewPort.rePos.normalizedY = m_flickable.data()->property("contentY").toReal(); + m_viewPort.rePos.normalizedY = m_flickable.data()->property("contentY").toReal() / (height() - m_flickable.data()->height()); } void PageItem::setIsThumbnail(bool thumbnail) diff --git a/active/components/pageitem.h b/active/components/pageitem.h index 80780fd2e..0db4080ee 100644 --- a/active/components/pageitem.h +++ b/active/components/pageitem.h @@ -124,6 +124,11 @@ public: */ Q_INVOKABLE void setBookmarkAtPos(qreal x, qreal y); + /** + * Remove a bookmark ar a given position of the current page (if present) + */ + Q_INVOKABLE void removeBookmarkAtPos(qreal x, qreal y); + /** * Remove a bookmark at a given position, if any */