File indexing completed on 2024-07-14 14:38:43

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2000 Simon Hausmann <hausmann@kde.org>
0004     SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef kxmlguibuilder_h
0010 #define kxmlguibuilder_h
0011 
0012 #include <kxmlgui_export.h>
0013 #include <memory>
0014 
0015 #include <QStringList>
0016 
0017 class KXMLGUIBuilderPrivate;
0018 class KXMLGUIClient;
0019 
0020 class QAction;
0021 class QDomElement;
0022 class QWidget;
0023 
0024 /**
0025  * @class KXMLGUIBuilder kxmlguibuilder.h KXMLGUIBuilder
0026  *
0027  * Implements the creation of the GUI (menubar, menus and toolbars)
0028  * as requested by the GUI factory.
0029  *
0030  * The virtual methods are mostly for historical reasons, there isn't really
0031  * a need to derive from KXMLGUIBuilder anymore.
0032  */
0033 class KXMLGUI_EXPORT KXMLGUIBuilder
0034 {
0035 public:
0036     explicit KXMLGUIBuilder(QWidget *widget);
0037     virtual ~KXMLGUIBuilder();
0038 
0039     /* @internal */
0040     KXMLGUIClient *builderClient() const;
0041     /* @internal */
0042     void setBuilderClient(KXMLGUIClient *client);
0043     /* @internal */
0044     QWidget *widget();
0045 
0046     virtual QStringList containerTags() const;
0047 
0048     /**
0049      * Creates a container (menubar/menu/toolbar/statusbar/separator/...)
0050      * from an element in the XML file
0051      *
0052      * @param parent The parent for the container
0053      * @param index The index where the container should be inserted
0054      *              into the parent container/widget
0055      * @param element The element from the DOM tree describing the
0056      *                container (use it to access container specified
0057      *                attributes or child elements)
0058      * @param action The action created for this container; used for e.g. passing to removeContainer.
0059      */
0060     virtual QWidget *createContainer(QWidget *parent, int index, const QDomElement &element, QAction *&containerAction);
0061 
0062     /**
0063      * Removes the given (and previously via createContainer )
0064      * created container.
0065      *
0066      */
0067     virtual void removeContainer(QWidget *container, QWidget *parent, QDomElement &element, QAction *containerAction);
0068 
0069     virtual QStringList customTags() const;
0070 
0071     virtual QAction *createCustomElement(QWidget *parent, int index, const QDomElement &element);
0072 
0073 #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0)
0074     // KF6 TODO: REMOVE
0075     /// @internal
0076     /// @deprecated Since 5.0, do not use
0077     KXMLGUI_DEPRECATED_VERSION(5, 0, "Do not use")
0078     virtual void removeCustomElement(QWidget *parent, QAction *action);
0079 #endif
0080 
0081     virtual void finalizeGUI(KXMLGUIClient *client);
0082 
0083 protected:
0084     virtual void virtual_hook(int id, void *data);
0085 
0086 private:
0087     std::unique_ptr<KXMLGUIBuilderPrivate> const d;
0088 };
0089 
0090 #endif