compile
[kdegraphics.git] / okular / part.h
blobd73583e14465b7bd2ac32b303ce6f1d2a79b5cbc
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;
34 class KUrl;
35 class KConfigGroup;
36 class KDirWatch;
37 class KToggleAction;
38 class KToggleFullScreenAction;
39 class KSelectAction;
40 class KAboutData;
41 class KTemporaryFile;
43 class FindBar;
44 class ThumbnailList;
45 class PageSizeLabel;
46 class PageView;
47 class PageViewTopMessage;
48 class PresentationWidget;
49 class ProgressWidget;
50 class SearchWidget;
51 class Sidebar;
52 class TOC;
53 class MiniBar;
54 class FileKeeper;
56 namespace Okular
58 class ExportFormat;
61 class BrowserExtension;
63 /**
64 * This is a "Part". It that does all the real work in a KPart
65 * application.
67 * @short Main Part
68 * @author Wilco Greven <greven@kde.org>
69 * @version 0.2
71 class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, public KDocumentViewer
73 Q_OBJECT
74 Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
75 Q_INTERFACES(KDocumentViewer)
77 public:
78 // Default constructor
79 Part(QWidget* parentWidget, QObject* parent, const QVariantList& args);
81 // Destructor
82 ~Part();
84 // inherited from DocumentObserver
85 uint observerId() const { return PART_ID; }
86 void notifySetup( const QVector< Okular::Page * > &pages, int setupFlags );
87 void notifyViewportChanged( bool smoothMove );
88 void notifyPageChanged( int page, int flags );
90 bool openDocument(const KUrl& url, uint page);
91 void startPresentation();
92 QStringList supportedMimeTypes() const;
94 KUrl realUrl() const;
96 public slots: // dbus
97 Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page);
98 Q_SCRIPTABLE Q_NOREPLY void openDocument( const QString &doc );
99 Q_SCRIPTABLE uint pages();
100 Q_SCRIPTABLE uint currentPage();
101 Q_SCRIPTABLE QString currentDocument();
102 Q_SCRIPTABLE void slotPreferences();
103 Q_SCRIPTABLE void slotFind();
104 Q_SCRIPTABLE void slotPrintPreview();
105 Q_SCRIPTABLE void slotPreviousPage();
106 Q_SCRIPTABLE void slotNextPage();
107 Q_SCRIPTABLE void slotGotoFirst();
108 Q_SCRIPTABLE void slotGotoLast();
109 Q_SCRIPTABLE void slotTogglePresentation();
111 signals:
112 void enablePrintAction(bool enable);
114 protected:
115 // reimplemented from KParts::ReadOnlyPart
116 bool openFile();
117 bool openUrl(const KUrl &url);
118 bool closeUrl();
120 protected slots:
121 // connected to actions
122 void openUrlFromDocument(const KUrl &url);
123 void openUrlFromBookmarks(const KUrl &url);
124 void slotGoToPage();
125 void slotHistoryBack();
126 void slotHistoryNext();
127 void slotAddBookmark();
128 void slotPreviousBookmark();
129 void slotNextBookmark();
130 void slotFindNext();
131 void slotSaveFileAs();
132 void slotSaveCopyAs();
133 void slotGetNewStuff();
134 void slotNewConfig();
135 void slotNewGeneratorConfig();
136 void slotShowMenu(const Okular::Page *page, const QPoint &point);
137 void slotShowProperties();
138 void slotShowEmbeddedFiles();
139 void slotShowLeftPanel();
140 void slotShowPresentation();
141 void slotHidePresentation();
142 void slotExportAs(QAction *);
143 bool slotImportPSFile();
144 void slotAboutBackend();
145 void slotReload();
146 void close();
147 void cannotQuit();
148 void slotShowFindBar();
149 void slotHideFindBar();
150 void setMimeTypes(KIO::Job *job);
151 void loadCancelled(const QString &reason);
152 void setWindowTitleFromDocument();
153 // can be connected to widget elements
154 void updateViewActions();
155 void updateBookmarksActions();
156 void enableTOC(bool enable);
157 void slotRebuildBookmarkMenu();
159 public slots:
160 // connected to Shell action (and browserExtension), not local one
161 void slotPrint();
162 void restoreDocument(const KConfigGroup &group);
163 void saveDocumentRestoreInfo(KConfigGroup &group);
164 void slotFileDirty( const QString& );
165 void slotDoFileDirty();
166 void psTransformEnded(int, QProcess::ExitStatus);
168 private:
169 void setupPrint( QPrinter &printer );
170 void doPrint( QPrinter &printer );
171 bool handleCompressed( QString &destpath, const QString &path, const QString &compressedMimetype );
172 void rebuildBookmarkMenu( bool unplugActions = true );
173 void updateAboutBackendAction();
174 void unsetDummyMode();
176 KTemporaryFile *m_tempfile;
178 // the document
179 Okular::Document * m_document;
180 QString m_temporaryLocalFile;
182 // main widgets
183 Sidebar *m_sidebar;
184 SearchWidget *m_searchWidget;
185 FindBar * m_findBar;
186 PageViewTopMessage * m_topMessage;
187 PageViewTopMessage * m_formsMessage;
188 QPointer<ThumbnailList> m_thumbnailList;
189 QPointer<PageView> m_pageView;
190 QPointer<TOC> m_toc;
191 QPointer<MiniBar> m_miniBar;
192 QPointer<PresentationWidget> m_presentationWidget;
193 QPointer<ProgressWidget> m_progressWidget;
194 QPointer<PageSizeLabel> m_pageSizeLabel;
196 // document watcher (and reloader) variables
197 KDirWatch *m_watcher;
198 QTimer *m_dirtyHandler;
199 Okular::DocumentViewport m_viewportDirty;
200 bool m_wasPresentationOpen;
201 int m_dirtyToolboxIndex;
202 bool m_wasSidebarVisible;
203 bool m_fileWasRemoved;
205 // Remember the search history
206 QStringList m_searchHistory;
208 // actions
209 QAction *m_gotoPage;
210 QAction *m_prevPage;
211 QAction *m_nextPage;
212 QAction *m_firstPage;
213 QAction *m_lastPage;
214 QAction *m_historyBack;
215 QAction *m_historyNext;
216 QAction *m_addBookmark;
217 QAction *m_prevBookmark;
218 QAction *m_nextBookmark;
219 QAction *m_copy;
220 QAction *m_selectAll;
221 QAction *m_find;
222 QAction *m_findNext;
223 QAction *m_saveAs;
224 QAction *m_saveCopyAs;
225 QAction *m_printPreview;
226 QAction *m_showProperties;
227 QAction *m_showEmbeddedFiles;
228 QAction *m_exportAs;
229 QAction *m_exportAsText;
230 QAction *m_showPresentation;
231 KToggleAction* m_showMenuBarAction;
232 KToggleAction* m_showLeftPanel;
233 KToggleFullScreenAction* m_showFullScreenAction;
234 QAction *m_aboutBackend;
235 QAction *m_reload;
237 bool m_actionsSearched;
238 BrowserExtension *m_bExtension;
240 QList<Okular::ExportFormat> m_exportFormats;
241 QList<QAction*> m_bookmarkActions;
242 bool m_cliPresentation;
243 QString m_addBookmarkText;
244 QIcon m_addBookmarkIcon;
246 bool m_dummyMode;
248 KUrl m_realUrl;
250 KXMLGUIClient *m_generatorGuiClient;
251 FileKeeper *m_keeper;
253 private slots:
254 void slotGeneratorPreferences();
257 #endif
259 /* kate: replace-tabs on; indent-width 4; */