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 6.03 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
#ifndef _PART_H_
#define _PART_H_
18

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

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

53 54 55 56
namespace Okular {
class Document;
class ExportEntry;
}
57 58 59 60 61 62 63 64 65 66 67

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

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

77 78
	// Destructor
	~Part();
79

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

84
	static KAboutData* createAboutData();
85

86
public slots: // dbus
Pino Toscano's avatar
Pino Toscano committed
87 88
	Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page);
	Q_SCRIPTABLE Q_NOREPLY void openDocument(KUrl doc);
89 90 91 92 93 94 95 96 97 98
	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();
99

Piotr Szymanski's avatar
Piotr Szymanski committed
100 101 102
signals:
	void enablePrintAction(bool enable);

103
protected:
104
	// reimplemented from KParts::ReadOnlyPart
105
	bool openFile();
106 107
	bool openUrl(const KUrl &url);
	bool closeUrl();
108
	void supportedMimetypes();
Laurent Montel's avatar
Laurent Montel committed
109

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

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

148 149
private:
	void doPrint( KPrinter& printer );
150
    void fillGenerators();
151

152
	// the document
153
	Okular::Document * m_document;
154
	QString m_temporaryLocalFile;
155 156

	// main widgets
157
	QSplitter *m_splitter;
158
	QWidget *m_leftPanel;
159
	QToolBox *m_toolBox;
160
	SearchWidget *m_searchWidget;
161
	PageViewTopMessage * m_topMessage;
162 163 164 165 166
	QPointer<ThumbnailList> m_thumbnailList;
	QPointer<PageView> m_pageView;
	QPointer<TOC> m_toc;
	QPointer<MiniBar> m_miniBar;
	QPointer<PresentationWidget> m_presentationWidget;
167
	QPointer<ProgressWidget> m_progressWidget;
168

169
	// document watcher (and reloader) variables
Albert Astals Cid's avatar
Albert Astals Cid committed
170 171
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
172
	Okular::DocumentViewport m_viewportDirty;
Albert Astals Cid's avatar
Albert Astals Cid committed
173
	bool m_wasPresentationOpen;
174

175 176 177
	// Remember the search history
	QStringList m_searchHistory;

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

Albert Astals Cid's avatar
Albert Astals Cid committed
201
	bool m_actionsSearched;
202
	bool m_searchStarted;
203
	BrowserExtension *m_bExtension;
204

205 206 207 208 209 210 211
  // QHash: key is the name of the generator
  QHash<QString, Okular::Generator*> m_loadedGenerators;
  // list of names of the generators that have settings
  QStringList m_generatorsWithSettings;
  QStringList m_supportedMimeTypes;
  KSelectAction * m_confGens;
	QList<Okular::ExportEntry*> m_exportItems;
212

213
private slots:
214
    void slotGeneratorPreferences();
215
};
Wilco Greven's avatar
Wilco Greven committed
216

217

218 219 220 221 222
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
223
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
224

225
public slots:
226 227
	// Automatically detected by the host.
	void print();
228
};
229

230 231 232
#endif

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