read only access to bookmarks

This commit is contained in:
Marco Martin 2012-08-01 18:00:56 +02:00
parent 1d5b80334e
commit e5a77cc8c7
5 changed files with 34 additions and 0 deletions

View file

@ -228,6 +228,19 @@ MobileComponents.OverlayDrawer {
}
}
}
PlasmaComponents.TabButton {
id: bookmarksButton
text: i18n("Bookmarks")
tab: tableOfContents
property bool current: mainTabBar.currentTab == bookmarksButton
onCurrentChanged: {
if (current) {
var page = pageStack.replace(Qt.createComponent("Thumbnails.qml"))
page.model = documentItem.bookmarks
page.toolBarVisible = false
}
}
}
}
}
Behavior on y {

View file

@ -26,13 +26,17 @@ import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
PlasmaComponents.Page {
property alias contentY: resultsGrid.contentY
property alias model: resultsGrid.model
property bool toolBarVisible: true
anchors.fill: parent
tools: Item {
id: toolBarContent
width: resultsGrid.width
height: searchField.height
MobileComponents.ViewSearch {
id: searchField
visible: toolBarVisible
enabled: documentItem.supportsSearch
anchors.centerIn: parent
busy: documentItem.searchInProgress

View file

@ -27,6 +27,7 @@ target_link_libraries(okularplugin
${QT_QTXML_LIBRARY}
${KDE4_KDECORE_LIBRARY}
${KDE4_KDEUI_LIBRARY}
${KDE4_KIO_LIBRARY}
${QIMAGEBLITZ_LIBRARIES}
okularcore
)

View file

@ -22,6 +22,7 @@
#include <QtDeclarative/qdeclarative.h>
#include <core/page.h>
#include <core/bookmarkmanager.h>
#include "tocmodel.h"
@ -36,6 +37,8 @@ DocumentItem::DocumentItem(QObject *parent)
connect(m_document, SIGNAL(searchFinished(int,Okular::Document::SearchStatus)),
this, SLOT(searchFinished(int,Okular::Document::SearchStatus)));
connect(m_document, SIGNAL(bookmarksChanged(KUrl)),
this, SIGNAL(bookmarksChanged()));
}
@ -100,6 +103,15 @@ TOCModel *DocumentItem::tableOfContents() const
return m_tocModel;
}
QList<int> DocumentItem::bookmarks() const
{
QList<int> list;
foreach (KBookmark bookmark, m_document->bookmarkManager()->bookmarks()) {
list << bookmark.url().fragment().split(";").first().toInt();
}
return list;
}
bool DocumentItem::supportsSearching() const
{
return m_document->supportsSearching();

View file

@ -46,6 +46,7 @@ class DocumentItem : public QObject
Q_PROPERTY(bool searchInProgress READ isSearchInProgress NOTIFY searchInProgressChanged)
Q_PROPERTY(QList<int> matchingPages READ matchingPages NOTIFY matchingPagesChanged)
Q_PROPERTY(TOCModel *tableOfContents READ tableOfContents CONSTANT)
Q_PROPERTY(QList<int> bookmarks READ bookmarks NOTIFY bookmarksChanged)
public:
@ -70,6 +71,8 @@ public:
TOCModel *tableOfContents() const;
QList<int> bookmarks() const;
//Those could be a property, but maybe we want to have parameter for searchText
Q_INVOKABLE void searchText(const QString &text);
Q_INVOKABLE void resetSearch();
@ -86,6 +89,7 @@ Q_SIGNALS:
void matchingPagesChanged();
void currentPageChanged();
void supportsSearchingChanged();
void bookmarksChanged();
private Q_SLOTS:
void searchFinished(int id, Okular::Document::SearchStatus endStatus);