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
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* GNU Library General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* 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 10:12:56 +00:00
|
|
|
#include <okular/core/document.h>
|
2012-05-14 18:37:22 +00:00
|
|
|
#include <okular/core/observer.h>
|
|
|
|
|
|
|
|
namespace Okular {
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Observer;
|
|
|
|
|
|
|
|
class DocumentItem : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
2012-05-15 11:50:16 +00:00
|
|
|
Q_PROPERTY(int currentPage READ currentPage WRITE setCurrentPage NOTIFY currentPageChanged)
|
2012-05-14 18:37:22 +00:00
|
|
|
Q_PROPERTY(bool opened READ isOpened NOTIFY openedChanged)
|
|
|
|
Q_PROPERTY(int pageCount READ pageCount NOTIFY pageCountChanged)
|
2012-05-15 10:12:56 +00:00
|
|
|
Q_PROPERTY(bool searchInProgress READ isSearchInProgress NOTIFY searchInProgressChanged)
|
|
|
|
Q_PROPERTY(QList<int> matchingPages READ matchingPages NOTIFY matchingPagesChanged)
|
2012-05-14 18:37:22 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DocumentItem(QObject *parent=0);
|
|
|
|
~DocumentItem();
|
|
|
|
|
|
|
|
void setPath(const QString &path);
|
|
|
|
QString path() 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 10:12:56 +00:00
|
|
|
bool isSearchInProgress() const;
|
|
|
|
|
|
|
|
QList<int> matchingPages() 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();
|
|
|
|
|
2012-05-14 18:37:22 +00:00
|
|
|
//Internal, not binded to qml
|
|
|
|
Okular::Document *document();
|
|
|
|
Observer *observerFor(int id);
|
|
|
|
|
|
|
|
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 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;
|
|
|
|
QHash <int, Observer *> m_observers;
|
2012-05-15 10:12:56 +00:00
|
|
|
QList<int> m_matchingPages;
|
|
|
|
bool m_searchInProgress;
|
2012-05-14 18:37:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Observer : public QObject, public Okular::DocumentObserver
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Observer(DocumentItem *parent, int observerId);
|
|
|
|
~Observer();
|
|
|
|
|
|
|
|
// inherited from DocumentObserver
|
|
|
|
uint observerId() const { return m_observerId; }
|
|
|
|
void notifyPageChanged(int page, int flags);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void pageChanged(int page, int flags);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_observerId;
|
|
|
|
DocumentItem *m_document;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|