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.11 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;
Albert Astals Cid's avatar
Albert Astals Cid committed
45
class PageSizeLabel;
46
class PageView;
47
class PageViewTopMessage;
48
class PresentationWidget;
49
class ProgressWidget;
50
class SearchWidget;
Albert Astals Cid's avatar
Albert Astals Cid committed
51 52
class TOC;
class MiniBar;
53

54 55
namespace Okular {
class Document;
Tobias Koenig's avatar
Tobias Koenig committed
56
class ExportFormat;
57
}
58 59 60 61 62 63 64 65 66 67 68

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

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

78 79
	// Destructor
	~Part();
80

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

85
	static KAboutData* createAboutData();
86

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

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

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

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

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

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

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

	// main widgets
158
	QSplitter *m_splitter;
159
	QWidget *m_leftPanel;
160
	QToolBox *m_toolBox;
161
	SearchWidget *m_searchWidget;
162
	PageViewTopMessage * m_topMessage;
163 164 165 166 167
	QPointer<ThumbnailList> m_thumbnailList;
	QPointer<PageView> m_pageView;
	QPointer<TOC> m_toc;
	QPointer<MiniBar> m_miniBar;
	QPointer<PresentationWidget> m_presentationWidget;
168
	QPointer<ProgressWidget> m_progressWidget;
Albert Astals Cid's avatar
Albert Astals Cid committed
169
	QPointer<PageSizeLabel> m_pageSizeLabel;
170

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

177 178 179
	// Remember the search history
	QStringList m_searchHistory;

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

Albert Astals Cid's avatar
Albert Astals Cid committed
204
	bool m_actionsSearched;
205
	bool m_searchStarted;
206
	BrowserExtension *m_bExtension;
207

208 209 210 211 212 213
  // 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;
Tobias Koenig's avatar
Tobias Koenig committed
214
	QList<Okular::ExportFormat> m_exportFormats;
215

216
private slots:
217
    void slotGeneratorPreferences();
218
};
Wilco Greven's avatar
Wilco Greven committed
219

220

221 222 223 224 225
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
226
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
227

228
public slots:
229 230
	// Automatically detected by the host.
	void print();
231
};
232

233 234 235
#endif

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