• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
part.h
Go to the documentation of this file.
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  ***************************************************************************/
15 
16 #ifndef _PART_H_
17 #define _PART_H_
18 
19 #include <kparts/part.h>
20 #include <kpluginfactory.h>
21 #include <qicon.h>
22 #include <qlist.h>
23 #include <qpointer.h>
24 #include <qprocess.h>
25 #include "core/observer.h"
26 #include "core/document.h"
27 #include "kdocumentviewer.h"
28 #include "interfaces/viewerinterface.h"
29 
30 #include "okular_part_export.h"
31 
32 #include <QtDBus/QtDBus>
33 
34 class QAction;
35 class QWidget;
36 class QPrinter;
37 class QMenu;
38 
39 class KUrl;
40 class KConfigDialog;
41 class KConfigGroup;
42 class KDirWatch;
43 class KToggleAction;
44 class KToggleFullScreenAction;
45 class KSelectAction;
46 class KAboutData;
47 class KTemporaryFile;
48 class KAction;
49 class KMenu;
50 namespace KParts { class GUIActivateEvent; }
51 
52 class FindBar;
53 class ThumbnailList;
54 class PageSizeLabel;
55 class PageView;
56 class PageViewTopMessage;
57 class PresentationWidget;
58 class ProgressWidget;
59 class SearchWidget;
60 class Sidebar;
61 class TOC;
62 class MiniBar;
63 class MiniBarLogic;
64 class FileKeeper;
65 class Reviews;
66 class BookmarkList;
67 
68 namespace Okular
69 {
70 
71 class BrowserExtension;
72 class ExportFormat;
73 
79 enum EmbedMode
80 {
81  UnknownEmbedMode,
82  NativeShellMode, // embedded in the native Okular' shell
83  PrintPreviewMode, // embedded to show the print preview of a document
84  KHTMLPartMode, // embedded in KHTML
85  ViewerWidgetMode, // the part acts as a widget that can display all kinds of documents
86 };
87 
96 class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::DocumentObserver, public KDocumentViewer, public Okular::ViewerInterface
97 {
98  Q_OBJECT
99  Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
100  Q_INTERFACES(KDocumentViewer)
101  Q_INTERFACES(Okular::ViewerInterface)
102 
103  friend class PartTest;
104 
105  public:
106  // Default constructor
113  Part(QWidget* parentWidget, QObject* parent, const QVariantList& args, KComponentData componentData);
114 
115  // Destructor
116  ~Part();
117 
118  // inherited from DocumentObserver
119  void notifySetup( const QVector< Okular::Page * > &pages, int setupFlags );
120  void notifyViewportChanged( bool smoothMove );
121  void notifyPageChanged( int page, int flags );
122 
123  bool openDocument(const KUrl& url, uint page);
124  void startPresentation();
125  QStringList supportedMimeTypes() const;
126 
127  KUrl realUrl() const;
128 
129  void showSourceLocation(const QString& fileName, int line, int column, bool showGraphically = true);
130  void clearLastShownSourceLocation();
131  bool isWatchFileModeEnabled() const;
132  void setWatchFileModeEnabled(bool enable);
133  bool areSourceLocationsShownGraphically() const;
134  void setShowSourceLocationsGraphically(bool show);
135 
136  public slots: // dbus
137  Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page);
138  Q_SCRIPTABLE Q_NOREPLY void openDocument( const QString &doc );
139  Q_SCRIPTABLE uint pages();
140  Q_SCRIPTABLE uint currentPage();
141  Q_SCRIPTABLE QString currentDocument();
142  Q_SCRIPTABLE QString documentMetaData( const QString &metaData ) const;
143  Q_SCRIPTABLE void slotPreferences();
144  Q_SCRIPTABLE void slotFind();
145  Q_SCRIPTABLE void slotPrintPreview();
146  Q_SCRIPTABLE void slotPreviousPage();
147  Q_SCRIPTABLE void slotNextPage();
148  Q_SCRIPTABLE void slotGotoFirst();
149  Q_SCRIPTABLE void slotGotoLast();
150  Q_SCRIPTABLE void slotTogglePresentation();
151  Q_SCRIPTABLE Q_NOREPLY void reload();
152  Q_SCRIPTABLE Q_NOREPLY void enableStartWithPrint();
153 
154  signals:
155  void enablePrintAction(bool enable);
156  void openSourceReference(const QString& absFileName, int line, int column);
157  void viewerMenuStateChange(bool enabled);
158  void enableCloseAction(bool enable);
159 
160  protected:
161  // reimplemented from KParts::ReadWritePart
162  bool openFile();
163  bool openUrl(const KUrl &url);
164  void guiActivateEvent(KParts::GUIActivateEvent *event);
165  public:
166  bool saveFile();
167  bool queryClose();
168  bool closeUrl();
169  bool closeUrl(bool promptToSave);
170  void setReadWrite(bool readwrite);
171  bool saveAs(const KUrl & saveUrl);
172 
173  protected slots:
174  // connected to actions
175  void openUrlFromDocument(const KUrl &url);
176  void openUrlFromBookmarks(const KUrl &url);
177  void slotGoToPage();
178  void slotHistoryBack();
179  void slotHistoryNext();
180  void slotAddBookmark();
181  void slotRenameBookmarkFromMenu();
182  void slotRenameCurrentViewportBookmark();
183  void slotAboutToShowContextMenu(KMenu *menu, QAction *action, QMenu *contextMenu);
184  void slotPreviousBookmark();
185  void slotNextBookmark();
186  void slotFindNext();
187  void slotFindPrev();
188  void slotSaveFileAs();
189  void slotSaveCopyAs();
190  void slotGetNewStuff();
191  void slotNewConfig();
192  void slotShowMenu(const Okular::Page *page, const QPoint &point);
193  void slotShowProperties();
194  void slotShowEmbeddedFiles();
195  void slotShowLeftPanel();
196  void slotShowBottomBar();
197  void slotShowPresentation();
198  void slotHidePresentation();
199  void slotExportAs(QAction *);
200  bool slotImportPSFile();
201  void slotAboutBackend();
202  void slotReload();
203  void close();
204  void cannotQuit();
205  void slotShowFindBar();
206  void slotHideFindBar();
207  void slotJobStarted(KIO::Job *job);
208  void slotJobFinished(KJob *job);
209  void loadCancelled(const QString &reason);
210  void setWindowTitleFromDocument();
211  // can be connected to widget elements
212  void updateViewActions();
213  void updateBookmarksActions();
214  void enableTOC(bool enable);
215  void slotRebuildBookmarkMenu();
216 
217  public slots:
218  // connected to Shell action (and browserExtension), not local one
219  void slotPrint();
220  void restoreDocument(const KConfigGroup &group);
221  void saveDocumentRestoreInfo(KConfigGroup &group);
222  void slotFileDirty( const QString& );
223  void slotDoFileDirty();
224  void psTransformEnded(int, QProcess::ExitStatus);
225  KConfigDialog * slotGeneratorPreferences();
226 
227  private:
228  void setupViewerActions();
229  void setViewerShortcuts();
230  void setupActions();
231 
232  void setupPrint( QPrinter &printer );
233  void doPrint( QPrinter &printer );
234  bool handleCompressed( QString &destpath, const QString &path, const QString &compressedMimetype );
235  void rebuildBookmarkMenu( bool unplugActions = true );
236  void updateAboutBackendAction();
237  void unsetDummyMode();
238  void slotRenameBookmark( const DocumentViewport &viewport );
239  void resetStartArguments();
240 
241  static int numberOfParts;
242 
243  KTemporaryFile *m_tempfile;
244 
245  // the document
246  Okular::Document * m_document;
247  QString m_temporaryLocalFile;
248  bool isDocumentArchive;
249 
250  // main widgets
251  Sidebar *m_sidebar;
252  SearchWidget *m_searchWidget;
253  FindBar * m_findBar;
254  PageViewTopMessage * m_topMessage;
255  PageViewTopMessage * m_formsMessage;
256  QPointer<ThumbnailList> m_thumbnailList;
257  QPointer<PageView> m_pageView;
258  QPointer<TOC> m_toc;
259  QPointer<MiniBarLogic> m_miniBarLogic;
260  QPointer<MiniBar> m_miniBar;
261  QPointer<MiniBar> m_pageNumberTool;
262  QPointer<QWidget> m_bottomBar;
263  QPointer<PresentationWidget> m_presentationWidget;
264  QPointer<ProgressWidget> m_progressWidget;
265  QPointer<PageSizeLabel> m_pageSizeLabel;
266  QPointer<Reviews> m_reviewsWidget;
267  QPointer<BookmarkList> m_bookmarkList;
268 
269  // document watcher (and reloader) variables
270  KDirWatch *m_watcher;
271  QTimer *m_dirtyHandler;
272  KUrl m_oldUrl;
273  Okular::DocumentViewport m_viewportDirty;
274  bool m_wasPresentationOpen;
275  int m_dirtyToolboxIndex;
276  bool m_wasSidebarVisible;
277  bool m_wasSidebarCollapsed;
278  bool m_fileWasRemoved;
279  Rotation m_dirtyPageRotation;
280 
281  // Remember the search history
282  QStringList m_searchHistory;
283 
284  // actions
285  KAction *m_gotoPage;
286  KAction *m_prevPage;
287  KAction *m_nextPage;
288  KAction *m_beginningOfDocument;
289  KAction *m_endOfDocument;
290  KAction *m_historyBack;
291  KAction *m_historyNext;
292  KAction *m_addBookmark;
293  KAction *m_renameBookmark;
294  KAction *m_prevBookmark;
295  KAction *m_nextBookmark;
296  KAction *m_copy;
297  KAction *m_selectAll;
298  KAction *m_find;
299  KAction *m_findNext;
300  KAction *m_findPrev;
301  KAction *m_saveAs;
302  KAction *m_saveCopyAs;
303  KAction *m_printPreview;
304  KAction *m_showProperties;
305  KAction *m_showEmbeddedFiles;
306  KAction *m_exportAs;
307  QAction *m_exportAsText;
308  QAction *m_exportAsDocArchive;
309  KAction *m_showPresentation;
310  KToggleAction* m_showMenuBarAction;
311  KToggleAction* m_showLeftPanel;
312  KToggleAction* m_showBottomBar;
313  KToggleFullScreenAction* m_showFullScreenAction;
314  KAction *m_aboutBackend;
315  KAction *m_reload;
316  QMenu *m_exportAsMenu;
317  KAction *m_closeFindBar;
318 
319  bool m_actionsSearched;
320  BrowserExtension *m_bExtension;
321 
322  QList<Okular::ExportFormat> m_exportFormats;
323  QList<QAction*> m_bookmarkActions;
324  bool m_cliPresentation;
325  bool m_cliPrint;
326  QString m_addBookmarkText;
327  QIcon m_addBookmarkIcon;
328 
329  EmbedMode m_embedMode;
330 
331  KUrl m_realUrl;
332 
333  KXMLGUIClient *m_generatorGuiClient;
334  FileKeeper *m_keeper;
335 
336  private slots:
337  void slotAnnotationPreferences();
338  void slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled);
339 };
340 
341 class PartFactory : public KPluginFactory
342 {
343  Q_OBJECT
344 
345  public:
346  PartFactory();
347  virtual ~PartFactory();
348 
349  protected:
350  virtual QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword);
351 };
352 
353 }
354 
355 #endif
356 
357 /* kate: replace-tabs on; indent-width 4; */
Okular::Rotation
Rotation
A rotation.
Definition: global.h:44
okular_part_export.h
KXMLGUIClient
Okular::EmbedMode
EmbedMode
Describes the possible embedding modes of the part.
Definition: part.h:79
KDocumentViewer
Abstract interface for a document viewer.
Definition: kdocumentviewer.h:22
QWidget
Okular::KHTMLPartMode
Definition: part.h:84
Okular::PartFactory
Definition: part.h:341
Okular::ViewerWidgetMode
Definition: part.h:85
QObject
observer.h
Okular::PrintPreviewMode
Definition: part.h:83
Okular::Part
This is a "Part".
Definition: part.h:96
Okular::Document
The Document.
Definition: document.h:84
Okular::Page
Collector for all the data belonging to a page.
Definition: page.h:49
document.h
OKULAR_PART_EXPORT
#define OKULAR_PART_EXPORT
Definition: okular_part_export.h:30
viewerinterface.h
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:75
Okular::DocumentObserver
Base class for objects being notified when something changes.
Definition: observer.h:28
kdocumentviewer.h
Okular::DocumentViewport
A view on the document.
Definition: document.h:1003
Okular::UnknownEmbedMode
Definition: part.h:81
Okular::ViewerInterface
Abstract interface for controlling advanced features of a document viewer.
Definition: viewerinterface.h:26
Okular::BrowserExtension
Definition: extensions.h:21
KPluginFactory
Okular::NativeShellMode
Definition: part.h:82
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal