File indexing completed on 2024-04-28 15:29:20
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2010 David Faure <faure@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KPARTS_HTMLEXTENSION_H 0009 #define KPARTS_HTMLEXTENSION_H 0010 0011 #include <kparts/kparts_export.h> 0012 0013 #include <QObject> 0014 #include <memory> 0015 0016 class QUrl; 0017 0018 namespace KParts 0019 { 0020 class ReadOnlyPart; 0021 class HtmlExtensionPrivate; 0022 0023 /** 0024 * @class HtmlExtension htmlextension.h <KParts/HtmlExtension> 0025 * 0026 * @short An extension for KParts to provide HTML-related features 0027 * 0028 * Use qobject_cast to cast the extension to interesting interfaces, like 0029 * qobject_cast<KParts::SelectorInterface>. 0030 * 0031 * @since 4.6 0032 */ 0033 class KPARTS_EXPORT HtmlExtension : public QObject 0034 { 0035 Q_OBJECT 0036 public: 0037 explicit HtmlExtension(KParts::ReadOnlyPart *parent); 0038 ~HtmlExtension() override; 0039 0040 /** 0041 * Queries @p obj for a child object which inherits from this 0042 * HtmlExtension class. 0043 */ 0044 static HtmlExtension *childObject(QObject *obj); 0045 0046 /** 0047 * Returns the current base url of the part that implements this extension. 0048 * 0049 * This function is mostly used to resolve any relative URLs that might be 0050 * returned when querying the part for links. 0051 */ 0052 virtual QUrl baseUrl() const = 0; 0053 0054 /** 0055 * Returns true if portions of the content in the part that implements 0056 * this extension are selected. 0057 * 0058 * By default this function returns false. 0059 */ 0060 virtual bool hasSelection() const; 0061 0062 private: 0063 // for future extensions 0064 std::unique_ptr<HtmlExtensionPrivate> const d; 0065 }; 0066 0067 } // namespace KParts 0068 0069 #endif /* KPARTS_HTMLEXTENSION_H */