1 | /* |
2 | * This file is part of the KDE project. |
3 | * |
4 | * Copyright (C) 2007 Trolltech ASA |
5 | * Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org> |
6 | * Copyright (C) 2008 Laurent Montel <montel@kde.org> |
7 | * Copyright (C) 2008 Michael Howell <mhowell123@gmail.com> |
8 | * Copyright (C) 2009 Dawit Alemayehu <adawit @ kde.org> |
9 | * |
10 | * This library is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU Library General Public |
12 | * License as published by the Free Software Foundation; either |
13 | * version 2 of the License, or (at your option) any later version. |
14 | * |
15 | * This library is distributed in the hope that it will be useful, |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | * Library General Public License for more details. |
19 | * |
20 | * You should have received a copy of the GNU Library General Public License |
21 | * along with this library; see the file COPYING.LIB. If not, write to |
22 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 | * Boston, MA 02110-1301, USA. |
24 | * |
25 | */ |
26 | |
27 | #include "kwebview.h" |
28 | #include "kwebview_p.h" |
29 | #include "kwebpage.h" |
30 | |
31 | #include <QtGui/QMouseEvent> |
32 | |
33 | |
34 | KWebView::KWebView(QWidget *parent, bool createCustomPage) |
35 | :QWebView(parent), d(new KWebViewPrivate<KWebView>(this)) |
36 | { |
37 | if (createCustomPage) |
38 | setPage(new KWebPage(this)); |
39 | } |
40 | |
41 | KWebView::~KWebView() |
42 | { |
43 | delete d; |
44 | } |
45 | |
46 | bool KWebView::isExternalContentAllowed() const |
47 | { |
48 | return d->isExternalContentAllowed(); |
49 | } |
50 | |
51 | void KWebView::setAllowExternalContent(bool allow) |
52 | { |
53 | d->setAllowExternalContent(allow); |
54 | } |
55 | |
56 | void KWebView::wheelEvent(QWheelEvent *event) |
57 | { |
58 | if (d->wheelEvent(event->delta())) { |
59 | event->accept(); |
60 | } else { |
61 | QWebView::wheelEvent(event); |
62 | } |
63 | } |
64 | |
65 | |
66 | void KWebView::mousePressEvent(QMouseEvent *event) |
67 | { |
68 | d->pressedButtons = event->buttons(); |
69 | d->keyboardModifiers = event->modifiers(); |
70 | QWebView::mousePressEvent(event); |
71 | } |
72 | |
73 | void KWebView::mouseReleaseEvent(QMouseEvent *event) |
74 | { |
75 | if (d->mouseReleased(event->pos()) || d->handleUrlPasteFromClipboard(event)) { |
76 | event->accept(); |
77 | return; |
78 | } |
79 | |
80 | QWebView::mouseReleaseEvent(event); |
81 | } |
82 | |
83 | #include "kwebview.moc" |
84 | |