File indexing completed on 2025-01-18 10:09:32
0001
0002
0003
0004 #ifndef QDATAWIDGETMAPPER_H
0005 #define QDATAWIDGETMAPPER_H
0006
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include "QtCore/qobject.h"
0009
0010 QT_REQUIRE_CONFIG(datawidgetmapper);
0011
0012 QT_BEGIN_NAMESPACE
0013
0014 class QAbstractItemDelegate;
0015 class QAbstractItemModel;
0016 class QModelIndex;
0017 class QDataWidgetMapperPrivate;
0018
0019 class Q_WIDGETS_EXPORT QDataWidgetMapper: public QObject
0020 {
0021 Q_OBJECT
0022
0023 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
0024 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
0025 Q_PROPERTY(SubmitPolicy submitPolicy READ submitPolicy WRITE setSubmitPolicy)
0026
0027 public:
0028 explicit QDataWidgetMapper(QObject *parent = nullptr);
0029 ~QDataWidgetMapper();
0030
0031 void setModel(QAbstractItemModel *model);
0032 QAbstractItemModel *model() const;
0033
0034 void setItemDelegate(QAbstractItemDelegate *delegate);
0035 QAbstractItemDelegate *itemDelegate() const;
0036
0037 void setRootIndex(const QModelIndex &index);
0038 QModelIndex rootIndex() const;
0039
0040 void setOrientation(Qt::Orientation aOrientation);
0041 Qt::Orientation orientation() const;
0042
0043 enum SubmitPolicy { AutoSubmit, ManualSubmit };
0044 Q_ENUM(SubmitPolicy)
0045 void setSubmitPolicy(SubmitPolicy policy);
0046 SubmitPolicy submitPolicy() const;
0047
0048 void addMapping(QWidget *widget, int section);
0049 void addMapping(QWidget *widget, int section, const QByteArray &propertyName);
0050 void removeMapping(QWidget *widget);
0051 int mappedSection(QWidget *widget) const;
0052 QByteArray mappedPropertyName(QWidget *widget) const;
0053 QWidget *mappedWidgetAt(int section) const;
0054 void clearMapping();
0055
0056 int currentIndex() const;
0057
0058 public Q_SLOTS:
0059 void revert();
0060 bool submit();
0061
0062 void toFirst();
0063 void toLast();
0064 void toNext();
0065 void toPrevious();
0066 virtual void setCurrentIndex(int index);
0067 void setCurrentModelIndex(const QModelIndex &index);
0068
0069 Q_SIGNALS:
0070 void currentIndexChanged(int index);
0071
0072 private:
0073 Q_DECLARE_PRIVATE(QDataWidgetMapper)
0074 Q_DISABLE_COPY(QDataWidgetMapper)
0075 };
0076
0077 QT_END_NAMESPACE
0078
0079 #endif