Changeset View
Changeset View
Standalone View
Standalone View
ui/pageviewannotator.h
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> * | 2 | * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> * | ||
3 | * * | 3 | * * | ||
4 | * This program is free software; you can redistribute it and/or modify * | 4 | * This program is free software; you can redistribute it and/or modify * | ||
5 | * it under the terms of the GNU General Public License as published by * | 5 | * it under the terms of the GNU General Public License as published by * | ||
6 | * the Free Software Foundation; either version 2 of the License, or * | 6 | * the Free Software Foundation; either version 2 of the License, or * | ||
7 | * (at your option) any later version. * | 7 | * (at your option) any later version. * | ||
8 | ***************************************************************************/ | 8 | ***************************************************************************/ | ||
9 | 9 | | |||
10 | #ifndef _OKULAR_PAGEVIEWANNOTATOR_H_ | 10 | #ifndef _OKULAR_PAGEVIEWANNOTATOR_H_ | ||
11 | #define _OKULAR_PAGEVIEWANNOTATOR_H_ | 11 | #define _OKULAR_PAGEVIEWANNOTATOR_H_ | ||
12 | 12 | | |||
13 | #include <qaction.h> | ||||
13 | #include <qobject.h> | 14 | #include <qobject.h> | ||
14 | #include <qdom.h> | 15 | #include <qdom.h> | ||
15 | #include <qlinkedlist.h> | 16 | #include <qlinkedlist.h> | ||
16 | 17 | | |||
18 | #include <kactioncollection.h> | ||||
19 | | ||||
17 | #include "pageviewutils.h" | 20 | #include "pageviewutils.h" | ||
18 | #include "annotationtools.h" | 21 | #include "annotationtools.h" | ||
19 | 22 | | |||
20 | class QKeyEvent; | 23 | class QKeyEvent; | ||
21 | class QMouseEvent; | 24 | class QMouseEvent; | ||
22 | class QPainter; | 25 | class QPainter; | ||
26 | class AnnotationActionHandler; | ||||
23 | 27 | | |||
24 | namespace Okular | 28 | namespace Okular | ||
25 | { | 29 | { | ||
26 | class Document; | 30 | class Document; | ||
27 | } | 31 | } | ||
28 | 32 | | |||
29 | // engines are defined and implemented in the cpp | 33 | // engines are defined and implemented in the cpp | ||
30 | class AnnotatorEngine; | 34 | class AnnotatorEngine; | ||
35 | class AnnotationTools; | ||||
31 | class PageView; | 36 | class PageView; | ||
32 | 37 | | |||
33 | /** | 38 | /** | ||
34 | * @short PageView object devoted to annotation creation/handling. | 39 | * @short PageView object devoted to annotation creation/handling. | ||
35 | * | 40 | * | ||
36 | * PageViewAnnotator is the okular class used for visually creating annotations. | 41 | * PageViewAnnotator is the okular class used for visually creating annotations. | ||
37 | * It uses internal 'engines' for interacting with user events and attaches | 42 | * It uses internal 'engines' for interacting with user events and attaches | ||
38 | * the newly created annotation to the document when the creation is complete. | 43 | * the newly created annotation to the document when the creation is complete. | ||
Show All 10 Lines | |||||
49 | */ | 54 | */ | ||
50 | class PageViewAnnotator : public QObject | 55 | class PageViewAnnotator : public QObject | ||
51 | { | 56 | { | ||
52 | Q_OBJECT | 57 | Q_OBJECT | ||
53 | public: | 58 | public: | ||
54 | PageViewAnnotator( PageView * parent, Okular::Document * storage ); | 59 | PageViewAnnotator( PageView * parent, Okular::Document * storage ); | ||
55 | ~PageViewAnnotator(); | 60 | ~PageViewAnnotator(); | ||
56 | 61 | | |||
62 | void setupActions( KActionCollection *ac ); | ||||
63 | | ||||
57 | // called to show/hide the editing toolbar | 64 | // called to show/hide the editing toolbar | ||
58 | void setEnabled( bool enabled ); | 65 | void setEnabled( bool enabled ); | ||
59 | 66 | | |||
60 | // called to toggle the usage of text annotating tools | 67 | // called to toggle the usage of text annotating tools | ||
61 | void setTextToolsEnabled( bool enabled ); | 68 | void setTextToolsEnabled( bool enabled ); | ||
62 | 69 | | |||
63 | void setToolsEnabled( bool enabled ); | 70 | void setToolsEnabled( bool enabled ); | ||
64 | 71 | | |||
65 | void setHidingForced( bool forced ); | | |||
66 | bool hidingWasForced() const; | | |||
67 | | ||||
68 | // methods used when creating the annotation | 72 | // methods used when creating the annotation | ||
69 | // @return Is a tool currently selected? | 73 | // @return Is a tool currently selected? | ||
70 | bool active() const; | 74 | bool active() const; | ||
71 | // @return Are we currently annotating (using the selected tool)? | 75 | // @return Are we currently annotating (using the selected tool)? | ||
72 | bool annotating() const; | 76 | bool annotating() const; | ||
73 | 77 | | |||
74 | // returns the preferred cursor for the current tool. call this only | 78 | // returns the preferred cursor for the current tool. call this only | ||
75 | // if active() == true | 79 | // if active() == true | ||
76 | QCursor cursor() const; | 80 | QCursor cursor() const; | ||
77 | 81 | | |||
78 | QRect routeMouseEvent( QMouseEvent * event, PageViewItem * item ); | 82 | QRect routeMouseEvent( QMouseEvent * event, PageViewItem * item ); | ||
79 | QRect routeTabletEvent( QTabletEvent * event, PageViewItem * item, const QPoint & localOriginInGlobal ); | 83 | QRect routeTabletEvent( QTabletEvent * event, PageViewItem * item, const QPoint & localOriginInGlobal ); | ||
80 | QRect performRouteMouseOrTabletEvent( const AnnotatorEngine::EventType & eventType, const AnnotatorEngine::Button & button, | 84 | QRect performRouteMouseOrTabletEvent( const AnnotatorEngine::EventType & eventType, const AnnotatorEngine::Button & button, | ||
81 | const QPointF & pos, PageViewItem * item ); | 85 | const QPointF & pos, PageViewItem * item ); | ||
82 | bool routeKeyEvent( QKeyEvent * event ); | 86 | bool routeKeyEvent( QKeyEvent * event ); | ||
83 | bool routePaints( const QRect & wantedRect ) const; | 87 | bool routePaints( const QRect & wantedRect ) const; | ||
84 | void routePaint( QPainter * painter, const QRect & paintRect ); | 88 | void routePaint( QPainter * painter, const QRect & paintRect ); | ||
85 | 89 | | |||
86 | void reparseConfig(); | 90 | void reparseConfig(); | ||
87 | 91 | | |||
88 | static QString defaultToolName( const QDomElement &toolElement ); | 92 | static QString defaultToolName( const QDomElement &toolElement ); | ||
89 | static QPixmap makeToolPixmap( const QDomElement &toolElement ); | 93 | static QPixmap makeToolPixmap( const QDomElement &toolElement ); | ||
90 | 94 | | |||
91 | private Q_SLOTS: | 95 | void saveAnnotationTools(); | ||
92 | void slotToolSelected( int toolID ); | 96 | | ||
93 | void slotSaveToolbarOrientation( int side ); | 97 | void selectTool( int toolID ); | ||
94 | void slotToolDoubleClicked( int toolID ); | 98 | int setFavoriteTool ( int toolID ); | ||
99 | void setAnnotationColor( QColor color ); | ||||
100 | void setAnnotationInnerColor( QColor color ); | ||||
101 | void setAnnotationOpacity( double opacity ); | ||||
102 | void setAnnotationFont( QFont font ); | ||||
103 | void setAnnotationWidth( double width ); | ||||
104 | | ||||
105 | QDomElement builtinTool( int toolID ); | ||||
106 | QDomElement favoriteTool( int toolID ); | ||||
107 | QDomElement currentEngineElement(); | ||||
108 | QDomElement currentAnnotationElement(); | ||||
109 | bool continuousMode(); | ||||
95 | 110 | | |||
96 | private: | | |||
97 | void detachAnnotation(); | 111 | void detachAnnotation(); | ||
98 | 112 | | |||
113 | public Q_SLOTS: | ||||
114 | void setContinuousMode( bool enabled ); | ||||
115 | void bookmarkAnnotation(); | ||||
116 | void slotAdvancedSettings(); | ||||
117 | | ||||
118 | Q_SIGNALS: | ||||
119 | void toolSelected(); | ||||
120 | | ||||
121 | private: | ||||
122 | | ||||
99 | // global class pointers | 123 | // global class pointers | ||
100 | Okular::Document * m_document; | 124 | Okular::Document * m_document; | ||
101 | PageView * m_pageView; | 125 | PageView * m_pageView; | ||
102 | PageViewToolBar * m_toolBar; | 126 | AnnotationActionHandler * m_actionHandler; | ||
103 | AnnotatorEngine * m_engine; | 127 | AnnotatorEngine * m_engine; | ||
104 | QDomElement m_toolsDefinition; | 128 | AnnotationTools * m_toolsDefinition; | ||
129 | AnnotationTools * m_favoriteToolsDefinition; | ||||
105 | QLinkedList<AnnotationToolItem> m_items; | 130 | QLinkedList<AnnotationToolItem> m_items; | ||
106 | bool m_textToolsEnabled; | 131 | bool m_textToolsEnabled; | ||
107 | bool m_toolsEnabled; | 132 | bool m_toolsEnabled; | ||
108 | bool m_continuousMode; | 133 | bool m_continuousMode; | ||
109 | bool m_hidingWasForced; | | |||
110 | 134 | | |||
111 | // creation related variables | 135 | // creation related variables | ||
112 | int m_lastToolID; | 136 | int m_lastToolID; | ||
113 | QRect m_lastDrawnRect; | 137 | QRect m_lastDrawnRect; | ||
114 | PageViewItem * m_lockedItem; | 138 | PageViewItem * m_lockedItem; | ||
115 | //selected annotation name | 139 | //selected annotation name | ||
116 | //QString m_selectedAnnotationName; | 140 | //QString m_selectedAnnotationName; | ||
117 | }; | 141 | }; | ||
118 | 142 | | |||
119 | #endif | 143 | #endif | ||
120 | 144 | | |||
121 | /* kate: replace-tabs on; indent-width 4; */ | 145 | /* kate: replace-tabs on; indent-width 4; */ |