2004-08-26 21:17:24 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* 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. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2002-08-30 09:14:01 +00:00
|
|
|
#ifndef _KPDF_PART_H_
|
|
|
|
#define _KPDF_PART_H_
|
|
|
|
|
2002-09-02 21:56:00 +00:00
|
|
|
#include <kparts/browserextension.h>
|
2002-08-30 09:14:01 +00:00
|
|
|
#include <kparts/part.h>
|
2005-01-28 11:04:03 +00:00
|
|
|
#include <qguardedptr.h>
|
2005-01-02 14:55:14 +00:00
|
|
|
#include "core/observer.h"
|
2005-07-15 18:20:57 +00:00
|
|
|
#include "core/document.h"
|
2005-01-02 14:29:37 +00:00
|
|
|
#include "dcop.h"
|
2004-10-12 11:08:09 +00:00
|
|
|
|
2002-08-30 09:14:01 +00:00
|
|
|
class QWidget;
|
2004-09-11 15:59:32 +00:00
|
|
|
class QSplitter;
|
2004-09-23 21:49:00 +00:00
|
|
|
class QToolBox;
|
2002-08-30 09:14:01 +00:00
|
|
|
|
|
|
|
class KURL;
|
2004-09-11 15:59:32 +00:00
|
|
|
class KAction;
|
2004-11-01 21:56:08 +00:00
|
|
|
class KConfig;
|
2004-12-01 22:18:27 +00:00
|
|
|
class KDirWatch;
|
2002-08-30 09:14:01 +00:00
|
|
|
class KToggleAction;
|
2003-09-15 21:57:19 +00:00
|
|
|
class KSelectAction;
|
2004-09-11 15:59:32 +00:00
|
|
|
class KAboutData;
|
|
|
|
class KPrinter;
|
2002-08-30 09:14:01 +00:00
|
|
|
|
2005-01-02 14:55:14 +00:00
|
|
|
class KPDFDocument;
|
2004-09-07 22:35:33 +00:00
|
|
|
class ThumbnailList;
|
2005-01-03 15:51:05 +00:00
|
|
|
class ThumbnailController;
|
2004-09-23 17:16:04 +00:00
|
|
|
class PageView;
|
2005-01-28 11:04:03 +00:00
|
|
|
class PresentationWidget;
|
2004-09-16 21:27:34 +00:00
|
|
|
class SearchWidget;
|
2004-09-08 12:41:14 +00:00
|
|
|
|
2005-10-17 19:16:31 +00:00
|
|
|
namespace oKular {
|
2004-10-09 08:10:56 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2005-10-17 19:20:32 +00:00
|
|
|
class Part : public KParts::ReadOnlyPart, public DocumentObserver, virtual public okular_dcop
|
2002-08-30 09:14:01 +00:00
|
|
|
{
|
2004-10-09 08:10:56 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Default constructor
|
2004-09-08 12:41:14 +00:00
|
|
|
Part(QWidget* parentWidget, const char* widgetName,
|
|
|
|
QObject* parent, const char* name, const QStringList& args);
|
2002-08-30 09:14:01 +00:00
|
|
|
|
2004-10-09 08:10:56 +00:00
|
|
|
// Destructor
|
|
|
|
~Part();
|
2002-08-30 12:10:02 +00:00
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// inherited from DocumentObserver
|
2004-11-09 17:20:19 +00:00
|
|
|
uint observerId() const { return PART_ID; }
|
2005-02-01 18:23:55 +00:00
|
|
|
void notifyViewportChanged( bool smoothMove );
|
2004-11-09 17:20:19 +00:00
|
|
|
|
2004-09-08 12:41:14 +00:00
|
|
|
static KAboutData* createAboutData();
|
2004-11-09 17:20:19 +00:00
|
|
|
|
2004-10-12 11:08:09 +00:00
|
|
|
ASYNC goToPage(uint page);
|
|
|
|
ASYNC openDocument(KURL doc);
|
|
|
|
uint pages();
|
2005-06-13 17:39:58 +00:00
|
|
|
uint currentPage();
|
|
|
|
KURL currentDocument();
|
2004-01-02 17:46:06 +00:00
|
|
|
|
2005-11-04 11:59:51 +00:00
|
|
|
signals:
|
|
|
|
void enablePrintAction(bool enable);
|
|
|
|
|
2004-10-09 08:10:56 +00:00
|
|
|
protected:
|
2004-09-08 12:41:14 +00:00
|
|
|
// reimplemented from KParts::ReadOnlyPart
|
2004-10-09 08:10:56 +00:00
|
|
|
bool openFile();
|
|
|
|
bool openURL(const KURL &url);
|
2004-09-08 12:41:14 +00:00
|
|
|
bool closeURL();
|
2005-04-07 12:47:24 +00:00
|
|
|
// filter that watches for splitter size changes
|
|
|
|
bool eventFilter( QObject * watched, QEvent * e );
|
2005-12-07 21:25:25 +00:00
|
|
|
void supportedMimetypes();
|
2003-09-15 09:35:55 +00:00
|
|
|
|
2004-10-09 08:10:56 +00:00
|
|
|
protected slots:
|
2004-09-08 12:41:14 +00:00
|
|
|
// connected to actions
|
2005-11-04 11:59:51 +00:00
|
|
|
void openURLFromDocument(const KURL &url);
|
2004-09-08 12:41:14 +00:00
|
|
|
void slotGoToPage();
|
|
|
|
void slotPreviousPage();
|
|
|
|
void slotNextPage();
|
2004-09-11 15:59:32 +00:00
|
|
|
void slotGotoFirst();
|
|
|
|
void slotGotoLast();
|
2005-01-27 17:31:07 +00:00
|
|
|
void slotHistoryBack();
|
|
|
|
void slotHistoryNext();
|
2004-09-08 12:41:14 +00:00
|
|
|
void slotFind();
|
|
|
|
void slotFindNext();
|
2005-01-27 17:31:07 +00:00
|
|
|
void slotSaveFileAs();
|
2005-04-16 00:25:26 +00:00
|
|
|
void slotGetNewStuff();
|
2005-01-27 17:31:07 +00:00
|
|
|
void slotPreferences();
|
|
|
|
void slotNewConfig();
|
|
|
|
void slotPrintPreview();
|
2004-12-04 23:23:18 +00:00
|
|
|
void slotShowMenu(const KPDFPage *page, const QPoint &point);
|
2004-12-05 22:47:32 +00:00
|
|
|
void slotShowProperties();
|
2005-03-12 15:39:04 +00:00
|
|
|
void slotShowLeftPanel();
|
2005-01-27 17:31:07 +00:00
|
|
|
void slotShowPresentation();
|
2005-04-07 09:53:15 +00:00
|
|
|
void slotHidePresentation();
|
2005-07-15 18:20:57 +00:00
|
|
|
bool slotImportPSFile();
|
2005-11-04 11:59:51 +00:00
|
|
|
void close();
|
|
|
|
void cannotQuit();
|
|
|
|
void setMimeTypes(KIO::Job *job);
|
|
|
|
void saveSplitterSize();
|
2004-09-11 15:59:32 +00:00
|
|
|
// can be connected to widget elements
|
2005-02-02 18:18:26 +00:00
|
|
|
void updateViewActions();
|
2004-09-23 21:49:00 +00:00
|
|
|
void enableTOC(bool enable);
|
2004-09-08 12:41:14 +00:00
|
|
|
|
2004-10-09 08:10:56 +00:00
|
|
|
public slots:
|
2004-09-08 12:41:14 +00:00
|
|
|
// connected to Shell action (and browserExtension), not local one
|
2004-09-18 16:41:23 +00:00
|
|
|
void slotPrint();
|
2004-12-01 22:18:27 +00:00
|
|
|
void restoreDocument(const KURL &url, int page);
|
|
|
|
void saveDocumentRestoreInfo(KConfig* config);
|
|
|
|
void slotFileDirty( const QString& );
|
|
|
|
void slotDoFileDirty();
|
2005-07-15 18:20:57 +00:00
|
|
|
void psTransformEnded();
|
2003-09-15 21:57:19 +00:00
|
|
|
|
2004-10-09 08:10:56 +00:00
|
|
|
private:
|
|
|
|
void doPrint( KPrinter& printer );
|
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
|
|
|
void fillGenerators();
|
2004-10-09 08:10:56 +00:00
|
|
|
|
2004-09-08 12:41:14 +00:00
|
|
|
// the document
|
2004-11-09 17:20:19 +00:00
|
|
|
KPDFDocument * m_document;
|
2005-07-15 18:20:57 +00:00
|
|
|
QString m_temporaryLocalFile;
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
// main widgets
|
2004-09-11 15:59:32 +00:00
|
|
|
QSplitter *m_splitter;
|
2005-02-12 14:34:12 +00:00
|
|
|
QWidget *m_leftPanel;
|
2004-09-27 21:36:25 +00:00
|
|
|
QToolBox *m_toolBox;
|
2005-01-03 15:51:05 +00:00
|
|
|
SearchWidget *m_searchWidget;
|
2004-09-08 12:41:14 +00:00
|
|
|
ThumbnailList *m_thumbnailList;
|
2004-09-23 17:16:04 +00:00
|
|
|
PageView *m_pageView;
|
2005-02-02 18:18:26 +00:00
|
|
|
QGuardedPtr<PresentationWidget> m_presentationWidget;
|
2004-09-08 12:41:14 +00:00
|
|
|
|
2005-06-24 16:39:57 +00:00
|
|
|
// document watcher (and reloader) variables
|
2004-12-01 22:18:27 +00:00
|
|
|
KDirWatch *m_watcher;
|
|
|
|
QTimer *m_dirtyHandler;
|
2005-07-15 18:20:57 +00:00
|
|
|
DocumentViewport m_viewportDirty;
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
// actions
|
|
|
|
KAction *m_gotoPage;
|
|
|
|
KAction *m_prevPage;
|
|
|
|
KAction *m_nextPage;
|
|
|
|
KAction *m_firstPage;
|
|
|
|
KAction *m_lastPage;
|
2005-01-27 17:31:07 +00:00
|
|
|
KAction *m_historyBack;
|
|
|
|
KAction *m_historyNext;
|
2004-09-08 12:41:14 +00:00
|
|
|
KAction *m_find;
|
|
|
|
KAction *m_findNext;
|
2005-01-27 17:31:07 +00:00
|
|
|
KAction *m_saveAs;
|
|
|
|
KAction *m_printPreview;
|
2004-12-05 22:47:32 +00:00
|
|
|
KAction *m_showProperties;
|
2005-01-03 15:51:05 +00:00
|
|
|
KAction *m_showPresentation;
|
2004-12-04 23:23:18 +00:00
|
|
|
KToggleAction* m_showMenuBarAction;
|
2005-03-12 15:39:04 +00:00
|
|
|
KToggleAction* m_showLeftPanel;
|
2004-12-13 00:27:09 +00:00
|
|
|
KToggleAction* m_showFullScreenAction;
|
|
|
|
bool m_actionsSearched;
|
2005-02-02 18:18:26 +00:00
|
|
|
bool m_searchStarted;
|
2005-06-24 16:42:44 +00:00
|
|
|
BrowserExtension *m_bExtension;
|
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
|
|
|
|
|
|
|
// QDict: key is the name of the generator
|
|
|
|
QDict<Generator> m_loadedGenerators;
|
|
|
|
// list of names of the generators that have settings
|
|
|
|
QStringList m_generatorsWithSettings;
|
2005-11-04 11:59:51 +00:00
|
|
|
QStringList m_supportedMimeTypes;
|
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
|
|
|
KSelectAction * m_confGens;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void slotGeneratorPreferences();
|
2004-10-09 08:10:56 +00:00
|
|
|
};
|
2002-09-02 21:56:00 +00:00
|
|
|
|
2003-09-14 14:22:37 +00:00
|
|
|
|
2004-10-09 08:10:56 +00:00
|
|
|
class BrowserExtension : public KParts::BrowserExtension
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2004-09-08 12:41:14 +00:00
|
|
|
BrowserExtension(Part*);
|
2002-09-02 21:56:00 +00:00
|
|
|
|
2004-10-09 08:10:56 +00:00
|
|
|
public slots:
|
2004-09-08 12:41:14 +00:00
|
|
|
// Automatically detected by the host.
|
|
|
|
void print();
|
2004-10-09 08:10:56 +00:00
|
|
|
};
|
2003-09-14 14:22:37 +00:00
|
|
|
|
2002-08-30 09:14:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// vim:ts=2:sw=2:tw=78:et
|