part.h 5.38 KB
Newer Older
1 2 3 4 5 6 7
/***************************************************************************
 *   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>           *
Albert Astals Cid's avatar
Albert Astals Cid committed
8
 *   Copyright (C) 2004-2006 by Albert Astals Cid <tsdgeos@terra.es>       *
9 10 11 12 13 14 15
 *                                                                         *
 *   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 <qpointer.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

Pino Toscano's avatar
porting  
Pino Toscano committed
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 KToggleFullScreenAction;
36
class KSelectAction;
37 38
class KAboutData;
class KPrinter;
39

40
class KPDFDocument;
Albert Astals Cid's avatar
Albert Astals Cid committed
41
class ThumbnailList;
42
class ThumbnailController;
43
class PageView;
44
class PresentationWidget;
45
class SearchWidget;
Albert Astals Cid's avatar
Albert Astals Cid committed
46 47
class TOC;
class MiniBar;
48

Albert Astals Cid's avatar
Albert Astals Cid committed
49
namespace oKular {
50 51 52 53 54 55 56 57 58 59 60

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
61
class Part : public KParts::ReadOnlyPart, public DocumentObserver, virtual public okular_dcop
62
{
63 64 65 66
Q_OBJECT

public:
	// Default constructor
Albert Astals Cid's avatar
compile  
Albert Astals Cid committed
67
	Part(QWidget* parentWidget, QObject* parent, const QStringList& args);
68

69 70
	// Destructor
	~Part();
71

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

76
	static KAboutData* createAboutData();
77

78
	ASYNC goToPage(uint page);
Pino Toscano's avatar
porting  
Pino Toscano committed
79
	ASYNC openDocument(KUrl doc);
80
	uint pages();
Enrico Ros's avatar
Enrico Ros committed
81
	uint currentPage();
Pino Toscano's avatar
porting  
Pino Toscano committed
82
	KUrl currentDocument();
83

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

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

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

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

137 138
private:
	void doPrint( KPrinter& printer );
139
    void fillGenerators();
140

141
	// the document
142
	KPDFDocument * m_document;
143
	QString m_temporaryLocalFile;
144 145

	// main widgets
146
	QSplitter *m_splitter;
147
	QWidget *m_leftPanel;
148
	QToolBox *m_toolBox;
149
	SearchWidget *m_searchWidget;
150 151 152 153 154
	QPointer<ThumbnailList> m_thumbnailList;
	QPointer<PageView> m_pageView;
	QPointer<TOC> m_toc;
	QPointer<MiniBar> m_miniBar;
	QPointer<PresentationWidget> m_presentationWidget;
155

156
	// document watcher (and reloader) variables
Albert Astals Cid's avatar
Albert Astals Cid committed
157 158
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
159
	DocumentViewport m_viewportDirty;
160 161 162 163 164 165 166

	// actions
	KAction *m_gotoPage;
	KAction *m_prevPage;
	KAction *m_nextPage;
	KAction *m_firstPage;
	KAction *m_lastPage;
167 168
	KAction *m_historyBack;
	KAction *m_historyNext;
169 170
	KAction *m_find;
	KAction *m_findNext;
171 172
	KAction *m_saveAs;
	KAction *m_printPreview;
Albert Astals Cid's avatar
Albert Astals Cid committed
173
	KAction *m_showProperties;
174
	KAction *m_showEmbeddedFiles;
175
	KAction *m_showPresentation;
176
	KToggleAction* m_showMenuBarAction;
177
	KToggleAction* m_showLeftPanel;
178
	KToggleFullScreenAction* m_showFullScreenAction;
179

Albert Astals Cid's avatar
Albert Astals Cid committed
180
	bool m_actionsSearched;
181
	bool m_searchStarted;
182
	BrowserExtension *m_bExtension;
183

184 185
    // QHash: key is the name of the generator
   QHash<QString, Generator*> m_loadedGenerators;
186 187
    // list of names of the generators that have settings
    QStringList m_generatorsWithSettings;
Piotr Szymanski's avatar
Piotr Szymanski committed
188
    QStringList m_supportedMimeTypes;
189 190 191 192
    KSelectAction * m_confGens;

    private slots:
    void slotGeneratorPreferences();
193
};
Wilco Greven's avatar
Wilco Greven committed
194

195

196 197 198 199 200
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
201
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
202

203
public slots:
204 205
	// Automatically detected by the host.
	void print();
206
};
207

208 209 210 211 212
}

#endif

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