compile
[kdegraphics.git] / okular / part.h
blob95ee71309b22e3cadb3fa90fa3434bff97cb0f1f
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 slotFindPrev();
137 void slotSaveFileAs();
138 void slotSaveCopyAs();
139 void slotGetNewStuff();
140 void slotNewConfig();
141 void slotNewGeneratorConfig();
142 void slotShowMenu(const Okular::Page *page, const QPoint &point);
143 void slotShowProperties();
144 void slotShowEmbeddedFiles();
145 void slotShowLeftPanel();
146 void slotShowPresentation();
147 void slotHidePresentation();
148 void slotExportAs(QAction *);
149 bool slotImportPSFile();
150 void slotAboutBackend();
151 void slotReload();
152 void close();
153 void cannotQuit();
154 void slotShowFindBar();
155 void slotHideFindBar();
156 void setMimeTypes(KIO::Job *job);
157 void loadCancelled(const QString &reason);
158 void setWindowTitleFromDocument();
159 // can be connected to widget elements
160 void updateViewActions();
161 void updateBookmarksActions();
162 void enableTOC(bool enable);
163 void slotRebuildBookmarkMenu();
165 public slots:
166 // connected to Shell action (and browserExtension), not local one
167 void slotPrint();
168 void restoreDocument(const KConfigGroup &group);
169 void saveDocumentRestoreInfo(KConfigGroup &group);
170 void slotFileDirty( const QString& );
171 void slotDoFileDirty();
172 void psTransformEnded(int, QProcess::ExitStatus);
174 private:
175 void setupPrint( QPrinter &printer );
176 void doPrint( QPrinter &printer );
177 bool handleCompressed( QString &destpath, const QString &path, const QString &compressedMimetype );
178 void rebuildBookmarkMenu( bool unplugActions = true );
179 void updateAboutBackendAction();
180 void unsetDummyMode();
182 KTemporaryFile *m_tempfile;
184 // the document
185 Okular::Document * m_document;
186 QString m_temporaryLocalFile;
188 // main widgets
189 Sidebar *m_sidebar;
190 SearchWidget *m_searchWidget;
191 FindBar * m_findBar;
192 PageViewTopMessage * m_topMessage;
193 PageViewTopMessage * m_formsMessage;
194 QPointer<ThumbnailList> m_thumbnailList;
195 QPointer<PageView> m_pageView;
196 QPointer<TOC> m_toc;
197 QPointer<MiniBar> m_miniBar;
198 QPointer<PresentationWidget> m_presentationWidget;
199 QPointer<ProgressWidget> m_progressWidget;
200 QPointer<PageSizeLabel> m_pageSizeLabel;
201 QPointer<Reviews> m_reviewsWidget;
202 QPointer<BookmarkList> m_bookmarkList;
204 // document watcher (and reloader) variables
205 KDirWatch *m_watcher;
206 QTimer *m_dirtyHandler;
207 Okular::DocumentViewport m_viewportDirty;
208 bool m_wasPresentationOpen;
209 int m_dirtyToolboxIndex;
210 bool m_wasSidebarVisible;
211 bool m_fileWasRemoved;
213 // Remember the search history
214 QStringList m_searchHistory;
216 // actions
217 KAction *m_gotoPage;
218 KAction *m_prevPage;
219 KAction *m_nextPage;
220 KAction *m_firstPage;
221 KAction *m_lastPage;
222 KAction *m_historyBack;
223 KAction *m_historyNext;
224 KAction *m_addBookmark;
225 KAction *m_prevBookmark;
226 KAction *m_nextBookmark;
227 KAction *m_copy;
228 KAction *m_selectAll;
229 KAction *m_find;
230 KAction *m_findNext;
231 KAction *m_findPrev;
232 KAction *m_saveAs;
233 KAction *m_saveCopyAs;
234 KAction *m_printPreview;
235 KAction *m_showProperties;
236 KAction *m_showEmbeddedFiles;
237 KAction *m_exportAs;
238 QAction *m_exportAsText;
239 QAction *m_exportAsDocArchive;
240 KAction *m_showPresentation;
241 KToggleAction* m_showMenuBarAction;
242 KToggleAction* m_showLeftPanel;
243 KToggleFullScreenAction* m_showFullScreenAction;
244 KAction *m_aboutBackend;
245 KAction *m_reload;
246 QMenu *m_exportAsMenu;
248 bool m_actionsSearched;
249 BrowserExtension *m_bExtension;
251 QList<Okular::ExportFormat> m_exportFormats;
252 QList<QAction*> m_bookmarkActions;
253 bool m_cliPresentation;
254 QString m_addBookmarkText;
255 QIcon m_addBookmarkIcon;
257 bool m_dummyMode;
259 KUrl m_realUrl;
261 KXMLGUIClient *m_generatorGuiClient;
262 FileKeeper *m_keeper;
264 private slots:
265 void slotGeneratorPreferences();
268 #endif
270 /* kate: replace-tabs on; indent-width 4; */