File indexing completed on 2025-01-19 04:46:50

0001 /*
0002    SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <MessageViewer/BodyPartURLHandler>
0010 
0011 #include <QObject>
0012 
0013 class ItineraryMemento;
0014 class ItineraryKDEConnectHandler;
0015 
0016 /** URL handler for the itinerary plugin. */
0017 class ItineraryUrlHandler : public QObject, public MessageViewer::Interface::BodyPartURLHandler
0018 {
0019     Q_OBJECT
0020 public:
0021     ~ItineraryUrlHandler() override = default;
0022     void setKDEConnectHandler(ItineraryKDEConnectHandler *kdeConnect);
0023 
0024     QString name() const override;
0025     bool handleClick(MessageViewer::Viewer *viewerInstance, MimeTreeParser::Interface::BodyPart *part, const QString &path) const override;
0026     bool handleContextMenuRequest(MimeTreeParser::Interface::BodyPart *part, const QString &path, const QPoint &p) const override;
0027     QString statusBarMessage(MimeTreeParser::Interface::BodyPart *part, const QString &path) const override;
0028 
0029     [[nodiscard]] static bool hasItineraryApp();
0030 
0031 private:
0032     ItineraryMemento *memento(MimeTreeParser::Interface::BodyPart *part) const;
0033     void showCalendar(QDate date) const;
0034     void addToCalendar(ItineraryMemento *memento) const;
0035     void openInApp(MimeTreeParser::Interface::BodyPart *part) const;
0036     void openWithKDEConnect(MimeTreeParser::Interface::BodyPart *part, const QString &deviceId) const;
0037     [[nodiscard]] QString createItineraryFile(MimeTreeParser::Interface::BodyPart *part) const;
0038 
0039     ItineraryKDEConnectHandler *m_kdeConnect = nullptr;
0040 };