3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
4 Copyright (c) 2005 Kazuki Ohta <mover@hct.zaq.ne.jp>
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
11 1. Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #define DEBUG_KP_VIEW 0
31 #define DEBUG_KP_VIEW_RENDERER ((DEBUG_KP_VIEW && 1) || 0)
35 #include <kpViewPrivate.h>
38 #include <QMouseEvent>
43 // protected virtual [base QWidget]
44 void kpView::mouseMoveEvent (QMouseEvent
*e
)
46 #if DEBUG_KP_VIEW && 0
47 kDebug () << "kpView(" << objectName () << ")::mouseMoveEvent ("
48 << e
->x () << "," << e
->y () << ")"
52 // TODO: This is wrong if you leaveEvent the mainView by mouseMoving on the
53 // mainView, landing on top of the thumbnailView cleverly put on top
55 setHasMouse (rect ().contains (e
->pos ()));
58 tool ()->mouseMoveEvent (e
);
63 // protected virtual [base QWidget]
64 void kpView::mousePressEvent (QMouseEvent
*e
)
66 #if DEBUG_KP_VIEW && 0
67 kDebug () << "kpView(" << objectName () << ")::mousePressEvent ("
68 << e
->x () << "," << e
->y () << ")"
75 tool ()->mousePressEvent (e
);
80 // protected virtual [base QWidget]
81 void kpView::mouseReleaseEvent (QMouseEvent
*e
)
83 #if DEBUG_KP_VIEW && 0
84 kDebug () << "kpView(" << objectName () << ")::mouseReleaseEvent ("
85 << e
->x () << "," << e
->y () << ")"
89 setHasMouse (rect ().contains (e
->pos ()));
92 tool ()->mouseReleaseEvent (e
);
98 // public virtual [base QWidget]
99 void kpView::wheelEvent (QWheelEvent
*e
)
102 tool ()->wheelEvent (e
);
106 // protected virtual [base QWidget]
107 void kpView::keyPressEvent (QKeyEvent
*e
)
109 #if DEBUG_KP_VIEW && 0
110 kDebug () << "kpView(" << objectName () << ")::keyPressEvent()";
114 tool ()->keyPressEvent (e
);
119 // protected virtual [base QWidget]
120 void kpView::keyReleaseEvent (QKeyEvent
*e
)
122 #if DEBUG_KP_VIEW && 0
123 kDebug () << "kpView(" << objectName () << ")::keyReleaseEvent()";
127 tool ()->keyReleaseEvent (e
);
133 // COMPAT: Need to update InputMethod support.
137 void kpView::imStartEvent (QIMEvent
*e
)
139 #if DEBUG_KP_VIEW && 1
140 kDebug () << "kpView(" << objectName () << ")::imStartEvent";
144 tool ()->imStartEvent (e
);
149 void kpView::imComposeEvent (QIMEvent
*e
)
151 #if DEBUG_KP_VIEW && 1
152 kDebug () << "kpView(" << objectName () << ")::imComposeEvent";
156 tool ()->imComposeEvent (e
);
161 void kpView::imEndEvent (QIMEvent
*e
)
163 #if DEBUG_KP_VIEW && 1
164 kDebug () << "kpView(" << objectName () << ")::imEndEvent";
168 tool ()->imEndEvent (e
);
175 // protected virtual [base QWidget]
176 bool kpView::event (QEvent
*e
)
179 kDebug () << "kpView::event() invoking kpTool::event()";
181 if (tool () && tool ()->viewEvent (e
))
184 kDebug () << "\tkpView::event() - tool said eat event, ret true";
190 kDebug () << "\tkpView::event() - no tool or said false, call QWidget::event()";
192 return QWidget::event (e
);
196 // protected virtual [base QWidget]
197 void kpView::focusInEvent (QFocusEvent
*e
)
199 #if DEBUG_KP_VIEW && 0
200 kDebug () << "kpView(" << objectName () << ")::focusInEvent()";
203 tool ()->focusInEvent (e
);
206 // protected virtual [base QWidget]
207 void kpView::focusOutEvent (QFocusEvent
*e
)
209 #if DEBUG_KP_VIEW && 0
210 kDebug () << "kpView(" << objectName () << ")::focusOutEvent()";
213 tool ()->focusOutEvent (e
);
217 // protected virtual [base QWidget]
218 void kpView::enterEvent (QEvent
*e
)
220 #if DEBUG_KP_VIEW && 0
221 kDebug () << "kpView(" << objectName () << ")::enterEvent()";
224 // Don't call setHasMouse(true) as it displays the brush cursor (if
225 // active) when dragging open a menu and then dragging
226 // past the extents of the menu due to Qt sending us an EnterEvent.
227 // We're already covered by MouseMoveEvent anyway.
229 // But disabling this causes a more serious problem: RMB on a text
230 // box and Esc. We have no other reliable way to determine if the
231 // mouse is still above the view (user could have moved mouse out
232 // while RMB menu was up) and hence the cursor is not updated.
236 tool ()->enterEvent (e
);
239 // protected virtual [base QWidget]
240 void kpView::leaveEvent (QEvent
*e
)
242 #if DEBUG_KP_VIEW && 0
243 kDebug () << "kpView(" << objectName () << ")::leaveEvent()";
248 tool ()->leaveEvent (e
);
252 // protected virtual [base QWidget]
253 void kpView::dragEnterEvent (QDragEnterEvent
*)
255 #if DEBUG_KP_VIEW && 1
256 kDebug () << "kpView(" << objectName () << ")::dragEnterEvent()";
262 // protected virtual [base QWidget]
263 void kpView::dragLeaveEvent (QDragLeaveEvent
*)
265 #if DEBUG_KP_VIEW && 1
266 kDebug () << "kpView(" << objectName () << ")::dragLeaveEvent";
273 // protected virtual [base QWidget]
274 void kpView::resizeEvent (QResizeEvent
*e
)
276 #if DEBUG_KP_VIEW && 1
277 kDebug () << "kpView(" << objectName () << ")::resizeEvent("
279 << " vs actual=" << size ()
280 << ") old=" << e
->oldSize () << endl
;
283 QWidget::resizeEvent (e
);
285 emit
sizeChanged (width (), height ());
286 emit
sizeChanged (size ());