1/*
2 This file is part of the KDE Libraries
3
4 Copyright (C) 2006 Tobias Koenig (tokoe@kde.org)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KPAGEWIDGET_H
23#define KPAGEWIDGET_H
24
25#include <kpagewidgetmodel.h>
26
27#include "kpageview.h"
28
29class KPageWidgetPrivate;
30/**
31 * @short Page widget with many layouts (faces).
32 * @see KPageView with hierarchical page model.
33 *
34 * @author Tobias Koenig (tokoe@kde.org)
35 */
36class KDEUI_EXPORT KPageWidget : public KPageView
37{
38 Q_OBJECT
39 Q_DECLARE_PRIVATE(KPageWidget)
40
41 public:
42 /**
43 * Creates a new page widget.
44 *
45 * @param parent The parent widget.
46 */
47 explicit KPageWidget( QWidget *parent = 0 );
48
49 /**
50 * Destroys the page widget.
51 */
52 ~KPageWidget();
53
54 /**
55 * Adds a new top level page to the widget.
56 *
57 * @param widget The widget of the page.
58 * @param name The name which is displayed in the navigation view.
59 *
60 * @returns The associated @see KPageWidgetItem.
61 */
62 KPageWidgetItem* addPage( QWidget *widget, const QString &name );
63
64 /**
65 * Adds a new top level page to the widget.
66 *
67 * @param item The @see KPageWidgetItem which describes the page.
68 */
69 void addPage( KPageWidgetItem *item );
70
71 /**
72 * Inserts a new page in the widget.
73 *
74 * @param before The new page will be insert before this @see KPageWidgetItem
75 * on the same level in hierarchy.
76 * @param widget The widget of the page.
77 * @param name The name which is displayed in the navigation view.
78 *
79 * @returns The associated @see KPageWidgetItem.
80 */
81 KPageWidgetItem* insertPage( KPageWidgetItem *before, QWidget *widget, const QString &name );
82
83 /**
84 * Inserts a new page in the widget.
85 *
86 * @param before The new page will be insert before this @see KPageWidgetItem
87 * on the same level in hierarchy.
88 *
89 * @param item The @see KPageWidgetItem which describes the page.
90 */
91 void insertPage( KPageWidgetItem *before, KPageWidgetItem *item );
92
93 /**
94 * Inserts a new sub page in the widget.
95 *
96 * @param parent The new page will be insert as child of this @see KPageWidgetItem.
97 * @param widget The widget of the page.
98 * @param name The name which is displayed in the navigation view.
99 *
100 * @returns The associated @see KPageWidgetItem.
101 */
102 KPageWidgetItem* addSubPage( KPageWidgetItem *parent, QWidget *widget, const QString &name );
103
104 /**
105 * Inserts a new sub page in the widget.
106 *
107 * @param parent The new page will be insert as child of this @see KPageWidgetItem.
108 *
109 * @param item The @see KPageWidgetItem which describes the page.
110 */
111 void addSubPage( KPageWidgetItem *parent, KPageWidgetItem *item );
112
113 /**
114 * Removes the page associated with the given @see KPageWidgetItem.
115 */
116 void removePage( KPageWidgetItem *item );
117
118 /**
119 * Sets the page which is associated with the given @see KPageWidgetItem to
120 * be the current page and emits the currentPageChanged() signal.
121 */
122 void setCurrentPage( KPageWidgetItem *item );
123
124 /**
125 * Returns the @see KPageWidgetItem for the current page or 0 if there is no
126 * current page.
127 */
128 KPageWidgetItem* currentPage() const;
129
130 Q_SIGNALS:
131 /**
132 * This signal is emitted whenever the current page has changed.
133 *
134 * @param item The new current page or 0 if no current page is available.
135 */
136 void currentPageChanged( KPageWidgetItem *current, KPageWidgetItem *before );
137
138 /**
139 * This signal is emitted whenever a checkable page changes its state. @param checked is true
140 * when the @param page is checked, or false if the @param page is unchecked.
141 */
142 void pageToggled( KPageWidgetItem *page, bool checked );
143
144 /**
145 * This signal is emitted when a page is removed.
146 * @param page The page which is removed
147 * */
148 void pageRemoved( KPageWidgetItem *page );
149
150 protected:
151 KPageWidget(KPageWidgetPrivate &dd, QWidget *parent);
152
153 private:
154 Q_PRIVATE_SLOT(d_func(), void _k_slotCurrentPageChanged(const QModelIndex &, const QModelIndex &))
155};
156
157#endif
158