part.h 5.93 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 PresentationWidget;
47
class SearchWidget;
Albert Astals Cid's avatar
Albert Astals Cid committed
48 49
class TOC;
class MiniBar;
50

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

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

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

75 76
	// Destructor
	~Part();
77

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

82
	static KAboutData* createAboutData();
83

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

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

101
protected:
102
	// reimplemented from KParts::ReadOnlyPart
103
	bool openFile();
104 105
	bool openUrl(const KUrl &url);
	bool closeUrl();
106 107
	// filter that watches for splitter size changes
	bool eventFilter( QObject * watched, QEvent * e );
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 132
	void close();
	void cannotQuit();
	void setMimeTypes(KIO::Job *job);
133
	void saveSplitterSize();
134
	// can be connected to widget elements
135
	void updateViewActions();
136
	void enableTOC(bool enable);
137

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

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

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

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

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

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

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

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

201 202 203 204 205 206 207
  // 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;
208

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

213

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

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

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

226 227 228
#endif

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