From 57311442b15b66f21e5e4c3ae5c2ab5454f0f1b7 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 15 May 2012 13:56:08 +0200 Subject: [PATCH] property that tells if the doc supports search --- active/app/package/contents/ui/Browser.qml | 1 + active/components/documentitem.cpp | 7 +++++++ active/components/documentitem.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/active/app/package/contents/ui/Browser.qml b/active/app/package/contents/ui/Browser.qml index f93d5c043..a91e62a98 100644 --- a/active/app/package/contents/ui/Browser.qml +++ b/active/app/package/contents/ui/Browser.qml @@ -200,6 +200,7 @@ PlasmaComponents.Page { height: searchField.height + 10 MobileComponents.ViewSearch { id: searchField + enabled: documentItem.supportsSearch anchors.centerIn: parent busy: documentItem.searchInProgress onSearchQueryChanged: { diff --git a/active/components/documentitem.cpp b/active/components/documentitem.cpp index b42a9a444..1037e540b 100644 --- a/active/components/documentitem.cpp +++ b/active/components/documentitem.cpp @@ -51,6 +51,7 @@ void DocumentItem::setPath(const QString &path) emit pathChanged(); emit pageCountChanged(); emit openedChanged(); + emit supportsSearchingChanged(); } QString DocumentItem::path() const @@ -84,6 +85,11 @@ QList DocumentItem::matchingPages() const return m_matchingPages; } +bool DocumentItem::supportsSearching() const +{ + return m_document->supportsSearching(); +} + bool DocumentItem::isSearchInProgress() const { return m_searchInProgress; @@ -95,6 +101,7 @@ void DocumentItem::searchText(const QString &text) resetSearch(); return; } + m_document->cancelSearch(); m_document->resetSearch(PAGEVIEW_SEARCH_ID); m_document->searchText(PAGEVIEW_SEARCH_ID, text, 1, Qt::CaseInsensitive, Okular::Document::AllDocument, true, QColor(100,100,200,40), true); diff --git a/active/components/documentitem.h b/active/components/documentitem.h index 01db0549e..a81f4b276 100644 --- a/active/components/documentitem.h +++ b/active/components/documentitem.h @@ -41,6 +41,7 @@ class DocumentItem : public QObject Q_PROPERTY(int currentPage READ currentPage WRITE setCurrentPage NOTIFY currentPageChanged) Q_PROPERTY(bool opened READ isOpened NOTIFY openedChanged) Q_PROPERTY(int pageCount READ pageCount NOTIFY pageCountChanged) + Q_PROPERTY(bool supportsSearching READ supportsSearching NOTIFY supportsSearchingChanged) Q_PROPERTY(bool searchInProgress READ isSearchInProgress NOTIFY searchInProgressChanged) Q_PROPERTY(QList matchingPages READ matchingPages NOTIFY matchingPagesChanged) @@ -59,6 +60,8 @@ public: int pageCount() const; + bool supportsSearching() const; + bool isSearchInProgress() const; QList matchingPages() const; @@ -78,6 +81,7 @@ Q_SIGNALS: void searchInProgressChanged(); void matchingPagesChanged(); void currentPageChanged(); + void supportsSearchingChanged(); private Q_SLOTS: void searchFinished(int id, Okular::Document::SearchStatus endStatus);