File indexing completed on 2025-03-09 04:54:33
0001 /* -*- c++ -*- 0002 interfaces/bodyparturlhandler.h 0003 0004 This file is part of KMail's plugin interface. 0005 SPDX-FileCopyrightText: 2003, 2004 Marc Mutz <mutz@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 class QString; 0013 class QPoint; 0014 0015 namespace MimeTreeParser 0016 { 0017 namespace Interface 0018 { 0019 class BodyPart; 0020 } 0021 } 0022 0023 namespace MessageViewer 0024 { 0025 class Viewer; 0026 } 0027 0028 namespace MessageViewer 0029 { 0030 namespace Interface 0031 { 0032 /** 0033 * @short An interface to body part reader link handlers 0034 * @author Marc Mutz <mutz@kde.org> 0035 * 0036 * This interface is a condensed of variant of the more general 0037 * @see URLHandler interface, designed to make bodypart-dependent 0038 * link operations possible without exposing KMail-internal 0039 * classes. 0040 * 0041 * Implementation-wise, these handlers are called as a nested 0042 * Chain Of Responsibility by an internal implementation of 0043 * URLHandler. 0044 * 0045 * You can create a link whose handling is passed to this handler 0046 * by using BodyPart::makeLink( const QString & path ). \a path is 0047 * what * is passed back to the methods of this interface. 0048 * 0049 * Note that the BodyPart interface does not provide a means of 0050 * learning the content type of the body part passed. This is 0051 * intentional. It is expected that either separate 0052 * BodyPartURLHandlers are created for these purposes or else the 0053 * information encoded into the path parameter by the 0054 * BodyPartFormatter. 0055 */ 0056 class BodyPartURLHandler 0057 { 0058 public: 0059 virtual ~BodyPartURLHandler() = default; 0060 0061 virtual QString name() const = 0; 0062 /** Called when LMB-clicking on a link in the reader. Should 0063 start processing equivalent to "opening" the link. 0064 0065 @return true if the click was handled by this handler, false 0066 otherwise. 0067 */ 0068 virtual bool handleClick(MessageViewer::Viewer *viewerInstance, MimeTreeParser::Interface::BodyPart *part, const QString &path) const = 0; 0069 0070 /** Called when RMB-clicking on a link in the reader. Should 0071 show a context menu at the specified point with the 0072 specified widget as parent. 0073 0074 @return true if the right-click was handled by this handler, 0075 false otherwise. 0076 */ 0077 virtual bool handleContextMenuRequest(MimeTreeParser::Interface::BodyPart *part, const QString &path, const QPoint &p) const = 0; 0078 0079 /** Called when hovering over a link. 0080 0081 @return a string to be shown in the status bar while 0082 hovering over this link or QString() if the link was not 0083 handled by this handler. 0084 */ 0085 virtual QString statusBarMessage(MimeTreeParser::Interface::BodyPart *part, const QString &path) const = 0; 0086 }; 0087 } // namespace Interface 0088 }