okular
part.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _PART_H_
00017 #define _PART_H_
00018
00019 #include <kparts/browserextension.h>
00020 #include <kparts/part.h>
00021 #include <qicon.h>
00022 #include <qlist.h>
00023 #include <qpointer.h>
00024 #include <qprocess.h>
00025 #include "core/observer.h"
00026 #include "core/document.h"
00027 #include "kdocumentviewer.h"
00028
00029 #include <QtDBus/QtDBus>
00030
00031 class QAction;
00032 class QWidget;
00033 class QPrinter;
00034
00035 class KUrl;
00036 class KConfigGroup;
00037 class KDirWatch;
00038 class KToggleAction;
00039 class KToggleFullScreenAction;
00040 class KSelectAction;
00041 class KAboutData;
00042 class KTemporaryFile;
00043
00044 class FindBar;
00045 class ThumbnailList;
00046 class PageSizeLabel;
00047 class PageView;
00048 class PageViewTopMessage;
00049 class PresentationWidget;
00050 class ProgressWidget;
00051 class SearchWidget;
00052 class Sidebar;
00053 class TOC;
00054 class MiniBar;
00055
00056 namespace Okular
00057 {
00058 class ExportFormat;
00059 }
00060
00061 class BrowserExtension;
00062
00071 class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, public KDocumentViewer
00072 {
00073 Q_OBJECT
00074 Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
00075 Q_INTERFACES(KDocumentViewer)
00076
00077 public:
00078
00079 Part(QWidget* parentWidget, QObject* parent, const QVariantList& args);
00080
00081
00082 ~Part();
00083
00084
00085 uint observerId() const { return PART_ID; }
00086 void notifySetup( const QVector< Okular::Page * > &pages, int setupFlags );
00087 void notifyViewportChanged( bool smoothMove );
00088 void notifyPageChanged( int page, int flags );
00089
00090 bool openDocument(const KUrl& url, uint page);
00091 void startPresentation();
00092 QStringList supportedMimeTypes() const;
00093
00094 KUrl realUrl() const;
00095
00096 public slots:
00097 Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page);
00098 Q_SCRIPTABLE Q_NOREPLY void openDocument( const QString &doc );
00099 Q_SCRIPTABLE uint pages();
00100 Q_SCRIPTABLE uint currentPage();
00101 Q_SCRIPTABLE QString currentDocument();
00102 Q_SCRIPTABLE void slotPreferences();
00103 Q_SCRIPTABLE void slotFind();
00104 Q_SCRIPTABLE void slotPrintPreview();
00105 Q_SCRIPTABLE void slotPreviousPage();
00106 Q_SCRIPTABLE void slotNextPage();
00107 Q_SCRIPTABLE void slotGotoFirst();
00108 Q_SCRIPTABLE void slotGotoLast();
00109 Q_SCRIPTABLE void slotTogglePresentation();
00110
00111 signals:
00112 void enablePrintAction(bool enable);
00113
00114 protected:
00115
00116 bool openFile();
00117 bool openUrl(const KUrl &url);
00118 bool closeUrl();
00119
00120 protected slots:
00121
00122 void openUrlFromDocument(const KUrl &url);
00123 void openUrlFromBookmarks(const KUrl &url);
00124 void slotGoToPage();
00125 void slotHistoryBack();
00126 void slotHistoryNext();
00127 void slotAddBookmark();
00128 void slotPreviousBookmark();
00129 void slotNextBookmark();
00130 void slotFindNext();
00131 void slotSaveFileAs();
00132 void slotGetNewStuff();
00133 void slotNewConfig();
00134 void slotNewGeneratorConfig();
00135 void slotShowMenu(const Okular::Page *page, const QPoint &point);
00136 void slotShowProperties();
00137 void slotShowEmbeddedFiles();
00138 void slotShowLeftPanel();
00139 void slotShowPresentation();
00140 void slotHidePresentation();
00141 void slotExportAs(QAction *);
00142 bool slotImportPSFile();
00143 void slotAboutBackend();
00144 void slotReload();
00145 void close();
00146 void cannotQuit();
00147 void slotShowFindBar();
00148 void slotHideFindBar();
00149 void setMimeTypes(KIO::Job *job);
00150 void loadCancelled(const QString &reason);
00151 void setWindowTitleFromDocument();
00152
00153 void updateViewActions();
00154 void updateBookmarksActions();
00155 void enableTOC(bool enable);
00156 void slotRebuildBookmarkMenu();
00157
00158 public slots:
00159
00160 void slotPrint();
00161 void restoreDocument(const KConfigGroup &group);
00162 void saveDocumentRestoreInfo(KConfigGroup &group);
00163 void slotFileDirty( const QString& );
00164 void slotDoFileDirty();
00165 void psTransformEnded(int, QProcess::ExitStatus);
00166
00167 private:
00168 void setupPrint( QPrinter &printer );
00169 void doPrint( QPrinter &printer );
00170 bool handleCompressed( QString &destpath, const QString &path, const QString &compressedMimetype );
00171 void rebuildBookmarkMenu( bool unplugActions = true );
00172 void updateAboutBackendAction();
00173 void unsetDummyMode();
00174
00175 KTemporaryFile *m_tempfile;
00176
00177
00178 Okular::Document * m_document;
00179 QString m_temporaryLocalFile;
00180
00181
00182 Sidebar *m_sidebar;
00183 SearchWidget *m_searchWidget;
00184 FindBar * m_findBar;
00185 PageViewTopMessage * m_topMessage;
00186 PageViewTopMessage * m_formsMessage;
00187 QPointer<ThumbnailList> m_thumbnailList;
00188 QPointer<PageView> m_pageView;
00189 QPointer<TOC> m_toc;
00190 QPointer<MiniBar> m_miniBar;
00191 QPointer<PresentationWidget> m_presentationWidget;
00192 QPointer<ProgressWidget> m_progressWidget;
00193 QPointer<PageSizeLabel> m_pageSizeLabel;
00194
00195
00196 KDirWatch *m_watcher;
00197 QTimer *m_dirtyHandler;
00198 Okular::DocumentViewport m_viewportDirty;
00199 bool m_wasPresentationOpen;
00200 int m_dirtyToolboxIndex;
00201 bool m_wasSidebarVisible;
00202
00203
00204 QStringList m_searchHistory;
00205
00206
00207 QAction *m_gotoPage;
00208 QAction *m_prevPage;
00209 QAction *m_nextPage;
00210 QAction *m_firstPage;
00211 QAction *m_lastPage;
00212 QAction *m_historyBack;
00213 QAction *m_historyNext;
00214 QAction *m_addBookmark;
00215 QAction *m_prevBookmark;
00216 QAction *m_nextBookmark;
00217 QAction *m_copy;
00218 QAction *m_selectAll;
00219 QAction *m_find;
00220 QAction *m_findNext;
00221 QAction *m_saveAs;
00222 QAction *m_printPreview;
00223 QAction *m_showProperties;
00224 QAction *m_showEmbeddedFiles;
00225 QAction *m_exportAs;
00226 QAction *m_exportAsText;
00227 QAction *m_showPresentation;
00228 KToggleAction* m_showMenuBarAction;
00229 KToggleAction* m_showLeftPanel;
00230 KToggleFullScreenAction* m_showFullScreenAction;
00231 QAction *m_aboutBackend;
00232 QAction *m_reload;
00233
00234 bool m_actionsSearched;
00235 BrowserExtension *m_bExtension;
00236
00237 QList<Okular::ExportFormat> m_exportFormats;
00238 QList<QAction*> m_bookmarkActions;
00239 bool m_cliPresentation;
00240 QString m_addBookmarkText;
00241 QIcon m_addBookmarkIcon;
00242
00243 bool m_dummyMode;
00244
00245 KUrl m_realUrl;
00246
00247 KXMLGUIClient *m_generatorGuiClient;
00248
00249 private slots:
00250 void slotGeneratorPreferences();
00251 };
00252
00253 class BrowserExtension : public KParts::BrowserExtension
00254 {
00255 Q_OBJECT
00256
00257 public:
00258 BrowserExtension(Part*);
00259
00260 public slots:
00261
00262 void print();
00263
00264 private:
00265 Part *m_part;
00266 };
00267 #endif
00268
00269