2004-09-08 12:41:14 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _KPDF_DOCUMENT_H_
|
|
|
|
#define _KPDF_DOCUMENT_H_
|
|
|
|
|
|
|
|
#include <qobject.h>
|
2004-09-17 17:58:42 +00:00
|
|
|
#include <qvaluevector.h>
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
class KPDFPage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @short Base class for objects being notified when something changes.
|
|
|
|
*
|
2004-09-15 20:45:00 +00:00
|
|
|
* Inherit this class and call KPDFDocument->addObserver( obsClass ) to get notified
|
|
|
|
* of asyncronous events (a new pixmap has arrived, changed, etc... ).
|
2004-09-08 12:41:14 +00:00
|
|
|
*/
|
|
|
|
class KPDFDocumentObserver
|
|
|
|
{
|
|
|
|
public:
|
2004-09-15 20:45:00 +00:00
|
|
|
// you must give each observer a unique ID (used for notifications)
|
|
|
|
virtual uint observerId() = 0;
|
|
|
|
|
2004-09-08 12:41:14 +00:00
|
|
|
// monitor changes in pixmaps (generation thread complete)
|
|
|
|
virtual void notifyPixmapChanged( int /*pageNumber*/ ) {};
|
|
|
|
|
2004-09-15 20:45:00 +00:00
|
|
|
// commands from the Document to all observers
|
2004-09-17 17:58:42 +00:00
|
|
|
virtual void pageSetup( const QValueVector<KPDFPage*> & /*pages*/, bool /*documentChanged*/ ) {};
|
2004-09-08 12:41:14 +00:00
|
|
|
virtual void pageSetCurrent( int /*pageNumber*/, float /*position*/ ) {};
|
|
|
|
};
|
|
|
|
|
2004-09-15 20:45:00 +00:00
|
|
|
#define PAGEWIDGET_ID 1
|
|
|
|
#define THUMBNAILS_ID 2
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
/**
|
2004-09-09 13:25:40 +00:00
|
|
|
* @short The information container. Actions (like open,find) take place here.
|
2004-09-08 12:41:14 +00:00
|
|
|
*
|
|
|
|
* xxxxxx
|
|
|
|
* yyy.
|
|
|
|
*/
|
|
|
|
class KPDFDocument : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2004-09-13 08:51:36 +00:00
|
|
|
|
2004-09-08 12:41:14 +00:00
|
|
|
public:
|
|
|
|
KPDFDocument();
|
|
|
|
~KPDFDocument();
|
|
|
|
|
|
|
|
// document handling
|
2004-09-17 17:58:42 +00:00
|
|
|
bool openDocument( const QString & docFile );
|
|
|
|
void closeDocument();
|
2004-09-08 12:41:14 +00:00
|
|
|
|
2004-09-09 21:16:26 +00:00
|
|
|
// query methods
|
2004-09-09 13:25:40 +00:00
|
|
|
uint currentPage() const;
|
2004-09-08 12:41:14 +00:00
|
|
|
uint pages() const;
|
2004-09-09 13:25:40 +00:00
|
|
|
bool atBegin() const;
|
|
|
|
bool atEnd() const;
|
|
|
|
const KPDFPage * page( uint page ) const;
|
2004-09-08 12:41:14 +00:00
|
|
|
|
2004-09-10 17:44:05 +00:00
|
|
|
// observers related methods
|
|
|
|
void addObserver( KPDFDocumentObserver * pObserver );
|
2004-09-15 20:45:00 +00:00
|
|
|
void requestPixmap( int id, uint page, int width, int height, bool syncronous = false );
|
2004-09-09 21:16:26 +00:00
|
|
|
|
2004-09-09 13:25:40 +00:00
|
|
|
public slots:
|
|
|
|
// document commands via slots
|
|
|
|
void slotSetCurrentPage( int page );
|
|
|
|
void slotSetCurrentPagePosition( int page, float position );
|
2004-09-16 21:27:34 +00:00
|
|
|
void slotSetFilter( const QString & pattern, bool caseSensitive );
|
2004-09-17 17:58:42 +00:00
|
|
|
void slotFind( const QString & text = "", bool caseSensitive = false );
|
|
|
|
void slotGoToLink( /* UnknownType unknown */ );
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
signals:
|
2004-09-09 13:25:40 +00:00
|
|
|
// notify changes via signals
|
2004-09-08 12:41:14 +00:00
|
|
|
void pageChanged();
|
|
|
|
|
|
|
|
private:
|
2004-09-17 17:58:42 +00:00
|
|
|
void processPageList( bool documentChanged );
|
|
|
|
void unHilightPages();
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
class KPDFDocumentPrivate * d;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|