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

okular

  • sources
  • kde-4.14
  • 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 <kmessagewidget.h>
22 #include <qicon.h>
23 #include <qlist.h>
24 #include <qpointer.h>
25 #include <qprocess.h>
26 #include "core/observer.h"
27 #include "core/document.h"
28 #include "kdocumentviewer.h"
29 #include "interfaces/viewerinterface.h"
30 
31 #include "okular_part_export.h"
32 
33 #include <QtDBus/QtDBus>
34 
35 class QAction;
36 class QWidget;
37 class QPrinter;
38 class QMenu;
39 
40 class KUrl;
41 class KConfigDialog;
42 class KConfigGroup;
43 class KDirWatch;
44 class KToggleAction;
45 class KToggleFullScreenAction;
46 class KSelectAction;
47 class KAboutData;
48 class KTemporaryFile;
49 class KAction;
50 class KMenu;
51 namespace KParts { class GUIActivateEvent; }
52 
53 class FindBar;
54 class ThumbnailList;
55 class PageSizeLabel;
56 class PageView;
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  bool openNewFilesInTabs() const;
136 
137  public slots: // dbus
138  Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page);
139  Q_SCRIPTABLE Q_NOREPLY void openDocument( const QString &doc );
140  Q_SCRIPTABLE uint pages();
141  Q_SCRIPTABLE uint currentPage();
142  Q_SCRIPTABLE QString currentDocument();
143  Q_SCRIPTABLE QString documentMetaData( const QString &metaData ) const;
144  Q_SCRIPTABLE void slotPreferences();
145  Q_SCRIPTABLE void slotFind();
146  Q_SCRIPTABLE void slotPrintPreview();
147  Q_SCRIPTABLE void slotPreviousPage();
148  Q_SCRIPTABLE void slotNextPage();
149  Q_SCRIPTABLE void slotGotoFirst();
150  Q_SCRIPTABLE void slotGotoLast();
151  Q_SCRIPTABLE void slotTogglePresentation();
152  Q_SCRIPTABLE Q_NOREPLY void reload();
153  Q_SCRIPTABLE Q_NOREPLY void enableStartWithPrint();
154 
155  signals:
156  void enablePrintAction(bool enable);
157  void openSourceReference(const QString& absFileName, int line, int column);
158  void viewerMenuStateChange(bool enabled);
159  void enableCloseAction(bool enable);
160  void mimeTypeChanged(KMimeType::Ptr mimeType);
161  void urlsDropped( const KUrl::List& urls );
162 
163  protected:
164  // reimplemented from KParts::ReadWritePart
165  bool openFile();
166  bool openUrl(const KUrl &url);
167  void guiActivateEvent(KParts::GUIActivateEvent *event);
168  void displayInfoMessage( const QString &message, KMessageWidget::MessageType messageType = KMessageWidget::Information, int duration = -1 );;
169  public:
170  bool saveFile();
171  bool queryClose();
172  bool closeUrl();
173  bool closeUrl(bool promptToSave);
174  void setReadWrite(bool readwrite);
175  bool saveAs(const KUrl & saveUrl);
176 
177  protected slots:
178  // connected to actions
179  void openUrlFromDocument(const KUrl &url);
180  void openUrlFromBookmarks(const KUrl &url);
181  void handleDroppedUrls( const KUrl::List& urls );
182  void slotGoToPage();
183  void slotHistoryBack();
184  void slotHistoryNext();
185  void slotAddBookmark();
186  void slotRenameBookmarkFromMenu();
187  void slotRenameCurrentViewportBookmark();
188  void slotAboutToShowContextMenu(KMenu *menu, QAction *action, QMenu *contextMenu);
189  void slotPreviousBookmark();
190  void slotNextBookmark();
191  void slotFindNext();
192  void slotFindPrev();
193  void slotSaveFileAs();
194  void slotSaveCopyAs();
195  void slotGetNewStuff();
196  void slotNewConfig();
197  void slotShowMenu(const Okular::Page *page, const QPoint &point);
198  void slotShowProperties();
199  void slotShowEmbeddedFiles();
200  void slotShowLeftPanel();
201  void slotShowBottomBar();
202  void slotShowPresentation();
203  void slotHidePresentation();
204  void slotExportAs(QAction *);
205  bool slotImportPSFile();
206  void slotAboutBackend();
207  void slotReload();
208  void close();
209  void cannotQuit();
210  void slotShowFindBar();
211  void slotHideFindBar();
212  void slotJobStarted(KIO::Job *job);
213  void slotJobFinished(KJob *job);
214  void loadCancelled(const QString &reason);
215  void setWindowTitleFromDocument();
216  // can be connected to widget elements
217  void updateViewActions();
218  void updateBookmarksActions();
219  void enableTOC(bool enable);
220  void slotRebuildBookmarkMenu();
221 
222  public slots:
223  // connected to Shell action (and browserExtension), not local one
224  void slotPrint();
225  void restoreDocument(const KConfigGroup &group);
226  void saveDocumentRestoreInfo(KConfigGroup &group);
227  void slotFileDirty( const QString& );
228  void slotDoFileDirty();
229  void psTransformEnded(int, QProcess::ExitStatus);
230  KConfigDialog * slotGeneratorPreferences();
231 
232  void errorMessage( const QString &message, int duration = 0 );
233  void warningMessage( const QString &message, int duration = -1 );
234  void noticeMessage( const QString &message, int duration = -1 );
235 
236  private:
237  Document::OpenResult doOpenFile(const KMimeType::Ptr &mime, const QString &fileNameToOpen, bool *isCompressedFile);
238 
239  void setupViewerActions();
240  void setViewerShortcuts();
241  void setupActions();
242 
243  void setupPrint( QPrinter &printer );
244  void doPrint( QPrinter &printer );
245  bool handleCompressed( QString &destpath, const QString &path, const QString &compressedMimetype );
246  void rebuildBookmarkMenu( bool unplugActions = true );
247  void updateAboutBackendAction();
248  void unsetDummyMode();
249  void slotRenameBookmark( const DocumentViewport &viewport );
250  void resetStartArguments();
251 
252  static int numberOfParts;
253 
254  KTemporaryFile *m_tempfile;
255 
256  // the document
257  Okular::Document * m_document;
258  QString m_temporaryLocalFile;
259  bool isDocumentArchive;
260 
261  // main widgets
262  Sidebar *m_sidebar;
263  SearchWidget *m_searchWidget;
264  FindBar * m_findBar;
265  KMessageWidget * m_topMessage;
266  KMessageWidget * m_formsMessage;
267  KMessageWidget * m_infoMessage;
268  QPointer<ThumbnailList> m_thumbnailList;
269  QPointer<PageView> m_pageView;
270  QPointer<TOC> m_toc;
271  QPointer<MiniBarLogic> m_miniBarLogic;
272  QPointer<MiniBar> m_miniBar;
273  QPointer<MiniBar> m_pageNumberTool;
274  QPointer<QWidget> m_bottomBar;
275  QPointer<PresentationWidget> m_presentationWidget;
276  QPointer<ProgressWidget> m_progressWidget;
277  QPointer<PageSizeLabel> m_pageSizeLabel;
278  QPointer<Reviews> m_reviewsWidget;
279  QPointer<BookmarkList> m_bookmarkList;
280 
281  // document watcher (and reloader) variables
282  KDirWatch *m_watcher;
283  QTimer *m_dirtyHandler;
284  KUrl m_oldUrl;
285  Okular::DocumentViewport m_viewportDirty;
286  bool m_wasPresentationOpen;
287  int m_dirtyToolboxIndex;
288  bool m_wasSidebarVisible;
289  bool m_wasSidebarCollapsed;
290  bool m_fileWasRemoved;
291  Rotation m_dirtyPageRotation;
292 
293  // Remember the search history
294  QStringList m_searchHistory;
295 
296  // actions
297  KAction *m_gotoPage;
298  KAction *m_prevPage;
299  KAction *m_nextPage;
300  KAction *m_beginningOfDocument;
301  KAction *m_endOfDocument;
302  KAction *m_historyBack;
303  KAction *m_historyNext;
304  KAction *m_addBookmark;
305  KAction *m_renameBookmark;
306  KAction *m_prevBookmark;
307  KAction *m_nextBookmark;
308  KAction *m_copy;
309  KAction *m_selectAll;
310  KAction *m_find;
311  KAction *m_findNext;
312  KAction *m_findPrev;
313  KAction *m_saveAs;
314  KAction *m_saveCopyAs;
315  KAction *m_printPreview;
316  KAction *m_showProperties;
317  KAction *m_showEmbeddedFiles;
318  KAction *m_exportAs;
319  QAction *m_exportAsText;
320  QAction *m_exportAsDocArchive;
321  KAction *m_showPresentation;
322  KToggleAction* m_showMenuBarAction;
323  KToggleAction* m_showLeftPanel;
324  KToggleAction* m_showBottomBar;
325  KToggleFullScreenAction* m_showFullScreenAction;
326  KAction *m_aboutBackend;
327  KAction *m_reload;
328  QMenu *m_exportAsMenu;
329  KAction *m_closeFindBar;
330 
331  bool m_actionsSearched;
332  BrowserExtension *m_bExtension;
333 
334  QList<Okular::ExportFormat> m_exportFormats;
335  QList<QAction*> m_bookmarkActions;
336  bool m_cliPresentation;
337  bool m_cliPrint;
338  QString m_addBookmarkText;
339  QIcon m_addBookmarkIcon;
340 
341  EmbedMode m_embedMode;
342 
343  KUrl m_realUrl;
344 
345  KXMLGUIClient *m_generatorGuiClient;
346  FileKeeper *m_keeper;
347 
348  // Timer for m_infoMessage
349  QTimer *m_infoTimer;
350 
351  private slots:
352  void slotAnnotationPreferences();
353  void slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled);
354 };
355 
356 class PartFactory : public KPluginFactory
357 {
358  Q_OBJECT
359 
360  public:
361  PartFactory();
362  virtual ~PartFactory();
363 
364  protected:
365  virtual QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword);
366 };
367 
368 }
369 
370 #endif
371 
372 /* kate: replace-tabs on; indent-width 4; */
QWidget
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
QPrinter
KDocumentViewer
Abstract interface for a document viewer.
Definition: kdocumentviewer.h:22
QPointer
Okular::KHTMLPartMode
Definition: part.h:84
QPoint
Okular::PartFactory
Definition: part.h:356
Okular::ViewerWidgetMode
Definition: part.h:85
observer.h
QTimer
QProcess
QObject
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
QString
QList
QStringList
QMenu
OKULAR_PART_EXPORT
#define OKULAR_PART_EXPORT
Definition: okular_part_export.h:30
viewerinterface.h
QVector
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:76
QAction
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:1016
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
QIcon
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:25 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