Messagelib

urlhandler.h
1/* -*- c++ -*-
2 interfaces/urlhandler.h
3
4 This file is part of KMail, the KDE mail client.
5 SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include <QUrl>
13
14class QString;
15class QPoint;
16
17namespace MessasgeViewer
18{
19class ViewerPrivate;
20}
21
22namespace MimeTreeParser
23{
24/**
25 * @short An interface to reader link handlers
26 * @author Marc Mutz <mutz@kde.org>
27 *
28 */
30{
31public:
32 virtual ~URLHandler() = default;
33
34 /**
35 * Called when LMB-clicking on a link in the reader. Should start
36 * processing equivalent to "opening" the link.
37 *
38 * @return true if the click was handled by this URLHandler,
39 * false otherwise.
40 */
41 virtual bool handleClick(const QUrl &url, MessageViewer::ViewerPrivate *w) const = 0;
42
43 /**
44 * Called when RMB-clicking on a link in the reader. Should show
45 * a context menu at the specified point with the specified
46 * widget as parent.
47 *
48 * @return true if the right-click was handled by this
49 * URLHandler, false otherwise.
50 */
51 virtual bool handleContextMenuRequest(const QUrl &url, const QPoint &p, MessageViewer::ViewerPrivate *w) const = 0;
52
53 /**
54 * Called when hovering over a link.
55 *
56 * @return a string to be shown in the status bar while hovering
57 * over this link.
58 */
59 [[nodiscard]] virtual QString statusBarMessage(const QUrl &url, MessageViewer::ViewerPrivate *w) const = 0;
60
61 /**
62 * Called when shift-clicking the link in the reader.
63 * @return true if the click was handled by this URLHandler, false otherwise
64 */
65 [[nodiscard]] virtual bool handleShiftClick(const QUrl &url, MessageViewer::ViewerPrivate *window) const
66 {
67 Q_UNUSED(url)
68 Q_UNUSED(window)
69 return false;
70 }
71
72 /**
73 * @return should return true if this URLHandler will handle the drag
74 */
75 [[nodiscard]] virtual bool willHandleDrag(const QUrl &url, MessageViewer::ViewerPrivate *window) const
76 {
77 Q_UNUSED(url)
78 Q_UNUSED(window)
79 return false;
80 }
81
82 /**
83 * Called when starting a drag with the given URL.
84 * If the drag is handled, you should create a drag object.
85 * @return true if the click was handled by this URLHandler, false otherwise
86 */
87 [[nodiscard]] virtual bool handleDrag(const QUrl &url, MessageViewer::ViewerPrivate *window) const
88 {
89 Q_UNUSED(url)
90 Q_UNUSED(window)
91 return false;
92 }
93};
94}
An interface to reader link handlers.
Definition urlhandler.h:30
virtual bool willHandleDrag(const QUrl &url, MessageViewer::ViewerPrivate *window) const
Definition urlhandler.h:75
virtual bool handleDrag(const QUrl &url, MessageViewer::ViewerPrivate *window) const
Called when starting a drag with the given URL.
Definition urlhandler.h:87
virtual bool handleClick(const QUrl &url, MessageViewer::ViewerPrivate *w) const =0
Called when LMB-clicking on a link in the reader.
virtual QString statusBarMessage(const QUrl &url, MessageViewer::ViewerPrivate *w) const =0
Called when hovering over a link.
virtual bool handleContextMenuRequest(const QUrl &url, const QPoint &p, MessageViewer::ViewerPrivate *w) const =0
Called when RMB-clicking on a link in the reader.
virtual bool handleShiftClick(const QUrl &url, MessageViewer::ViewerPrivate *window) const
Called when shift-clicking the link in the reader.
Definition urlhandler.h:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.