part.h 4.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/***************************************************************************
 *   Copyright (C) 2002 by Wilco Greven <greven@kde.org>                   *
 *   Copyright (C) 2003-2004 by Christophe Devriese                        *
 *                         <Christophe.Devriese@student.kuleuven.ac.be>    *
 *   Copyright (C) 2003 by Andy Goossens <andygoossens@telenet.be>         *
 *   Copyright (C) 2003 by Laurent Montel <montel@kde.org>                 *
 *   Copyright (C) 2004 by Dominique Devriese <devriese@kde.org>           *
 *   Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es>            *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/

16 17 18
#ifndef _KPDF_PART_H_
#define _KPDF_PART_H_

Wilco Greven's avatar
Wilco Greven committed
19
#include <kparts/browserextension.h>
20 21
#include <kparts/part.h>

22
#include "kpdf_dcop.h"
23
#include "document.h"
24

25
class QWidget;
26
class QSplitter;
27
class QToolBox;
28 29

class KURL;
30
class KAction;
31
class KConfig;
Albert Astals Cid's avatar
Albert Astals Cid committed
32
class KDirWatch;
33
class KToggleAction;
34
class KSelectAction;
35 36
class KAboutData;
class KPrinter;
37

Albert Astals Cid's avatar
Albert Astals Cid committed
38
class ThumbnailList;
39
class PageView;
40
class SearchWidget;
41

42 43 44 45 46 47 48 49 50 51 52 53
namespace KPDF {

class BrowserExtension;

/**
 * This is a "Part".  It that does all the real work in a KPart
 * application.
 *
 * @short Main Part
 * @author Wilco Greven <greven@kde.org>
 * @version 0.2
 */
54
class Part : public KParts::ReadOnlyPart, public KPDFDocumentObserver, virtual public kpdf_dcop
55
{
56 57 58 59
Q_OBJECT

public:
	// Default constructor
60 61
	Part(QWidget* parentWidget, const char* widgetName,
	     QObject* parent, const char* name, const QStringList& args);
62

63 64
	// Destructor
	~Part();
65

66 67 68 69
    // inherited from KPDFDocumentObserver
    uint observerId() const { return PART_ID; }
    void pageSetCurrent( int pageNumber, const QRect & viewport );

70
	static KAboutData* createAboutData();
71

72 73 74
	ASYNC goToPage(uint page);
	ASYNC openDocument(KURL doc);
	uint pages();
75

76
protected:
77
	// reimplemented from KParts::ReadOnlyPart
78 79
	bool openFile();
	bool openURL(const KURL &url);
80
	bool closeURL();
Laurent Montel's avatar
Laurent Montel committed
81

82
protected slots:
83 84 85 86
	// connected to actions
	void slotGoToPage();
	void slotPreviousPage();
	void slotNextPage();
87 88
	void slotGotoFirst();
	void slotGotoLast();
89 90
	void slotFind();
	void slotFindNext();
Enrico Ros's avatar
Enrico Ros committed
91 92 93 94
    void slotSaveFileAs();
    void slotPreferences();
    void slotNewConfig();
    void slotPrintPreview();
95
	void slotShowMenu(const KPDFPage *page, const QPoint &point);
Albert Astals Cid's avatar
Albert Astals Cid committed
96
	void slotShowProperties();
97
    void slotShowPresentation();
98
	// can be connected to widget elements
99
	void updateActions();
100
	void enableTOC(bool enable);
101

102
public slots:
103
	// connected to Shell action (and browserExtension), not local one
104
	void slotPrint();
Albert Astals Cid's avatar
Albert Astals Cid committed
105 106 107 108 109
	void restoreDocument(const KURL &url, int page);
	void saveDocumentRestoreInfo(KConfig* config);
	void slotWatchFile();
	void slotFileDirty( const QString& );
	void slotDoFileDirty();
110

111 112 113
private:
	void doPrint( KPrinter& printer );

114
	// the document
115
	KPDFDocument * m_document;
116 117

	// main widgets
118
	QSplitter *m_splitter;
119
	QToolBox *m_toolBox;
120
	ThumbnailList *m_thumbnailList;
121
	PageView *m_pageView;
122
	SearchWidget *m_searchWidget;
123 124 125

	// static instances counter
	static unsigned int m_count;
Albert Astals Cid's avatar
Albert Astals Cid committed
126 127 128
	
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
129 130 131 132 133 134 135 136 137

	// actions
	KAction *m_gotoPage;
	KAction *m_prevPage;
	KAction *m_nextPage;
	KAction *m_firstPage;
	KAction *m_lastPage;
	KAction *m_find;
	KAction *m_findNext;
Albert Astals Cid's avatar
Albert Astals Cid committed
138
	KAction *m_showProperties;
139
    KAction *m_showPresentation;
Albert Astals Cid's avatar
Albert Astals Cid committed
140
	KToggleAction* m_watchFile;
141
	KToggleAction* m_showMenuBarAction;
Albert Astals Cid's avatar
Albert Astals Cid committed
142 143
	KToggleAction* m_showFullScreenAction;
	bool m_actionsSearched;
144
};
Wilco Greven's avatar
Wilco Greven committed
145

146

147 148 149 150 151
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
152
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
153

154
public slots:
155 156
	// Automatically detected by the host.
	void print();
157
};
158

159 160 161 162 163
}

#endif

// vim:ts=2:sw=2:tw=78:et