Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

part.h 5.28 KB
Newer Older
1 2 3 4 5 6 7
/***************************************************************************
 *   Copyright (C) 2002 by Wilco Greven <greven@kde.org>                   *
 *   Copyright (C) 2003-2004 by Christophe Devriese                        *
 *                         <Christophe.Devriese@student.kuleuven.ac.be>    *
 *   Copyright (C) 2003 by Andy Goossens <andygoossens@telenet.be>         *
 *   Copyright (C) 2003 by Laurent Montel <montel@kde.org>                 *
 *   Copyright (C) 2004 by Dominique Devriese <devriese@kde.org>           *
Albert Astals Cid's avatar
Albert Astals Cid committed
8
 *   Copyright (C) 2004-2006 by Albert Astals Cid <tsdgeos@terra.es>       *
9 10 11 12 13 14 15
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

16 17 18
#ifndef _KPDF_PART_H_
#define _KPDF_PART_H_

Wilco Greven's avatar
Wilco Greven committed
19
#include <kparts/browserextension.h>
20
#include <kparts/part.h>
21
#include <qpointer.h>
22
#include "core/observer.h"
23
#include "core/document.h"
24
#include "dcop.h"
25

26
class QWidget;
27
class QSplitter;
28
class QToolBox;
29

Pino Toscano's avatar
porting  
Pino Toscano committed
30
class KUrl;
31
class KAction;
32
class KConfig;
Albert Astals Cid's avatar
Albert Astals Cid committed
33
class KDirWatch;
34
class KToggleAction;
35
class KSelectAction;
36 37
class KAboutData;
class KPrinter;
38

39
class KPDFDocument;
Albert Astals Cid's avatar
Albert Astals Cid committed
40
class ThumbnailList;
41
class ThumbnailController;
42
class PageView;
43
class PresentationWidget;
44
class SearchWidget;
Albert Astals Cid's avatar
Albert Astals Cid committed
45 46
class TOC;
class MiniBar;
47

Albert Astals Cid's avatar
Albert Astals Cid committed
48
namespace oKular {
49 50 51 52 53 54 55 56 57 58 59

class BrowserExtension;

/**
 * This is a "Part".  It that does all the real work in a KPart
 * application.
 *
 * @short Main Part
 * @author Wilco Greven <greven@kde.org>
 * @version 0.2
 */
Albert Astals Cid's avatar
Albert Astals Cid committed
60
class Part : public KParts::ReadOnlyPart, public DocumentObserver, virtual public okular_dcop
61
{
62 63 64 65
Q_OBJECT

public:
	// Default constructor
Albert Astals Cid's avatar
compile  
Albert Astals Cid committed
66
	Part(QWidget* parentWidget, QObject* parent, const QStringList& args);
67

68 69
	// Destructor
	~Part();
70

71
    // inherited from DocumentObserver
72
    uint observerId() const { return PART_ID; }
Enrico Ros's avatar
Enrico Ros committed
73
    void notifyViewportChanged( bool smoothMove );
74

75
	static KAboutData* createAboutData();
76

77
	ASYNC goToPage(uint page);
Pino Toscano's avatar
porting  
Pino Toscano committed
78
	ASYNC openDocument(KUrl doc);
79
	uint pages();
Enrico Ros's avatar
Enrico Ros committed
80
	uint currentPage();
Pino Toscano's avatar
porting  
Pino Toscano committed
81
	KUrl currentDocument();
82

Piotr Szymanski's avatar
Piotr Szymanski committed
83 84 85
signals:
	void enablePrintAction(bool enable);

86
protected:
87
	// reimplemented from KParts::ReadOnlyPart
88
	bool openFile();
Pino Toscano's avatar
porting  
Pino Toscano committed
89
	bool openURL(const KUrl &url);
90
	bool closeURL();
91 92
	// filter that watches for splitter size changes
	bool eventFilter( QObject * watched, QEvent * e );
93
	void supportedMimetypes();
Laurent Montel's avatar
Laurent Montel committed
94

95
protected slots:
96
	// connected to actions
Pino Toscano's avatar
porting  
Pino Toscano committed
97
	void openURLFromDocument(const KUrl &url);
98 99 100
	void slotGoToPage();
	void slotPreviousPage();
	void slotNextPage();
101 102
	void slotGotoFirst();
	void slotGotoLast();
103 104
	void slotHistoryBack();
	void slotHistoryNext();
105 106
	void slotFind();
	void slotFindNext();
107
	void slotSaveFileAs();
Enrico Ros's avatar
Enrico Ros committed
108
	void slotGetNewStuff();
109 110 111
	void slotPreferences();
	void slotNewConfig();
	void slotPrintPreview();
112
	void slotShowMenu(const KPDFPage *page, const QPoint &point);
Albert Astals Cid's avatar
Albert Astals Cid committed
113
	void slotShowProperties();
114
	void slotShowLeftPanel();
115
	void slotShowPresentation();
116
	void slotHidePresentation();
117
	bool slotImportPSFile();
Piotr Szymanski's avatar
Piotr Szymanski committed
118 119 120 121
	void close();
	void cannotQuit();
	void setMimeTypes(KIO::Job *job);
    void saveSplitterSize();
122
	// can be connected to widget elements
123
	void updateViewActions();
124
	void enableTOC(bool enable);
125

126
public slots:
127
	// connected to Shell action (and browserExtension), not local one
128
	void slotPrint();
Pino Toscano's avatar
porting  
Pino Toscano committed
129
	void restoreDocument(const KUrl &url, int page);
Albert Astals Cid's avatar
Albert Astals Cid committed
130 131 132
	void saveDocumentRestoreInfo(KConfig* config);
	void slotFileDirty( const QString& );
	void slotDoFileDirty();
133
	void psTransformEnded();
134

135 136
private:
	void doPrint( KPrinter& printer );
137
    void fillGenerators();
138

139
	// the document
140
	KPDFDocument * m_document;
141
	QString m_temporaryLocalFile;
142 143

	// main widgets
144
	QSplitter *m_splitter;
145
	QWidget *m_leftPanel;
146
	QToolBox *m_toolBox;
147
	SearchWidget *m_searchWidget;
148 149 150 151 152
	QPointer<ThumbnailList> m_thumbnailList;
	QPointer<PageView> m_pageView;
	QPointer<TOC> m_toc;
	QPointer<MiniBar> m_miniBar;
	QPointer<PresentationWidget> m_presentationWidget;
153

154
	// document watcher (and reloader) variables
Albert Astals Cid's avatar
Albert Astals Cid committed
155 156
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
157
	DocumentViewport m_viewportDirty;
158 159 160 161 162 163 164

	// actions
	KAction *m_gotoPage;
	KAction *m_prevPage;
	KAction *m_nextPage;
	KAction *m_firstPage;
	KAction *m_lastPage;
165 166
	KAction *m_historyBack;
	KAction *m_historyNext;
167 168
	KAction *m_find;
	KAction *m_findNext;
169 170
	KAction *m_saveAs;
	KAction *m_printPreview;
Albert Astals Cid's avatar
Albert Astals Cid committed
171
	KAction *m_showProperties;
172
	KAction *m_showPresentation;
173
	KToggleAction* m_showMenuBarAction;
174
	KToggleAction* m_showLeftPanel;
Albert Astals Cid's avatar
Albert Astals Cid committed
175
	KToggleAction* m_showFullScreenAction;
176

Albert Astals Cid's avatar
Albert Astals Cid committed
177
	bool m_actionsSearched;
178
	bool m_searchStarted;
179
	BrowserExtension *m_bExtension;
180

181 182
    // QHash: key is the name of the generator
   QHash<QString, Generator*> m_loadedGenerators;
183 184
    // list of names of the generators that have settings
    QStringList m_generatorsWithSettings;
Piotr Szymanski's avatar
Piotr Szymanski committed
185
    QStringList m_supportedMimeTypes;
186 187 188 189
    KSelectAction * m_confGens;

    private slots:
    void slotGeneratorPreferences();
190
};
Wilco Greven's avatar
Wilco Greven committed
191

192

193 194 195 196 197
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
198
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
199

200
public slots:
201 202
	// Automatically detected by the host.
	void print();
203
};
204

205 206 207 208 209
}

#endif

// vim:ts=2:sw=2:tw=78:et