part.h 4.52 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/***************************************************************************
 *   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>           *
 *   Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es>            *
 *                                                                         *
 *   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 <qguardedptr.h>
22
#include "core/observer.h"
23
#include "dcop.h"
24

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

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

38
class KPDFDocument;
Albert Astals Cid's avatar
Albert Astals Cid committed
39
class ThumbnailList;
40
class ThumbnailController;
41
class PageView;
42
class PresentationWidget;
43
class SearchWidget;
44

45 46 47 48 49 50 51 52 53 54 55 56
namespace KPDF {

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
 */
57
class Part : public KParts::ReadOnlyPart, public DocumentObserver, virtual public kpdf_dcop
58
{
59 60 61 62
Q_OBJECT

public:
	// Default constructor
63 64
	Part(QWidget* parentWidget, const char* widgetName,
	     QObject* parent, const char* name, const QStringList& args);
65

66 67
	// Destructor
	~Part();
68

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

73
	static KAboutData* createAboutData();
74

75 76 77
	ASYNC goToPage(uint page);
	ASYNC openDocument(KURL doc);
	uint pages();
Enrico Ros's avatar
Enrico Ros committed
78 79
	uint currentPage();
	KURL currentDocument();
80

81
protected:
82
	// reimplemented from KParts::ReadOnlyPart
83 84
	bool openFile();
	bool openURL(const KURL &url);
85
	bool closeURL();
86 87
	// filter that watches for splitter size changes
	bool eventFilter( QObject * watched, QEvent * e );
Laurent Montel's avatar
Laurent Montel committed
88

89
protected slots:
90 91 92 93
	// connected to actions
	void slotGoToPage();
	void slotPreviousPage();
	void slotNextPage();
94 95
	void slotGotoFirst();
	void slotGotoLast();
96 97
	void slotHistoryBack();
	void slotHistoryNext();
98 99
	void slotFind();
	void slotFindNext();
100
	void slotSaveFileAs();
Enrico Ros's avatar
Enrico Ros committed
101
	void slotGetNewStuff();
102 103 104
	void slotPreferences();
	void slotNewConfig();
	void slotPrintPreview();
105
	void slotShowMenu(const KPDFPage *page, const QPoint &point);
Albert Astals Cid's avatar
Albert Astals Cid committed
106
	void slotShowProperties();
107
	void slotShowLeftPanel();
108
	void slotShowPresentation();
109
	void slotHidePresentation();
110
	// can be connected to widget elements
111
	void updateViewActions();
112
	void enableTOC(bool enable);
113

114
public slots:
115
	// connected to Shell action (and browserExtension), not local one
116
	void slotPrint();
Albert Astals Cid's avatar
Albert Astals Cid committed
117 118 119 120
	void restoreDocument(const KURL &url, int page);
	void saveDocumentRestoreInfo(KConfig* config);
	void slotFileDirty( const QString& );
	void slotDoFileDirty();
121

122 123 124
private:
	void doPrint( KPrinter& printer );

125
	// the document
126
	KPDFDocument * m_document;
127 128

	// main widgets
129
	QSplitter *m_splitter;
130
	QWidget *m_leftPanel;
131
	QToolBox *m_toolBox;
132
	SearchWidget *m_searchWidget;
133
	ThumbnailList *m_thumbnailList;
134
	PageView *m_pageView;
135
	QGuardedPtr<PresentationWidget> m_presentationWidget;
136 137 138

	// static instances counter
	static unsigned int m_count;
139

Albert Astals Cid's avatar
Albert Astals Cid committed
140 141
	KDirWatch *m_watcher;
	QTimer *m_dirtyHandler;
142 143 144 145 146 147 148

	// actions
	KAction *m_gotoPage;
	KAction *m_prevPage;
	KAction *m_nextPage;
	KAction *m_firstPage;
	KAction *m_lastPage;
149 150
	KAction *m_historyBack;
	KAction *m_historyNext;
151 152
	KAction *m_find;
	KAction *m_findNext;
153 154
	KAction *m_saveAs;
	KAction *m_printPreview;
Albert Astals Cid's avatar
Albert Astals Cid committed
155
	KAction *m_showProperties;
156
	KAction *m_showPresentation;
157
	KToggleAction* m_showMenuBarAction;
158
	KToggleAction* m_showLeftPanel;
Albert Astals Cid's avatar
Albert Astals Cid committed
159 160
	KToggleAction* m_showFullScreenAction;
	bool m_actionsSearched;
161
	bool m_searchStarted;
162
};
Wilco Greven's avatar
Wilco Greven committed
163

164

165 166 167 168 169
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT

public:
170
	BrowserExtension(Part*);
Wilco Greven's avatar
Wilco Greven committed
171

172
public slots:
173 174
	// Automatically detected by the host.
	void print();
175
};
176

177 178 179 180 181
}

#endif

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