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

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

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

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

76 77
	// Destructor
	~Part();
78

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

83
	static KAboutData* createAboutData();
84

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

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

102
protected:
103
	// reimplemented from KParts::ReadOnlyPart
104
	bool openFile();
105 106
	bool openUrl(const KUrl &url);
	bool closeUrl();
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 Okular::Page *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
	void close();
	void cannotQuit();
131
	void splitterMoved( int pos, int index );
Piotr Szymanski's avatar
Piotr Szymanski committed
132
	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
	PageViewTopMessage * m_topMessage;
161 162 163 164 165
	QPointer<ThumbnailList> m_thumbnailList;
	QPointer<PageView> m_pageView;
	QPointer<TOC> m_toc;
	QPointer<MiniBar> m_miniBar;
	QPointer<PresentationWidget> m_presentationWidget;
166

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

173 174 175
	// Remember the search history
	QStringList m_searchHistory;

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

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

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

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

215

216 217 218 219 220
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
221
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
222

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

228 229 230
#endif

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