File indexing completed on 2024-04-14 03:57:14

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     virtual void finalizeGUI(KXMLGUIClient *client);
0074 
0075 protected:
0076     virtual void virtual_hook(int id, void *data);
0077 
0078 private:
0079     std::unique_ptr<KXMLGUIBuilderPrivate> const d;
0080 };
0081 
0082 #endif