upper
[kdegraphics.git] / okular / part.h
blob86a18b92e5536817b9505b877b3e0fd3e71f241e
1 /***************************************************************************
2 * Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
3 * Copyright (C) 2003-2004 by Christophe Devriese *
4 * <Christophe.Devriese@student.kuleuven.ac.be> *
5 * Copyright (C) 2003 by Andy Goossens <andygoossens@telenet.be> *
6 * Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
7 * Copyright (C) 2004 by Dominique Devriese <devriese@kde.org> *
8 * Copyright (C) 2004-2007 by Albert Astals Cid <aacid@kde.org> *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 ***************************************************************************/
16 #ifndef _PART_H_
17 #define _PART_H_
19 #include <kparts/part.h>
20 #include <qicon.h>
21 #include <qlist.h>
22 #include <qpointer.h>
23 #include <qprocess.h>
24 #include "core/observer.h"
25 #include "core/document.h"
26 #include "kdocumentviewer.h"
28 #include <QtDBus/QtDBus>
30 class QAction;
31 class QWidget;
32 class QPrinter;
33 class QMenu;
35 class KUrl;
36 class KConfigGroup;
37 class KDirWatch;
38 class KToggleAction;
39 class KToggleFullScreenAction;
40 class KSelectAction;
41 class KAboutData;
42 class KTemporaryFile;
43 class KAction;
45 class FindBar;
46 class ThumbnailList;
47 class PageSizeLabel;
48 class PageView;
49 class PageViewTopMessage;
50 class PresentationWidget;
51 class ProgressWidget;
52 class SearchWidget;
53 class Sidebar;
54 class TOC;
55 class MiniBar;
56 class FileKeeper;
57 class Reviews;
58 class BookmarkList;
60 namespace Okular
62 class ExportFormat;
65 class BrowserExtension;
67 /**
68 * This is a "Part". It that does all the real work in a KPart
69 * application.
71 * @short Main Part
72 * @author Wilco Greven <greven@kde.org>
73 * @version 0.2
75 class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, public KDocumentViewer
77 Q_OBJECT
78 Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
79 Q_INTERFACES(KDocumentViewer)
81 public:
82 // Default constructor
83 Part(QWidget* parentWidget, QObject* parent, const QVariantList& args);
85 // Destructor
86 ~Part();
88 // inherited from DocumentObserver
89 uint observerId() const { return PART_ID; }
90 void notifySetup( const QVector< Okular::Page * > &pages, int setupFlags );
91 void notifyViewportChanged( bool smoothMove );
92 void notifyPageChanged( int page, int flags );
94 bool openDocument(const KUrl& url, uint page);
95 void startPresentation();
96 QStringList supportedMimeTypes() const;
98 KUrl realUrl() const;
100 public slots: // dbus
101 Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page);
102 Q_SCRIPTABLE Q_NOREPLY void openDocument( const QString &doc );
103 Q_SCRIPTABLE uint pages();
104 Q_SCRIPTABLE uint currentPage();
105 Q_SCRIPTABLE QString currentDocument();
106 Q_SCRIPTABLE void slotPreferences();
107 Q_SCRIPTABLE void slotFind();
108 Q_SCRIPTABLE void slotPrintPreview();
109 Q_SCRIPTABLE void slotPreviousPage();
110 Q_SCRIPTABLE void slotNextPage();
111 Q_SCRIPTABLE void slotGotoFirst();
112 Q_SCRIPTABLE void slotGotoLast();
113 Q_SCRIPTABLE void slotTogglePresentation();
114 Q_SCRIPTABLE Q_NOREPLY void reload();
116 signals:
117 void enablePrintAction(bool enable);
119 protected:
120 // reimplemented from KParts::ReadOnlyPart
121 bool openFile();
122 bool openUrl(const KUrl &url);
123 bool closeUrl();
125 protected slots:
126 // connected to actions
127 void openUrlFromDocument(const KUrl &url);
128 void openUrlFromBookmarks(const KUrl &url);
129 void slotGoToPage();
130 void slotHistoryBack();
131 void slotHistoryNext();
132 void slotAddBookmark();
133 void slotPreviousBookmark();
134 void slotNextBookmark();
135 void slotFindNext();
136 void slotSaveFileAs();
137 void slotSaveCopyAs();
138 void slotGetNewStuff();
139 void slotNewConfig();
140 void slotNewGeneratorConfig();
141 void slotShowMenu(const Okular::Page *page, const QPoint &point);
142 void slotShowProperties();
143 void slotShowEmbeddedFiles();
144 void slotShowLeftPanel();
145 void slotShowPresentation();
146 void slotHidePresentation();
147 void slotExportAs(QAction *);
148 bool slotImportPSFile();
149 void slotAboutBackend();
150 void slotReload();
151 void close();
152 void cannotQuit();
153 void slotShowFindBar();
154 void slotHideFindBar();
155 void setMimeTypes(KIO::Job *job);
156 void loadCancelled(const QString &reason);
157 void setWindowTitleFromDocument();
158 // can be connected to widget elements
159 void updateViewActions();
160 void updateBookmarksActions();
161 void enableTOC(bool enable);
162 void slotRebuildBookmarkMenu();
164 public slots:
165 // connected to Shell action (and browserExtension), not local one
166 void slotPrint();
167 void restoreDocument(const KConfigGroup &group);
168 void saveDocumentRestoreInfo(KConfigGroup &group);
169 void slotFileDirty( const QString& );
170 void slotDoFileDirty();
171 void psTransformEnded(int, QProcess::ExitStatus);
173 private:
174 void setupPrint( QPrinter &printer );
175 void doPrint( QPrinter &printer );
176 bool handleCompressed( QString &destpath, const QString &path, const QString &compressedMimetype );
177 void rebuildBookmarkMenu( bool unplugActions = true );
178 void updateAboutBackendAction();
179 void unsetDummyMode();
181 KTemporaryFile *m_tempfile;
183 // the document
184 Okular::Document * m_document;
185 QString m_temporaryLocalFile;
187 // main widgets
188 Sidebar *m_sidebar;
189 SearchWidget *m_searchWidget;
190 FindBar * m_findBar;
191 PageViewTopMessage * m_topMessage;
192 PageViewTopMessage * m_formsMessage;
193 QPointer<ThumbnailList> m_thumbnailList;
194 QPointer<PageView> m_pageView;
195 QPointer<TOC> m_toc;
196 QPointer<MiniBar> m_miniBar;
197 QPointer<PresentationWidget> m_presentationWidget;
198 QPointer<ProgressWidget> m_progressWidget;
199 QPointer<PageSizeLabel> m_pageSizeLabel;
200 QPointer<Reviews> m_reviewsWidget;
201 QPointer<BookmarkList> m_bookmarkList;
203 // document watcher (and reloader) variables
204 KDirWatch *m_watcher;
205 QTimer *m_dirtyHandler;
206 Okular::DocumentViewport m_viewportDirty;
207 bool m_wasPresentationOpen;
208 int m_dirtyToolboxIndex;
209 bool m_wasSidebarVisible;
210 bool m_fileWasRemoved;
212 // Remember the search history
213 QStringList m_searchHistory;
215 // actions
216 KAction *m_gotoPage;
217 KAction *m_prevPage;
218 KAction *m_nextPage;
219 KAction *m_firstPage;
220 KAction *m_lastPage;
221 KAction *m_historyBack;
222 KAction *m_historyNext;
223 KAction *m_addBookmark;
224 KAction *m_prevBookmark;
225 KAction *m_nextBookmark;
226 KAction *m_copy;
227 KAction *m_selectAll;
228 KAction *m_find;
229 KAction *m_findNext;
230 KAction *m_saveAs;
231 KAction *m_saveCopyAs;
232 KAction *m_printPreview;
233 KAction *m_showProperties;
234 KAction *m_showEmbeddedFiles;
235 KAction *m_exportAs;
236 QAction *m_exportAsText;
237 KAction *m_showPresentation;
238 KToggleAction* m_showMenuBarAction;
239 KToggleAction* m_showLeftPanel;
240 KToggleFullScreenAction* m_showFullScreenAction;
241 KAction *m_aboutBackend;
242 KAction *m_reload;
243 QMenu *m_exportAsMenu;
245 bool m_actionsSearched;
246 BrowserExtension *m_bExtension;
248 QList<Okular::ExportFormat> m_exportFormats;
249 QList<QAction*> m_bookmarkActions;
250 bool m_cliPresentation;
251 QString m_addBookmarkText;
252 QIcon m_addBookmarkIcon;
254 bool m_dummyMode;
256 KUrl m_realUrl;
258 KXMLGUIClient *m_generatorGuiClient;
259 FileKeeper *m_keeper;
261 private slots:
262 void slotGeneratorPreferences();
265 #endif
267 /* kate: replace-tabs on; indent-width 4; */