File indexing completed on 2024-04-28 08:50:24
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2002 Patrick Charbonnier <pch@valleeurpe.net> 0004 Copyright (C) 2010 Matthias Fuchs <mat69@gmx.net> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 */ 0011 0012 #ifndef KGETPLUGIN_H 0013 #define KGETPLUGIN_H 0014 0015 #include <konq_kpart_plugin.h> 0016 #include "asyncselectorinterface.h" 0017 0018 #include <QPointer> 0019 0020 #if QT_VERSION_MAJOR < 6 0021 #include <KParts/SelectorInterface> 0022 #endif 0023 0024 class KToggleAction; 0025 class HtmlExtension; 0026 0027 class KGetPlugin : public KonqParts::Plugin 0028 { 0029 Q_OBJECT 0030 public: 0031 KGetPlugin(QObject *parent, const QVariantList &); 0032 ~KGetPlugin() override; 0033 0034 private Q_SLOTS: 0035 void slotShowDrop(); 0036 void slotShowLinks(); 0037 void slotShowSelectedLinks(); 0038 void slotImportLinks(); 0039 void showPopup(); 0040 0041 private: 0042 void getLinks(bool selectedOnly = false); 0043 void fillLinkListFromHtml(const QUrl &baseUrl, const QList<AsyncSelectorInterface::Element> &elements); 0044 0045 /** 0046 * @brief The kind of html selector interface to use 0047 */ 0048 enum class SelectorInterfaceType { 0049 None, /**< No interface type is supported by the part */ 0050 Sync, /**< Use the synchronous interface */ 0051 Async /**< Use the asynchronous interface */ 0052 }; 0053 0054 /** 0055 * @brief Struct encapsulating the different selector interfaces supported by the plugin 0056 */ 0057 struct SelectorInterface { 0058 /** 0059 * @brief Constructor 0060 * @param ext The HTML Extension 0061 */ 0062 SelectorInterface(HtmlExtension *ext); 0063 /** 0064 * @brief The query methods supported by the HTML part 0065 * @return The query methods supported by the HTML part or KParts::SelectionInterface::None if no selector interface 0066 * is provided by the part 0067 */ 0068 AsyncSelectorInterface::QueryMethods supportedMethods() const; 0069 /** 0070 * @brief Whether the HTML extension provides either the synchronous or the asynchronous interface 0071 * @return `true` if the HTML extension provides at least one of the two interfaces and `false` otherwise 0072 */ 0073 bool hasInterface() const; 0074 0075 /** 0076 * @brief The type of selector interface provided by the HTML extension 0077 */ 0078 SelectorInterfaceType interfaceType = SelectorInterfaceType::None; 0079 /** 0080 * @brief A pointer to the KParts::SelectorInterface or `nullptr` if he HTML extension doesn't provide the 0081 * KParts::SelectorInterface interface 0082 **/ 0083 #if QT_VERSION_MAJOR < 6 0084 KParts::SelectorInterface *syncInterface = nullptr; 0085 #endif 0086 /** 0087 * @brief A pointer to the AsyncSelectorInterface or `nullptr` if he HTML extension doesn't provide the 0088 * AsyncSelectorInterface interface 0089 **/ 0090 AsyncSelectorInterface *asyncInterface = nullptr; 0091 }; 0092 0093 QStringList m_linkList; 0094 KToggleAction *m_dropTargetAction; 0095 }; 0096 0097 #endif