part.h 4.68 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 <qguardedptr.h>
22
#include "core/observer.h"
23
#include "core/document.h"
24
#include "dcop.h"
25

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

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

39
class KPDFDocument;
Albert Astals Cid's avatar
Albert Astals Cid committed
40
class ThumbnailList;
41
class ThumbnailController;
42
class PageView;
43
class PresentationWidget;
44
class SearchWidget;
45

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

public:
	// Default constructor
64 65
	Part(QWidget* parentWidget, const char* widgetName,
	     QObject* parent, const char* name, const QStringList& args);
66

67 68
	// Destructor
	~Part();
69

70
    // inherited from DocumentObserver
71
    uint observerId() const { return PART_ID; }
Enrico Ros's avatar
Enrico Ros committed
72
    void notifyViewportChanged( bool smoothMove );
73

74
	static KAboutData* createAboutData();
75

76 77 78
	ASYNC goToPage(uint page);
	ASYNC openDocument(KURL doc);
	uint pages();
Enrico Ros's avatar
Enrico Ros committed
79 80
	uint currentPage();
	KURL currentDocument();
81

82
protected:
83
	// reimplemented from KParts::ReadOnlyPart
84 85
	bool openFile();
	bool openURL(const KURL &url);
86
	bool closeURL();
87 88
	// filter that watches for splitter size changes
	bool eventFilter( QObject * watched, QEvent * e );
Laurent Montel's avatar
Laurent Montel committed
89

90
protected slots:
91 92 93 94
	// connected to actions
	void slotGoToPage();
	void slotPreviousPage();
	void slotNextPage();
95 96
	void slotGotoFirst();
	void slotGotoLast();
97 98
	void slotHistoryBack();
	void slotHistoryNext();
99 100
	void slotFind();
	void slotFindNext();
101
	void slotSaveFileAs();
Enrico Ros's avatar
Enrico Ros committed
102
	void slotGetNewStuff();
103 104 105
	void slotPreferences();
	void slotNewConfig();
	void slotPrintPreview();
106
	void slotShowMenu(const KPDFPage *page, const QPoint &point);
Albert Astals Cid's avatar
Albert Astals Cid committed
107
	void slotShowProperties();
108
	void slotShowLeftPanel();
109
	void slotShowPresentation();
110
	void slotHidePresentation();
111
	bool slotImportPSFile();
112
	// can be connected to widget elements
113
	void updateViewActions();
114
	void enableTOC(bool enable);
115

116
public slots:
117
	// connected to Shell action (and browserExtension), not local one
118
	void slotPrint();
Albert Astals Cid's avatar
Albert Astals Cid committed
119 120 121 122
	void restoreDocument(const KURL &url, int page);
	void saveDocumentRestoreInfo(KConfig* config);
	void slotFileDirty( const QString& );
	void slotDoFileDirty();
123
	void psTransformEnded();
124

125 126 127
private:
	void doPrint( KPrinter& printer );

128
	// the document
129
	KPDFDocument * m_document;
130
	QString m_temporaryLocalFile;
131 132

	// main widgets
133
	QSplitter *m_splitter;
134
	QWidget *m_leftPanel;
135
	QToolBox *m_toolBox;
136
	SearchWidget *m_searchWidget;
137
	ThumbnailList *m_thumbnailList;
138
	PageView *m_pageView;
139
	QGuardedPtr<PresentationWidget> m_presentationWidget;
140

141
	// document watcher (and reloader) variables
Albert Astals Cid's avatar
Albert Astals Cid committed
142 143
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
144
	DocumentViewport m_viewportDirty;
145 146 147 148 149 150 151

	// actions
	KAction *m_gotoPage;
	KAction *m_prevPage;
	KAction *m_nextPage;
	KAction *m_firstPage;
	KAction *m_lastPage;
152 153
	KAction *m_historyBack;
	KAction *m_historyNext;
154 155
	KAction *m_find;
	KAction *m_findNext;
156 157
	KAction *m_saveAs;
	KAction *m_printPreview;
Albert Astals Cid's avatar
Albert Astals Cid committed
158
	KAction *m_showProperties;
159
	KAction *m_showPresentation;
160
	KToggleAction* m_showMenuBarAction;
161
	KToggleAction* m_showLeftPanel;
Albert Astals Cid's avatar
Albert Astals Cid committed
162 163
	KToggleAction* m_showFullScreenAction;
	bool m_actionsSearched;
164
	bool m_searchStarted;
165
	BrowserExtension *m_bExtension;
166
};
Wilco Greven's avatar
Wilco Greven committed
167

168

169 170 171 172 173
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
174
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
175

176
public slots:
177 178
	// Automatically detected by the host.
	void print();
179
};
180

181 182 183 184 185
}

#endif

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