Changeset View
Changeset View
Standalone View
Standalone View
views/kpView_Events.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 44 | { | |||
---|---|---|---|---|---|
45 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::mouseMoveEvent (" | 45 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::mouseMoveEvent (" | ||
46 | << e->x () << "," << e->y () << ")"; | 46 | << e->x () << "," << e->y () << ")"; | ||
47 | 47 | | |||
48 | // TODO: This is wrong if you leaveEvent the mainView by mouseMoving on the | 48 | // TODO: This is wrong if you leaveEvent the mainView by mouseMoving on the | ||
49 | // mainView, landing on top of the thumbnailView cleverly put on top | 49 | // mainView, landing on top of the thumbnailView cleverly put on top | ||
50 | // of the mainView. | 50 | // of the mainView. | ||
51 | setHasMouse (rect ().contains (e->pos ())); | 51 | setHasMouse (rect ().contains (e->pos ())); | ||
52 | 52 | | |||
53 | if (tool ()) | 53 | if (tool ()) { | ||
54 | tool ()->mouseMoveEvent (e); | 54 | tool ()->mouseMoveEvent (e); | ||
55 | } | ||||
55 | 56 | | |||
56 | e->accept (); | 57 | e->accept (); | ||
57 | } | 58 | } | ||
58 | 59 | | |||
59 | // protected virtual [base QWidget] | 60 | // protected virtual [base QWidget] | ||
60 | void kpView::mousePressEvent (QMouseEvent *e) | 61 | void kpView::mousePressEvent (QMouseEvent *e) | ||
61 | { | 62 | { | ||
62 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::mousePressEvent (" | 63 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::mousePressEvent (" | ||
63 | << e->x () << "," << e->y () << ")"; | 64 | << e->x () << "," << e->y () << ")"; | ||
64 | 65 | | |||
65 | setHasMouse (true); | 66 | setHasMouse (true); | ||
66 | 67 | | |||
67 | if (tool ()) | 68 | if (tool ()) { | ||
68 | tool ()->mousePressEvent (e); | 69 | tool ()->mousePressEvent (e); | ||
70 | } | ||||
69 | 71 | | |||
70 | e->accept (); | 72 | e->accept (); | ||
71 | } | 73 | } | ||
72 | 74 | | |||
73 | //--------------------------------------------------------------------- | 75 | //--------------------------------------------------------------------- | ||
74 | 76 | | |||
75 | // protected virtual [base QWidget] | 77 | // protected virtual [base QWidget] | ||
76 | void kpView::mouseReleaseEvent (QMouseEvent *e) | 78 | void kpView::mouseReleaseEvent (QMouseEvent *e) | ||
77 | { | 79 | { | ||
78 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::mouseReleaseEvent (" | 80 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::mouseReleaseEvent (" | ||
79 | << e->x () << "," << e->y () << ")"; | 81 | << e->x () << "," << e->y () << ")"; | ||
80 | 82 | | |||
81 | setHasMouse (rect ().contains (e->pos ())); | 83 | setHasMouse (rect ().contains (e->pos ())); | ||
82 | 84 | | |||
83 | if (tool ()) | 85 | if (tool ()) { | ||
84 | tool ()->mouseReleaseEvent (e); | 86 | tool ()->mouseReleaseEvent (e); | ||
87 | } | ||||
85 | 88 | | |||
86 | e->accept (); | 89 | e->accept (); | ||
87 | } | 90 | } | ||
88 | 91 | | |||
89 | //--------------------------------------------------------------------- | 92 | //--------------------------------------------------------------------- | ||
90 | 93 | | |||
91 | // public virtual [base QWidget] | 94 | // public virtual [base QWidget] | ||
92 | void kpView::wheelEvent (QWheelEvent *e) | 95 | void kpView::wheelEvent (QWheelEvent *e) | ||
93 | { | 96 | { | ||
94 | if (tool ()) | 97 | if (tool ()) { | ||
95 | tool ()->wheelEvent (e); | 98 | tool ()->wheelEvent (e); | ||
96 | } | 99 | } | ||
100 | } | ||||
97 | 101 | | |||
98 | //--------------------------------------------------------------------- | 102 | //--------------------------------------------------------------------- | ||
99 | 103 | | |||
100 | // protected virtual [base QWidget] | 104 | // protected virtual [base QWidget] | ||
101 | void kpView::keyPressEvent (QKeyEvent *e) | 105 | void kpView::keyPressEvent (QKeyEvent *e) | ||
102 | { | 106 | { | ||
103 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::keyPressEvent()" << e->text(); | 107 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::keyPressEvent()" << e->text(); | ||
104 | 108 | | |||
105 | if (tool ()) | 109 | if (tool ()) { | ||
106 | tool ()->keyPressEvent (e); | 110 | tool ()->keyPressEvent (e); | ||
111 | } | ||||
107 | 112 | | |||
108 | e->accept (); | 113 | e->accept (); | ||
109 | } | 114 | } | ||
110 | 115 | | |||
111 | //--------------------------------------------------------------------- | 116 | //--------------------------------------------------------------------- | ||
112 | 117 | | |||
113 | // protected virtual [base QWidget] | 118 | // protected virtual [base QWidget] | ||
114 | void kpView::keyReleaseEvent (QKeyEvent *e) | 119 | void kpView::keyReleaseEvent (QKeyEvent *e) | ||
115 | { | 120 | { | ||
116 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::keyReleaseEvent()"; | 121 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::keyReleaseEvent()"; | ||
117 | 122 | | |||
118 | if (tool ()) | 123 | if (tool ()) { | ||
119 | tool ()->keyReleaseEvent (e); | 124 | tool ()->keyReleaseEvent (e); | ||
125 | } | ||||
120 | 126 | | |||
121 | e->accept (); | 127 | e->accept (); | ||
122 | } | 128 | } | ||
123 | 129 | | |||
124 | //--------------------------------------------------------------------- | 130 | //--------------------------------------------------------------------- | ||
125 | 131 | | |||
126 | // protected virtual [base QWidget] | 132 | // protected virtual [base QWidget] | ||
127 | void kpView::inputMethodEvent (QInputMethodEvent *e) | 133 | void kpView::inputMethodEvent (QInputMethodEvent *e) | ||
128 | { | 134 | { | ||
129 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::inputMethodEvent()"; | 135 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::inputMethodEvent()"; | ||
130 | 136 | | |||
131 | if (tool ()) | 137 | if (tool ()) { | ||
132 | tool ()->inputMethodEvent (e); | 138 | tool ()->inputMethodEvent (e); | ||
139 | } | ||||
133 | e->accept (); | 140 | e->accept (); | ||
134 | } | 141 | } | ||
135 | 142 | | |||
136 | // protected virtual [base QWidget] | 143 | // protected virtual [base QWidget] | ||
137 | bool kpView::event (QEvent *e) | 144 | bool kpView::event (QEvent *e) | ||
138 | { | 145 | { | ||
139 | qCDebug(kpLogViews) << "kpView::event() invoking kpTool::event()"; | 146 | qCDebug(kpLogViews) << "kpView::event() invoking kpTool::event()"; | ||
140 | if (tool () && tool ()->viewEvent (e)) | 147 | if (tool () && tool ()->viewEvent (e)) | ||
141 | { | 148 | { | ||
142 | qCDebug(kpLogViews) << "\tkpView::event() - tool said eat event, ret true"; | 149 | qCDebug(kpLogViews) << "\tkpView::event() - tool said eat event, ret true"; | ||
143 | return true; | 150 | return true; | ||
144 | } | 151 | } | ||
145 | 152 | | |||
146 | qCDebug(kpLogViews) << "\tkpView::event() - no tool or said false, call QWidget::event()"; | 153 | qCDebug(kpLogViews) << "\tkpView::event() - no tool or said false, call QWidget::event()"; | ||
147 | return QWidget::event (e); | 154 | return QWidget::event (e); | ||
148 | } | 155 | } | ||
149 | 156 | | |||
150 | 157 | | |||
151 | // protected virtual [base QWidget] | 158 | // protected virtual [base QWidget] | ||
152 | void kpView::focusInEvent (QFocusEvent *e) | 159 | void kpView::focusInEvent (QFocusEvent *e) | ||
153 | { | 160 | { | ||
154 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::focusInEvent()"; | 161 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::focusInEvent()"; | ||
155 | if (tool ()) | 162 | if (tool ()) { | ||
156 | tool ()->focusInEvent (e); | 163 | tool ()->focusInEvent (e); | ||
157 | } | 164 | } | ||
165 | } | ||||
158 | 166 | | |||
159 | // protected virtual [base QWidget] | 167 | // protected virtual [base QWidget] | ||
160 | void kpView::focusOutEvent (QFocusEvent *e) | 168 | void kpView::focusOutEvent (QFocusEvent *e) | ||
161 | { | 169 | { | ||
162 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::focusOutEvent()"; | 170 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::focusOutEvent()"; | ||
163 | if (tool ()) | 171 | if (tool ()) { | ||
164 | tool ()->focusOutEvent (e); | 172 | tool ()->focusOutEvent (e); | ||
165 | } | 173 | } | ||
174 | } | ||||
166 | 175 | | |||
167 | 176 | | |||
168 | // protected virtual [base QWidget] | 177 | // protected virtual [base QWidget] | ||
169 | void kpView::enterEvent (QEvent *e) | 178 | void kpView::enterEvent (QEvent *e) | ||
170 | { | 179 | { | ||
171 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::enterEvent()"; | 180 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::enterEvent()"; | ||
172 | 181 | | |||
173 | // Don't call setHasMouse(true) as it displays the brush cursor (if | 182 | // Don't call setHasMouse(true) as it displays the brush cursor (if | ||
174 | // active) when dragging open a menu and then dragging | 183 | // active) when dragging open a menu and then dragging | ||
175 | // past the extents of the menu due to Qt sending us an EnterEvent. | 184 | // past the extents of the menu due to Qt sending us an EnterEvent. | ||
176 | // We're already covered by MouseMoveEvent anyway. | 185 | // We're already covered by MouseMoveEvent anyway. | ||
177 | // | 186 | // | ||
178 | // But disabling this causes a more serious problem: RMB on a text | 187 | // But disabling this causes a more serious problem: RMB on a text | ||
179 | // box and Esc. We have no other reliable way to determine if the | 188 | // box and Esc. We have no other reliable way to determine if the | ||
180 | // mouse is still above the view (user could have moved mouse out | 189 | // mouse is still above the view (user could have moved mouse out | ||
181 | // while RMB menu was up) and hence the cursor is not updated. | 190 | // while RMB menu was up) and hence the cursor is not updated. | ||
182 | setHasMouse (true); | 191 | setHasMouse (true); | ||
183 | 192 | | |||
184 | if (tool ()) | 193 | if (tool ()) { | ||
185 | tool ()->enterEvent (e); | 194 | tool ()->enterEvent (e); | ||
186 | } | 195 | } | ||
196 | } | ||||
187 | 197 | | |||
188 | // protected virtual [base QWidget] | 198 | // protected virtual [base QWidget] | ||
189 | void kpView::leaveEvent (QEvent *e) | 199 | void kpView::leaveEvent (QEvent *e) | ||
190 | { | 200 | { | ||
191 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::leaveEvent()"; | 201 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::leaveEvent()"; | ||
192 | 202 | | |||
193 | setHasMouse (false); | 203 | setHasMouse (false); | ||
194 | if (tool ()) | 204 | if (tool ()) { | ||
195 | tool ()->leaveEvent (e); | 205 | tool ()->leaveEvent (e); | ||
196 | } | 206 | } | ||
207 | } | ||||
197 | 208 | | |||
198 | 209 | | |||
199 | // protected virtual [base QWidget] | 210 | // protected virtual [base QWidget] | ||
200 | void kpView::dragEnterEvent (QDragEnterEvent *) | 211 | void kpView::dragEnterEvent (QDragEnterEvent *) | ||
201 | { | 212 | { | ||
202 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::dragEnterEvent()"; | 213 | qCDebug(kpLogViews) << "kpView(" << objectName () << ")::dragEnterEvent()"; | ||
203 | 214 | | |||
204 | setHasMouse (true); | 215 | setHasMouse (true); | ||
Show All 24 Lines |