| 1 | /* |
| 2 | This file is part of the KDE Libraries |
| 3 | SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef KPAGEWIDGET_H |
| 9 | #define KPAGEWIDGET_H |
| 10 | |
| 11 | #include <kpagewidgetmodel.h> |
| 12 | |
| 13 | #include "kpageview.h" |
| 14 | |
| 15 | class KPageWidgetPrivate; |
| 16 | /*! |
| 17 | * \class KPageWidget |
| 18 | * \inmodule KWidgetsAddons |
| 19 | * |
| 20 | * \brief Page widget with many layouts (faces). |
| 21 | * |
| 22 | * A KPageView with hierarchical page model. |
| 23 | */ |
| 24 | class KWIDGETSADDONS_EXPORT KPageWidget : public KPageView |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | Q_DECLARE_PRIVATE(KPageWidget) |
| 28 | |
| 29 | public: |
| 30 | /*! |
| 31 | * Creates a new page widget. |
| 32 | * |
| 33 | * \a parent The parent widget. |
| 34 | */ |
| 35 | explicit KPageWidget(QWidget *parent = nullptr); |
| 36 | |
| 37 | ~KPageWidget() override; |
| 38 | |
| 39 | /*! |
| 40 | * Adds a new top level page to the widget. |
| 41 | * |
| 42 | * \a widget The widget of the page. |
| 43 | * |
| 44 | * \a name The name which is displayed in the navigation view. |
| 45 | * |
| 46 | * Returns The associated KPageWidgetItem. |
| 47 | */ |
| 48 | KPageWidgetItem *addPage(QWidget *widget, const QString &name); |
| 49 | |
| 50 | /*! |
| 51 | * Adds a new top level page to the widget. |
| 52 | * |
| 53 | * \a item The KPageWidgetItem which describes the page. |
| 54 | */ |
| 55 | void addPage(KPageWidgetItem *item); |
| 56 | |
| 57 | /*! |
| 58 | * Inserts a new page in the widget. |
| 59 | * |
| 60 | * \a before The new page will be insert before this KPageWidgetItem |
| 61 | * on the same level in hierarchy. |
| 62 | * |
| 63 | * \a widget The widget of the page. |
| 64 | * |
| 65 | * \a name The name which is displayed in the navigation view. |
| 66 | * |
| 67 | * Returns the associated KPageWidgetItem. |
| 68 | */ |
| 69 | KPageWidgetItem *insertPage(KPageWidgetItem *before, QWidget *widget, const QString &name); |
| 70 | |
| 71 | /*! |
| 72 | * Inserts a new page in the widget. |
| 73 | * |
| 74 | * \a before The new page will be insert before this KPageWidgetItem |
| 75 | * on the same level in hierarchy. |
| 76 | * |
| 77 | * \a item The KPageWidgetItem which describes the page. |
| 78 | */ |
| 79 | void insertPage(KPageWidgetItem *before, KPageWidgetItem *item); |
| 80 | |
| 81 | /*! |
| 82 | * Inserts a new sub page in the widget. |
| 83 | * |
| 84 | * \a parent The new page will be insert as child of this KPageWidgetItem. |
| 85 | * |
| 86 | * \a widget The widget of the page. |
| 87 | * |
| 88 | * \a name The name which is displayed in the navigation view. |
| 89 | * |
| 90 | * Returns the associated KPageWidgetItem. |
| 91 | */ |
| 92 | KPageWidgetItem *addSubPage(KPageWidgetItem *parent, QWidget *widget, const QString &name); |
| 93 | |
| 94 | /*! |
| 95 | * Inserts a new sub page in the widget. |
| 96 | * |
| 97 | * \a parent The new page will be insert as child of this KPageWidgetItem. |
| 98 | * |
| 99 | * \a item The KPageWidgetItem which describes the page. |
| 100 | */ |
| 101 | void addSubPage(KPageWidgetItem *parent, KPageWidgetItem *item); |
| 102 | |
| 103 | /*! |
| 104 | * Removes the page associated with the given KPageWidgetItem. |
| 105 | */ |
| 106 | void removePage(KPageWidgetItem *item); |
| 107 | |
| 108 | /*! |
| 109 | * Sets the page which is associated with the given KPageWidgetItem to |
| 110 | * be the current page and emits the currentPageChanged() signal. |
| 111 | */ |
| 112 | void setCurrentPage(KPageWidgetItem *item); |
| 113 | |
| 114 | /*! |
| 115 | * Returns the KPageWidgetItem for the current page or a null pointer if there is no |
| 116 | * current page. |
| 117 | */ |
| 118 | KPageWidgetItem *currentPage() const; |
| 119 | |
| 120 | Q_SIGNALS: |
| 121 | /*! |
| 122 | * This signal is emitted whenever the current page has changed. |
| 123 | * |
| 124 | * \a current The new current page or a null pointer if no current page is available. |
| 125 | * |
| 126 | * \a before The page that was current before the new current page has changed. |
| 127 | */ |
| 128 | void currentPageChanged(KPageWidgetItem *current, KPageWidgetItem *before); |
| 129 | |
| 130 | /*! |
| 131 | * This signal is emitted whenever a checkable page changes its state. \a checked is true |
| 132 | * when the \a page is checked, or false if the \a page is unchecked. |
| 133 | */ |
| 134 | void pageToggled(KPageWidgetItem *page, bool checked); |
| 135 | |
| 136 | /*! |
| 137 | * This signal is emitted when a page is removed. |
| 138 | * |
| 139 | * \a page The page which is removed |
| 140 | **/ |
| 141 | void (KPageWidgetItem *page); |
| 142 | |
| 143 | protected: |
| 144 | KWIDGETSADDONS_NO_EXPORT KPageWidget(KPageWidgetPrivate &dd, QWidget *parent); |
| 145 | }; |
| 146 | |
| 147 | #endif |
| 148 | |