okular/active/components/documentitem.h

108 lines
2.8 KiB
C
Raw Normal View History

/*
* 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.
*/
#ifndef QDOCUMENTITEM_H
#define QDOCUMENTITEM_H
#include <QObject>
#include "settings.h"
2012-05-15 10:12:56 +00:00
#include <okular/core/document.h>
#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)
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)
public:
DocumentItem(QObject *parent=0);
~DocumentItem();
void setPath(const QString &path);
QString path() const;
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();
//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();
private Q_SLOTS:
void searchFinished(int id, Okular::Document::SearchStatus endStatus);
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;
};
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