part.h 5.23 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

Albert Astals Cid's avatar
Albert Astals Cid committed
46
namespace oKular {
47 48 49 50 51 52 53 54 55 56 57

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
 */
Albert Astals Cid's avatar
Albert Astals Cid committed
58
class Part : public KParts::ReadOnlyPart, public DocumentObserver, virtual public okular_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

Piotr Szymanski's avatar
Piotr Szymanski committed
82 83 84
signals:
	void enablePrintAction(bool enable);

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

94
protected slots:
95
	// connected to actions
Piotr Szymanski's avatar
Piotr Szymanski committed
96
	void openURLFromDocument(const KURL &url);
97 98 99
	void slotGoToPage();
	void slotPreviousPage();
	void slotNextPage();
100 101
	void slotGotoFirst();
	void slotGotoLast();
102 103
	void slotHistoryBack();
	void slotHistoryNext();
104 105
	void slotFind();
	void slotFindNext();
106
	void slotSaveFileAs();
Enrico Ros's avatar
Enrico Ros committed
107
	void slotGetNewStuff();
108 109 110
	void slotPreferences();
	void slotNewConfig();
	void slotPrintPreview();
111
	void slotShowMenu(const KPDFPage *page, const QPoint &point);
Albert Astals Cid's avatar
Albert Astals Cid committed
112
	void slotShowProperties();
113
	void slotShowLeftPanel();
114
	void slotShowPresentation();
115
	void slotHidePresentation();
116
	bool slotImportPSFile();
Piotr Szymanski's avatar
Piotr Szymanski committed
117 118 119 120
	void close();
	void cannotQuit();
	void setMimeTypes(KIO::Job *job);
    void saveSplitterSize();
121
	// can be connected to widget elements
122
	void updateViewActions();
123
	void enableTOC(bool enable);
124

125
public slots:
126
	// connected to Shell action (and browserExtension), not local one
127
	void slotPrint();
Albert Astals Cid's avatar
Albert Astals Cid committed
128 129 130 131
	void restoreDocument(const KURL &url, int page);
	void saveDocumentRestoreInfo(KConfig* config);
	void slotFileDirty( const QString& );
	void slotDoFileDirty();
132
	void psTransformEnded();
133

134 135
private:
	void doPrint( KPrinter& printer );
136
    void fillGenerators();
137

138
	// the document
139
	KPDFDocument * m_document;
140
	QString m_temporaryLocalFile;
141 142

	// main widgets
143
	QSplitter *m_splitter;
144
	QWidget *m_leftPanel;
145
	QToolBox *m_toolBox;
146
	SearchWidget *m_searchWidget;
147
	ThumbnailList *m_thumbnailList;
148
	PageView *m_pageView;
149
	QGuardedPtr<PresentationWidget> m_presentationWidget;
150

151
	// document watcher (and reloader) variables
Albert Astals Cid's avatar
Albert Astals Cid committed
152 153
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
154
	DocumentViewport m_viewportDirty;
155 156 157 158 159 160 161

	// actions
	KAction *m_gotoPage;
	KAction *m_prevPage;
	KAction *m_nextPage;
	KAction *m_firstPage;
	KAction *m_lastPage;
162 163
	KAction *m_historyBack;
	KAction *m_historyNext;
164 165
	KAction *m_find;
	KAction *m_findNext;
166 167
	KAction *m_saveAs;
	KAction *m_printPreview;
Albert Astals Cid's avatar
Albert Astals Cid committed
168
	KAction *m_showProperties;
169
	KAction *m_showPresentation;
170
	KToggleAction* m_showMenuBarAction;
171
	KToggleAction* m_showLeftPanel;
Albert Astals Cid's avatar
Albert Astals Cid committed
172 173
	KToggleAction* m_showFullScreenAction;
	bool m_actionsSearched;
174
	bool m_searchStarted;
175
	BrowserExtension *m_bExtension;
176 177 178 179 180

    // QDict: key is the name of the generator
    QDict<Generator> m_loadedGenerators;
    // list of names of the generators that have settings
    QStringList m_generatorsWithSettings;
Piotr Szymanski's avatar
Piotr Szymanski committed
181
    QStringList m_supportedMimeTypes;
182 183 184 185
    KSelectAction * m_confGens;

    private slots:
    void slotGeneratorPreferences();
186
};
Wilco Greven's avatar
Wilco Greven committed
187

188

189 190 191 192 193
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
194
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
195

196
public slots:
197 198
	// Automatically detected by the host.
	void print();
199
};
200

201 202 203 204 205
}

#endif

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