KWidgetsAddons

kpagemodel.h
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 KPAGEMODEL_H
9#define KPAGEMODEL_H
10
11#include <kwidgetsaddons_export.h>
12
13#include <QAbstractItemModel>
14#include <memory>
15
16class KPageModelPrivate;
17
18/**
19 * @class KPageModel kpagemodel.h KPageModel
20 *
21 * @short A base class for a model used by KPageView.
22 *
23 * This class is an abstract base class which must be used to
24 * implement custom models for KPageView. Additional to the standard
25 * Qt::ItemDataRoles it provides the two roles
26 *
27 * @li HeaderRole
28 * @li HeaderVisibleRole
29 * @li WidgetRole
30 *
31 * which are used to return a header string for a page and a QWidget
32 * pointer to the page itself.
33 *
34 * <b>Example:</b>\n
35 *
36 * \code
37 * KPageView *view = new KPageView( this );
38 * KPageModel *model = new MyPageModel( this );
39 *
40 * view->setModel( model );
41 * \endcode
42 *
43 * @see KPageView
44 * @author Tobias Koenig <tokoe@kde.org>
45 */
46class KWIDGETSADDONS_EXPORT KPageModel : public QAbstractItemModel
47{
48 Q_OBJECT
49 Q_DECLARE_PRIVATE(KPageModel)
50
51public:
52 /**
53 * Additional roles that KPageView uses.
54 */
55 enum Role {
56 /**
57 * A string to be rendered as page header.
58 */
59 HeaderRole = Qt::UserRole + 1,
60 /**
61 * A pointer to the page widget. This is the widget that is shown when the item is
62 * selected.
63 *
64 * You can make QVariant take a QWidget using
65 * \code
66 * QWidget *myWidget = new QWidget;
67 * QVariant v = QVariant::fromValue(myWidget);
68 * \endcode
69 */
71 /**
72 * when true, show the page header, if false don't
73 * @since 5.52
74 */
76 /**
77 * The list of actions associated to the page
78 * @since 6.6
79 */
81 };
82
83 /**
84 * Constructs a page model with the given parent.
85 */
86 explicit KPageModel(QObject *parent = nullptr);
87
88 /**
89 * Destroys the page model.
90 */
91 ~KPageModel() override;
92
93protected:
94 KWIDGETSADDONS_NO_EXPORT KPageModel(KPageModelPrivate &dd, QObject *parent);
95
96 std::unique_ptr<class KPageModelPrivate> const d_ptr;
97};
98
99#endif
A base class for a model used by KPageView.
Definition kpagemodel.h:47
~KPageModel() override
Destroys the page model.
Role
Additional roles that KPageView uses.
Definition kpagemodel.h:55
@ ActionsRole
The list of actions associated to the page.
Definition kpagemodel.h:80
@ WidgetRole
A pointer to the page widget.
Definition kpagemodel.h:70
@ HeaderVisibleRole
when true, show the page header, if false don't
Definition kpagemodel.h:75
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:19:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.