Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

part.h 5.92 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 <qlist.h>
22
#include <qpointer.h>
23
#include "core/observer.h"
24
#include "core/document.h"
25

Pino Toscano's avatar
Pino Toscano committed
26
#include <QtDBus/QtDBus>
27

28
class QAction;
29
class QWidget;
30
class QSplitter;
31
class QToolBox;
32

Pino Toscano's avatar
porting  
Pino Toscano committed
33
class KUrl;
34
class KAction;
35
class KConfig;
Albert Astals Cid's avatar
Albert Astals Cid committed
36
class KDirWatch;
37
class KToggleAction;
38
class KToggleFullScreenAction;
39
class KSelectAction;
40 41
class KAboutData;
class KPrinter;
42

43
class KPDFDocument;
Albert Astals Cid's avatar
Albert Astals Cid committed
44
class ThumbnailList;
45
class ThumbnailController;
46
class PageView;
47
class PresentationWidget;
48
class SearchWidget;
Albert Astals Cid's avatar
Albert Astals Cid committed
49 50
class TOC;
class MiniBar;
51
class ExportEntry;
52

Albert Astals Cid's avatar
Albert Astals Cid committed
53
namespace okular {
54 55 56 57 58 59 60 61 62 63 64

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
 */
65
class Part : public KParts::ReadOnlyPart, public DocumentObserver
66
{
67
Q_OBJECT
Albert Astals Cid's avatar
Albert Astals Cid committed
68
Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
69 70 71

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

74 75
	// Destructor
	~Part();
76

77
    // inherited from DocumentObserver
78
    uint observerId() const { return PART_ID; }
Enrico Ros's avatar
Enrico Ros committed
79
    void notifyViewportChanged( bool smoothMove );
80

81
	static KAboutData* createAboutData();
82

83
public slots: // dbus
Pino Toscano's avatar
Pino Toscano committed
84 85
	Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page);
	Q_SCRIPTABLE Q_NOREPLY void openDocument(KUrl doc);
86 87 88 89 90 91 92 93 94 95
	Q_SCRIPTABLE uint pages();
	Q_SCRIPTABLE uint currentPage();
	Q_SCRIPTABLE KUrl currentDocument();
	Q_SCRIPTABLE void slotPreferences();
	Q_SCRIPTABLE void slotFind();
	Q_SCRIPTABLE void slotPrintPreview();
	Q_SCRIPTABLE void slotPreviousPage();
	Q_SCRIPTABLE void slotNextPage();
	Q_SCRIPTABLE void slotGotoFirst();
	Q_SCRIPTABLE void slotGotoLast();
96

Piotr Szymanski's avatar
Piotr Szymanski committed
97 98 99
signals:
	void enablePrintAction(bool enable);

100
protected:
101
	// reimplemented from KParts::ReadOnlyPart
102
	bool openFile();
103 104
	bool openUrl(const KUrl &url);
	bool closeUrl();
105 106
	// filter that watches for splitter size changes
	bool eventFilter( QObject * watched, QEvent * e );
107
	void supportedMimetypes();
Laurent Montel's avatar
Laurent Montel committed
108

109
protected slots:
110
	// connected to actions
111
	void openUrlFromDocument(const KUrl &url);
112
	void slotGoToPage();
113 114
	void slotHistoryBack();
	void slotHistoryNext();
115 116
	void slotPreviousBookmark();
	void slotNextBookmark();
117
	void slotFindNext();
118
	void slotSaveFileAs();
Enrico Ros's avatar
Enrico Ros committed
119
	void slotGetNewStuff();
120
	void slotNewConfig();
121
	void slotShowMenu(const KPDFPage *page, const QPoint &point);
Albert Astals Cid's avatar
Albert Astals Cid committed
122
	void slotShowProperties();
123
	void slotShowEmbeddedFiles();
124
	void slotShowLeftPanel();
125
	void slotShowPresentation();
126
	void slotHidePresentation();
127
	void slotExportAs(QAction *);
128
	bool slotImportPSFile();
Piotr Szymanski's avatar
Piotr Szymanski committed
129 130 131
	void close();
	void cannotQuit();
	void setMimeTypes(KIO::Job *job);
132
	void saveSplitterSize();
133
	// can be connected to widget elements
134
	void updateViewActions();
135
	void enableTOC(bool enable);
136

137
public slots:
138
	// connected to Shell action (and browserExtension), not local one
139
	void slotPrint();
140
	void restoreDocument(KConfig* config);
Albert Astals Cid's avatar
Albert Astals Cid committed
141 142 143
	void saveDocumentRestoreInfo(KConfig* config);
	void slotFileDirty( const QString& );
	void slotDoFileDirty();
144
	void psTransformEnded();
145

146 147
private:
	void doPrint( KPrinter& printer );
148
    void fillGenerators();
149

150
	// the document
151
	KPDFDocument * m_document;
152
	QString m_temporaryLocalFile;
153 154

	// main widgets
155
	QSplitter *m_splitter;
156
	QWidget *m_leftPanel;
157
	QToolBox *m_toolBox;
158
	SearchWidget *m_searchWidget;
159 160 161 162 163
	QPointer<ThumbnailList> m_thumbnailList;
	QPointer<PageView> m_pageView;
	QPointer<TOC> m_toc;
	QPointer<MiniBar> m_miniBar;
	QPointer<PresentationWidget> m_presentationWidget;
164

165
	// document watcher (and reloader) variables
Albert Astals Cid's avatar
Albert Astals Cid committed
166 167
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
168
	DocumentViewport m_viewportDirty;
169

170 171 172
	// Remember the search history
	QStringList m_searchHistory;

173 174 175 176 177 178
	// actions
	KAction *m_gotoPage;
	KAction *m_prevPage;
	KAction *m_nextPage;
	KAction *m_firstPage;
	KAction *m_lastPage;
179 180
	KAction *m_historyBack;
	KAction *m_historyNext;
181 182
	KAction *m_prevBookmark;
	KAction *m_nextBookmark;
183 184
	KAction *m_find;
	KAction *m_findNext;
185 186
	KAction *m_saveAs;
	KAction *m_printPreview;
Albert Astals Cid's avatar
Albert Astals Cid committed
187
	KAction *m_showProperties;
188
	KAction *m_showEmbeddedFiles;
189 190
	KAction *m_exportAs;
	QAction *m_exportAsText;
191
	KAction *m_showPresentation;
192
	KToggleAction* m_showMenuBarAction;
193
	KToggleAction* m_showLeftPanel;
194
	KToggleFullScreenAction* m_showFullScreenAction;
195

Albert Astals Cid's avatar
Albert Astals Cid committed
196
	bool m_actionsSearched;
197
	bool m_searchStarted;
198
	BrowserExtension *m_bExtension;
199

200 201
    // QHash: key is the name of the generator
   QHash<QString, Generator*> m_loadedGenerators;
202 203
    // list of names of the generators that have settings
    QStringList m_generatorsWithSettings;
Piotr Szymanski's avatar
Piotr Szymanski committed
204
    QStringList m_supportedMimeTypes;
205
    KSelectAction * m_confGens;
206
	QList<ExportEntry*> m_exportItems;
207 208 209

    private slots:
    void slotGeneratorPreferences();
210
};
Wilco Greven's avatar
Wilco Greven committed
211

212

213 214 215 216 217
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
218
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
219

220
public slots:
221 222
	// Automatically detected by the host.
	void print();
223
};
224

225 226 227 228 229
}

#endif

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