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

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 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;
Albert Astals Cid's avatar
Albert Astals Cid committed
45 46
class TOC;
class MiniBar;
47

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

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

public:
	// Default constructor
66 67
	Part(QWidget* parentWidget, const char* widgetName,
	     QObject* parent, const char* name, 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 slotShowLeftPanel();
116
	void slotShowPresentation();
117
	void slotHidePresentation();
118
	bool slotImportPSFile();
Piotr Szymanski's avatar
Piotr Szymanski committed
119 120 121 122
	void close();
	void cannotQuit();
	void setMimeTypes(KIO::Job *job);
    void saveSplitterSize();
123
	// can be connected to widget elements
124
	void updateViewActions();
125
	void enableTOC(bool enable);
126

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

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

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

	// main widgets
145
	QSplitter *m_splitter;
146
	QWidget *m_leftPanel;
147
	QToolBox *m_toolBox;
148
	SearchWidget *m_searchWidget;
Albert Astals Cid's avatar
Albert Astals Cid committed
149 150 151 152
	QGuardedPtr<ThumbnailList> m_thumbnailList;
	QGuardedPtr<PageView> m_pageView;
	QGuardedPtr<TOC> m_toc;
	QGuardedPtr<MiniBar> m_miniBar;
153
	QGuardedPtr<PresentationWidget> m_presentationWidget;
154

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

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

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

    // 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
186
    QStringList m_supportedMimeTypes;
187 188 189 190
    KSelectAction * m_confGens;

    private slots:
    void slotGeneratorPreferences();
191
};
Wilco Greven's avatar
Wilco Greven committed
192

193

194 195 196 197 198
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
199
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
200

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

206 207 208 209 210
}

#endif

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