File indexing completed on 2024-04-28 04:58:10

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 HTMLEXTENSION_H
0009 #define HTMLEXTENSION_H
0010 
0011 #include <libkonq_export.h>
0012 
0013 #include <QObject>
0014 #include <memory>
0015 
0016 class QUrl;
0017 
0018 namespace KParts
0019 {
0020 class ReadOnlyPart;
0021 }
0022 class HtmlExtensionPrivate;
0023 
0024 /**
0025  * @class HtmlExtension htmlextension.h <KParts/HtmlExtension>
0026  *
0027  * @short An extension for KParts to provide HTML-related features
0028  *
0029  * Use qobject_cast to cast the extension to interesting interfaces, like
0030  * qobject_cast<KParts::SelectorInterface>.
0031  *
0032  * @since 4.6
0033  */
0034 class LIBKONQ_EXPORT HtmlExtension : public QObject
0035 {
0036     Q_OBJECT
0037 public:
0038     explicit HtmlExtension(KParts::ReadOnlyPart *parent);
0039     ~HtmlExtension() override;
0040 
0041     /**
0042      * Queries @p obj for a child object which inherits from this
0043      * HtmlExtension class.
0044      */
0045     static HtmlExtension *childObject(QObject *obj);
0046 
0047     /**
0048      * Returns the current base url of the part that implements this extension.
0049      *
0050      * This function is mostly used to resolve any relative URLs that might be
0051      * returned when querying the part for links.
0052      */
0053     virtual QUrl baseUrl() const = 0;
0054 
0055     /**
0056      * Returns true if portions of the content in the part that implements
0057      * this extension are selected.
0058      *
0059      * By default this function returns false.
0060      */
0061     virtual bool hasSelection() const;
0062 
0063 private:
0064     // for future extensions
0065     std::unique_ptr<HtmlExtensionPrivate> const d;
0066 };
0067 
0068 #endif /* KPARTS_HTMLEXTENSION_H */