File indexing completed on 2025-03-09 04:54:41
0001 /* -*- c++ -*- 0002 urlhandlermanager.h 0003 0004 This file is part of KMail, the KDE mail client. 0005 SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org> 0006 SPDX-FileCopyrightText: 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net 0007 SPDX-FileCopyrightText: 2009 Andras Mantia <andras@kdab.net> 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #pragma once 0013 0014 #include "messageviewer_private_export.h" 0015 0016 #include <QList> 0017 0018 class QUrl; 0019 class QString; 0020 class QPoint; 0021 0022 namespace MimeTreeParser 0023 { 0024 class URLHandler; 0025 } 0026 0027 namespace MessageViewer 0028 { 0029 namespace Interface 0030 { 0031 class BodyPartURLHandler; 0032 } 0033 class ViewerPrivate; 0034 class BodyPartURLHandlerManager; 0035 /** 0036 * @short Singleton to manage the list of URLHandlers 0037 * @author Marc Mutz <mutz@kde.org> 0038 */ 0039 class MESSAGEVIEWER_TESTS_EXPORT URLHandlerManager 0040 { 0041 static URLHandlerManager *self; 0042 0043 URLHandlerManager(); 0044 0045 public: 0046 ~URLHandlerManager(); 0047 0048 static URLHandlerManager *instance(); 0049 0050 void registerHandler(const MimeTreeParser::URLHandler *handler); 0051 void unregisterHandler(const MimeTreeParser::URLHandler *handler); 0052 0053 void registerHandler(const Interface::BodyPartURLHandler *handler, const QString &mimeType); 0054 void unregisterHandler(const Interface::BodyPartURLHandler *handler); 0055 0056 [[nodiscard]] bool handleClick(const QUrl &url, ViewerPrivate *w = nullptr) const; 0057 [[nodiscard]] bool handleShiftClick(const QUrl &url, ViewerPrivate *window = nullptr) const; 0058 [[nodiscard]] bool handleContextMenuRequest(const QUrl &url, const QPoint &p, ViewerPrivate *w = nullptr) const; 0059 [[nodiscard]] bool willHandleDrag(const QUrl &url, ViewerPrivate *window = nullptr) const; 0060 [[nodiscard]] bool handleDrag(const QUrl &url, ViewerPrivate *window = nullptr) const; 0061 [[nodiscard]] QString statusBarMessage(const QUrl &url, ViewerPrivate *w = nullptr) const; 0062 0063 private: 0064 using HandlerList = QList<const MimeTreeParser::URLHandler *>; 0065 HandlerList mHandlers; 0066 BodyPartURLHandlerManager *mBodyPartURLHandlerManager = nullptr; 0067 }; 0068 }