Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdatawidgetmapper.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QDATAWIDGETMAPPER_H
6#define QDATAWIDGETMAPPER_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9
10#include <QtCore/qobject.h>
11
13
14QT_BEGIN_NAMESPACE
15
16class QAbstractItemDelegate;
17class QAbstractItemModel;
18class QModelIndex;
19class QDataWidgetMapperPrivate;
20
21class Q_WIDGETS_EXPORT QDataWidgetMapper: public QObject
22{
23 Q_OBJECT
24
25 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
26 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
27 Q_PROPERTY(SubmitPolicy submitPolicy READ submitPolicy WRITE setSubmitPolicy)
28
29public:
30 explicit QDataWidgetMapper(QObject *parent = nullptr);
31 ~QDataWidgetMapper();
32
33 void setModel(QAbstractItemModel *model);
34 QAbstractItemModel *model() const;
35
36 void setItemDelegate(QAbstractItemDelegate *delegate);
37 QAbstractItemDelegate *itemDelegate() const;
38
39 void setRootIndex(const QModelIndex &index);
40 QModelIndex rootIndex() const;
41
42 void setOrientation(Qt::Orientation aOrientation);
43 Qt::Orientation orientation() const;
44
45 enum SubmitPolicy { AutoSubmit, ManualSubmit };
46 Q_ENUM(SubmitPolicy)
47 void setSubmitPolicy(SubmitPolicy policy);
48 SubmitPolicy submitPolicy() const;
49
50 void addMapping(QWidget *widget, int section);
51 void addMapping(QWidget *widget, int section, const QByteArray &propertyName);
52 void removeMapping(QWidget *widget);
53 int mappedSection(QWidget *widget) const;
54 QByteArray mappedPropertyName(QWidget *widget) const;
55 QWidget *mappedWidgetAt(int section) const;
56 void clearMapping();
57
58 int currentIndex() const;
59
60public Q_SLOTS:
61 void revert();
62 bool submit();
63
64 void toFirst();
65 void toLast();
66 void toNext();
67 void toPrevious();
68 virtual void setCurrentIndex(int index);
69 void setCurrentModelIndex(const QModelIndex &index);
70
71Q_SIGNALS:
72 void currentIndexChanged(int index);
73
74private:
75 Q_DECLARE_PRIVATE(QDataWidgetMapper)
76 Q_DISABLE_COPY(QDataWidgetMapper)
77};
78
79QT_END_NAMESPACE
80
81#endif
The QDataWidgetMapper class provides mapping between a section of a data model to widgets.
\inmodule QtCore
static bool qContainsIndex(const QModelIndex &idx, const QModelIndex &topLeft, const QModelIndex &bottomRight)
Q_DECLARE_TYPEINFO(QDataWidgetMapperPrivate::WidgetMapper, Q_RELOCATABLE_TYPE)
QT_REQUIRE_CONFIG(datawidgetmapper)