2012-05-14 19:16:56 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 by Marco Martin <mart@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2012-10-03 09:32:42 +00:00
|
|
|
* it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2,
|
|
|
|
* or (at your option) any later version.
|
2012-05-14 19:16:56 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-10-03 09:32:42 +00:00
|
|
|
* GNU General Public License for more details
|
2012-05-14 19:16:56 +00:00
|
|
|
*
|
2012-10-03 09:32:42 +00:00
|
|
|
* You should have received a copy of the GNU General Public
|
2012-05-14 19:16:56 +00:00
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
#ifndef QDOCUMENTITEM_H
|
|
|
|
#define QDOCUMENTITEM_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
2012-05-15 15:23:15 +00:00
|
|
|
#include <core/document.h>
|
|
|
|
#include <core/observer.h>
|
2012-05-14 18:37:22 +00:00
|
|
|
|
|
|
|
namespace Okular {
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Observer;
|
2012-07-31 14:28:54 +00:00
|
|
|
class TOCModel;
|
2012-05-14 18:37:22 +00:00
|
|
|
|
|
|
|
class DocumentItem : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2012-10-02 11:25:34 +00:00
|
|
|
/**
|
|
|
|
* Absolute path of the document file to open
|
|
|
|
*/
|
2012-05-14 18:37:22 +00:00
|
|
|
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
2012-10-02 11:25:34 +00:00
|
|
|
|
2012-10-03 10:06:02 +00:00
|
|
|
/**
|
|
|
|
* Suggested window title if a window represents this document. may be pathname or document title, dependeing from Okular settings.
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(QString windowTitleForDocument READ windowTitleForDocument NOTIFY windowTitleForDocumentChanged)
|
|
|
|
|
2012-10-02 11:25:34 +00:00
|
|
|
/**
|
|
|
|
* Current displaying page for the document
|
|
|
|
*/
|
2012-05-15 11:50:16 +00:00
|
|
|
Q_PROPERTY(int currentPage READ currentPage WRITE setCurrentPage NOTIFY currentPageChanged)
|
2012-10-02 11:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if this DocumentItem instance has a document file opened
|
|
|
|
*/
|
2012-05-14 18:37:22 +00:00
|
|
|
Q_PROPERTY(bool opened READ isOpened NOTIFY openedChanged)
|
2012-10-02 11:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* How many pages there are in the document
|
|
|
|
*/
|
2012-05-14 18:37:22 +00:00
|
|
|
Q_PROPERTY(int pageCount READ pageCount NOTIFY pageCountChanged)
|
2012-10-02 11:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the document is able to perform full text searches in its contents
|
|
|
|
*/
|
2012-05-15 11:56:08 +00:00
|
|
|
Q_PROPERTY(bool supportsSearching READ supportsSearching NOTIFY supportsSearchingChanged)
|
2012-10-02 11:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if a search is currently in progress and results didn't arrive yet
|
|
|
|
*/
|
2012-05-15 10:12:56 +00:00
|
|
|
Q_PROPERTY(bool searchInProgress READ isSearchInProgress NOTIFY searchInProgressChanged)
|
2012-10-02 11:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A list of all pages that contain a match for the search terms. If no text has been searched, all pages are returned.
|
|
|
|
*/
|
2014-12-17 18:16:25 +00:00
|
|
|
Q_PROPERTY(QVariantList matchingPages READ matchingPages NOTIFY matchingPagesChanged)
|
2012-10-02 11:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Table of contents for the document, if available
|
|
|
|
*/
|
2012-07-31 14:28:54 +00:00
|
|
|
Q_PROPERTY(TOCModel *tableOfContents READ tableOfContents CONSTANT)
|
2012-10-02 11:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of pages that contain a bookmark
|
|
|
|
*/
|
2015-09-18 16:22:28 +00:00
|
|
|
Q_PROPERTY(QVariantList bookmarkedPages READ bookmarkedPages NOTIFY bookmarkedPagesChanged)
|
2012-05-14 18:37:22 +00:00
|
|
|
|
2012-10-05 14:15:55 +00:00
|
|
|
/**
|
|
|
|
* list of bookmarks urls valid on this page
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(QStringList bookmarks READ bookmarks NOTIFY bookmarksChanged)
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
public:
|
|
|
|
|
2015-08-04 12:20:30 +00:00
|
|
|
explicit DocumentItem(QObject *parent=0);
|
2012-05-14 18:37:22 +00:00
|
|
|
~DocumentItem();
|
|
|
|
|
|
|
|
void setPath(const QString &path);
|
|
|
|
QString path() const;
|
|
|
|
|
2012-10-03 10:06:02 +00:00
|
|
|
QString windowTitleForDocument() const;
|
|
|
|
|
2012-05-15 11:50:16 +00:00
|
|
|
void setCurrentPage(int page);
|
|
|
|
int currentPage() const;
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
bool isOpened() const;
|
|
|
|
|
|
|
|
int pageCount() const;
|
|
|
|
|
2012-05-15 11:56:08 +00:00
|
|
|
bool supportsSearching() const;
|
|
|
|
|
2012-05-15 10:12:56 +00:00
|
|
|
bool isSearchInProgress() const;
|
|
|
|
|
2014-12-17 18:16:25 +00:00
|
|
|
QVariantList matchingPages() const;
|
2012-05-15 10:12:56 +00:00
|
|
|
|
2012-07-31 14:28:54 +00:00
|
|
|
TOCModel *tableOfContents() const;
|
|
|
|
|
2015-09-18 16:22:28 +00:00
|
|
|
QVariantList bookmarkedPages() const;
|
2012-08-01 16:00:56 +00:00
|
|
|
|
2012-10-05 14:15:55 +00:00
|
|
|
QStringList bookmarks() const;
|
|
|
|
|
2012-10-02 11:25:34 +00:00
|
|
|
//This could be a property, but maybe we want to have parameter for searchText
|
|
|
|
/**
|
|
|
|
* Performs a search in the document
|
|
|
|
*
|
|
|
|
* @param text the string to search in the document
|
|
|
|
*/
|
2012-05-15 10:12:56 +00:00
|
|
|
Q_INVOKABLE void searchText(const QString &text);
|
2012-10-02 11:25:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset the search over the document.
|
|
|
|
*/
|
2012-05-15 10:12:56 +00:00
|
|
|
Q_INVOKABLE void resetSearch();
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
//Internal, not binded to qml
|
|
|
|
Okular::Document *document();
|
2013-02-24 21:58:53 +00:00
|
|
|
Observer *pageviewObserver();
|
|
|
|
Observer *thumbnailObserver();
|
2012-05-14 18:37:22 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void pathChanged();
|
|
|
|
void pageCountChanged();
|
|
|
|
void openedChanged();
|
2012-05-15 10:12:56 +00:00
|
|
|
void searchInProgressChanged();
|
|
|
|
void matchingPagesChanged();
|
2012-05-15 11:50:16 +00:00
|
|
|
void currentPageChanged();
|
2012-05-15 11:56:08 +00:00
|
|
|
void supportsSearchingChanged();
|
2012-10-05 13:59:08 +00:00
|
|
|
void bookmarkedPagesChanged();
|
2012-10-05 14:15:55 +00:00
|
|
|
void bookmarksChanged();
|
2012-10-03 10:06:02 +00:00
|
|
|
void windowTitleForDocumentChanged();
|
2012-05-15 10:12:56 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void searchFinished(int id, Okular::Document::SearchStatus endStatus);
|
2012-05-14 18:37:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::Document *m_document;
|
2012-07-31 14:28:54 +00:00
|
|
|
TOCModel *m_tocModel;
|
2013-02-24 21:58:53 +00:00
|
|
|
Observer *m_thumbnailObserver;
|
|
|
|
Observer *m_pageviewObserver;
|
2014-12-17 18:16:25 +00:00
|
|
|
QVariantList m_matchingPages;
|
2012-05-15 10:12:56 +00:00
|
|
|
bool m_searchInProgress;
|
2012-05-14 18:37:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Observer : public QObject, public Okular::DocumentObserver
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-02-24 21:58:53 +00:00
|
|
|
Observer(DocumentItem *parent);
|
2012-05-14 18:37:22 +00:00
|
|
|
~Observer();
|
|
|
|
|
|
|
|
// inherited from DocumentObserver
|
|
|
|
void notifyPageChanged(int page, int flags);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void pageChanged(int page, int flags);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DocumentItem *m_document;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|