File indexing completed on 2024-04-28 03:59:10

0001 /*
0002     This file is part of the KDE Libraries
0003     SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KPAGEWIDGET_H
0009 #define KPAGEWIDGET_H
0010 
0011 #include <kpagewidgetmodel.h>
0012 
0013 #include "kpageview.h"
0014 
0015 class KPageWidgetPrivate;
0016 /**
0017  * @class KPageWidget kpagewidget.h KPageWidget
0018  *
0019  * @short Page widget with many layouts (faces).
0020  * A KPageView with hierarchical page model.
0021  *
0022  * @author Tobias Koenig (tokoe@kde.org)
0023  */
0024 class KWIDGETSADDONS_EXPORT KPageWidget : public KPageView
0025 {
0026     Q_OBJECT
0027     Q_DECLARE_PRIVATE(KPageWidget)
0028 
0029 public:
0030     /**
0031      * Creates a new page widget.
0032      *
0033      * @param parent The parent widget.
0034      */
0035     explicit KPageWidget(QWidget *parent = nullptr);
0036 
0037     /**
0038      * Destroys the page widget.
0039      */
0040     ~KPageWidget() override;
0041 
0042     /**
0043      * Adds a new top level page to the widget.
0044      *
0045      * @param widget The widget of the page.
0046      * @param name The name which is displayed in the navigation view.
0047      *
0048      * @returns The associated KPageWidgetItem.
0049      */
0050     KPageWidgetItem *addPage(QWidget *widget, const QString &name);
0051 
0052     /**
0053      * Adds a new top level page to the widget.
0054      *
0055      * @param item The KPageWidgetItem which describes the page.
0056      */
0057     void addPage(KPageWidgetItem *item);
0058 
0059     /**
0060      * Inserts a new page in the widget.
0061      *
0062      * @param before The new page will be insert before this KPageWidgetItem
0063      *               on the same level in hierarchy.
0064      * @param widget The widget of the page.
0065      * @param name The name which is displayed in the navigation view.
0066      *
0067      * @returns The associated KPageWidgetItem.
0068      */
0069     KPageWidgetItem *insertPage(KPageWidgetItem *before, QWidget *widget, const QString &name);
0070 
0071     /**
0072      * Inserts a new page in the widget.
0073      *
0074      * @param before The new page will be insert before this KPageWidgetItem
0075      *               on the same level in hierarchy.
0076      *
0077      * @param item The KPageWidgetItem which describes the page.
0078      */
0079     void insertPage(KPageWidgetItem *before, KPageWidgetItem *item);
0080 
0081     /**
0082      * Inserts a new sub page in the widget.
0083      *
0084      * @param parent The new page will be insert as child of this KPageWidgetItem.
0085      * @param widget The widget of the page.
0086      * @param name The name which is displayed in the navigation view.
0087      *
0088      * @returns The associated KPageWidgetItem.
0089      */
0090     KPageWidgetItem *addSubPage(KPageWidgetItem *parent, QWidget *widget, const QString &name);
0091 
0092     /**
0093      * Inserts a new sub page in the widget.
0094      *
0095      * @param parent The new page will be insert as child of this KPageWidgetItem.
0096      *
0097      * @param item The KPageWidgetItem which describes the page.
0098      */
0099     void addSubPage(KPageWidgetItem *parent, KPageWidgetItem *item);
0100 
0101     /**
0102      * Removes the page associated with the given KPageWidgetItem.
0103      */
0104     void removePage(KPageWidgetItem *item);
0105 
0106     /**
0107      * Sets the page which is associated with the given KPageWidgetItem to
0108      * be the current page and emits the currentPageChanged() signal.
0109      */
0110     void setCurrentPage(KPageWidgetItem *item);
0111 
0112     /**
0113      * Returns the KPageWidgetItem for the current page or a null pointer if there is no
0114      * current page.
0115      */
0116     KPageWidgetItem *currentPage() const;
0117 
0118 Q_SIGNALS:
0119     /**
0120      * This signal is emitted whenever the current page has changed.
0121      *
0122      * @param current The new current page or a null pointer if no current page is available.
0123      * @param before The page that was current before the new current page has changed.
0124      */
0125     void currentPageChanged(KPageWidgetItem *current, KPageWidgetItem *before);
0126 
0127     /**
0128      * This signal is emitted whenever a checkable page changes its state. @param checked is true
0129      * when the @p page is checked, or false if the @p page is unchecked.
0130      */
0131     void pageToggled(KPageWidgetItem *page, bool checked);
0132 
0133     /**
0134      * This signal is emitted when a page is removed.
0135      * @param page The page which is removed
0136      * */
0137     void pageRemoved(KPageWidgetItem *page);
0138 
0139 protected:
0140     KWIDGETSADDONS_NO_EXPORT KPageWidget(KPageWidgetPrivate &dd, QWidget *parent);
0141 };
0142 
0143 #endif