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
#include <kparts/part.h>
21
#include "core/observer.h"
22
#include "dcop.h"
23

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

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

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

43 44 45 46 47 48 49 50 51 52 53 54
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
 */
55
class Part : public KParts::ReadOnlyPart, public DocumentObserver, virtual public kpdf_dcop
56
{
57 58 59 60
Q_OBJECT

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

64 65
	// Destructor
	~Part();
66

67
    // inherited from DocumentObserver
68
    uint observerId() const { return PART_ID; }
69
    void notifyViewportChanged();
70

71
	static KAboutData* createAboutData();
72

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

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

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

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

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

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

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

	// static instances counter
	static unsigned int m_count;
127

Albert Astals Cid's avatar
Albert Astals Cid committed
128 129
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
130 131 132 133 134 135 136 137 138

	// 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
139
	KAction *m_showProperties;
140
	KAction *m_showPresentation;
Albert Astals Cid's avatar
Albert Astals Cid committed
141
	KToggleAction* m_watchFile;
142
	KToggleAction* m_showMenuBarAction;
Albert Astals Cid's avatar
Albert Astals Cid committed
143 144
	KToggleAction* m_showFullScreenAction;
	bool m_actionsSearched;
145
};
Wilco Greven's avatar
Wilco Greven committed
146

147

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

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

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

160 161 162 163 164
}

#endif

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