document.h 3.12 KB
Newer Older
1 2
/***************************************************************************
 *   Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>                  *
Albert Astals Cid's avatar
Albert Astals Cid committed
3
 *   Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es>            *
4 5 6 7 8 9 10 11 12 13 14
 *                                                                         *
 *   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>
15
#include <qvaluevector.h>
16

Albert Astals Cid's avatar
Albert Astals Cid committed
17 18
class KPrinter;

Albert Astals Cid's avatar
Albert Astals Cid committed
19 20
class Outline;

21
class KPDFPage;
22
class KPDFLink;
23 24 25 26

/**
 * @short Base class for objects being notified when something changes.
 *
27 28
 * Inherit this class and call KPDFDocument->addObserver( obsClass ) to get notified
 * of asyncronous events (a new pixmap has arrived, changed, etc... ).
29 30 31 32
 */
class KPDFDocumentObserver
{
public:
33
    // you must give each observer a unique ID (used for notifications)
Laurent Montel's avatar
Laurent Montel committed
34
    virtual uint observerId() const = 0;
35

36 37 38
    // monitor changes in pixmaps (generation thread complete)
    virtual void notifyPixmapChanged( int /*pageNumber*/ ) {};

39
    // commands from the Document to all observers
40
    virtual void pageSetup( const QValueVector<KPDFPage*> & /*pages*/, bool /*documentChanged*/ ) {};
Enrico Ros's avatar
Enrico Ros committed
41
    virtual void pageSetCurrent( int /*pageNumber*/, const QRect & /*viewport*/ = QRect() ) {};
42 43
};

44
#define PAGEVIEW_ID 1
45
#define THUMBNAILS_ID 2
46
#define TOC_ID 3
47 48

/**
49
 * @short The information container. Actions (like open,find) take place here.
50 51 52 53 54 55 56
 *
 * xxxxxx
 * yyy.
 */
class KPDFDocument : public QObject
{
    Q_OBJECT
Enrico Ros's avatar
Enrico Ros committed
57

58 59 60 61 62
public:
    KPDFDocument();
    ~KPDFDocument();

    // document handling
63 64
    bool openDocument( const QString & docFile );
    void closeDocument();
65

66
    // query methods
67
    uint currentPage() const;
68
    uint pages() const;
69 70 71
    bool atBegin() const;
    bool atEnd() const;
    const KPDFPage * page( uint page ) const;
Albert Astals Cid's avatar
Albert Astals Cid committed
72
    Outline * outline() const;
73

74 75
    // observers related methods
    void addObserver( KPDFDocumentObserver * pObserver );
76
    void requestPixmap( int id, uint page, int width, int height, bool syncronous = false );
77
    void requestTextPage( uint page );
78

Albert Astals Cid's avatar
Albert Astals Cid committed
79 80 81
    bool okToPrint() const;
    bool print(KPrinter &printer);

Enrico Ros's avatar
misc  
Enrico Ros committed
82
//public slots: TODO remove me
83
    // document commands via slots
84
    void slotSetCurrentPage( int page, const QRect & viewport = QRect() );
85
    void slotSetFilter( const QString & pattern, bool caseSensitive );
86
    void slotToggleBookmark( int page );
87
    void slotFind( const QString & text = "", bool caseSensitive = false );
88
    void slotProcessLink( const KPDFLink * link );
89 90

signals:
91
    // notify changes via signals
92 93 94
    void pageChanged();

private:
95
    QString giveAbsolutePath( const QString & fileName );
96
    bool openRelativeFile( const QString & fileName );
97 98
    void processPageList( bool documentChanged );
    void unHilightPages();
99 100 101 102 103 104

    class KPDFDocumentPrivate * d;
};


#endif