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 <QMouseEvent>
32
KWebView(QWidget * parent,bool createCustomPage)33 KWebView::KWebView(QWidget *parent, bool createCustomPage)
34 : QWebView(parent), d(new KWebViewPrivate<KWebView>(this))
35 {
36 if (createCustomPage) {
37 setPage(new KWebPage(this));
38 }
39 }
40
~KWebView()41 KWebView::~KWebView()
42 {
43 delete d;
44 }
45
isExternalContentAllowed() const46 bool KWebView::isExternalContentAllowed() const
47 {
48 return d->isExternalContentAllowed();
49 }
50
setAllowExternalContent(bool allow)51 void KWebView::setAllowExternalContent(bool allow)
52 {
53 d->setAllowExternalContent(allow);
54 }
55
wheelEvent(QWheelEvent * event)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
mousePressEvent(QMouseEvent * event)65 void KWebView::mousePressEvent(QMouseEvent *event)
66 {
67 d->pressedButtons = event->buttons();
68 d->keyboardModifiers = event->modifiers();
69 QWebView::mousePressEvent(event);
70 }
71
mouseReleaseEvent(QMouseEvent * event)72 void KWebView::mouseReleaseEvent(QMouseEvent *event)
73 {
74 if (d->mouseReleased(event->pos()) || d->handleUrlPasteFromClipboard(event)) {
75 event->accept();
76 return;
77 }
78
79 QWebView::mouseReleaseEvent(event);
80 }
81
82