Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ObjectPropertyModel.h
Go to the documentation of this file.
1#pragma once
2#include <QAbstractItemView>
3#include <QAbstractListModel>
4#include <misc/global.h>
5
6namespace sf
7{
8
12class _MISC_CLASS ObjectPropertyModel : public QAbstractListModel
13{
14 Q_OBJECT
15
16 public:
20 explicit ObjectPropertyModel(QObject* parent = nullptr);
21
25 void setTarget(QObject* obj);
26
30 void setDelegates(QAbstractItemView* view);
31
35 void refresh();
36
40 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
41
45 [[nodiscard]] int rowCount(const QModelIndex& parent) const override;
46
50 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
51
55 [[nodiscard]] int columnCount(const QModelIndex& parent) const override;
56
60 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex& index) const override;
61
65 bool setData(const QModelIndex& index, const QVariant& value, int role) override;
66
73 // ReSharper disable once CppFunctionIsNotImplemented
74 Q_SIGNAL void changed(QObject* obj, int propertyIndex, bool dynamic);
82 // ReSharper disable once CppFunctionIsNotImplemented
83 Q_SIGNAL void addLineEditActions(QLineEdit* lineEdit, QObject* obj, int propertyIndex, bool dynamic) const;
84
85 private:
89 QObject* _target{nullptr};
90
91 struct Entry
92 {
93 inline Entry(QObject* obj, int index, bool dynamic)
94 : _obj(obj)
95 , _index(index)
96 , _dynamic(dynamic) {};
97
98 QObject* _obj;
99 int _index;
100 bool _dynamic;
101 };
102
106 QList<Entry> _indices;
107};
108
109}// namespace sf
List model for QObject properties.
Definition ObjectPropertyModel.h:13
void setTarget(QObject *obj)
???
void setDelegates(QAbstractItemView *view)
???
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Overridden from base class to provide column display names.
Q_SIGNAL void changed(QObject *obj, int propertyIndex, bool dynamic)
Signals a change of the object's property.
void refresh()
Called to refresh the attached viewer.
Qt::ItemFlags flags(const QModelIndex &index) const override
Overridden from base class to provide flags on an item by index.
QVariant data(const QModelIndex &index, int role) const override
Overridden from base class to provide the data to present.
Q_SIGNAL void addLineEditActions(QLineEdit *lineEdit, QObject *obj, int propertyIndex, bool dynamic) const
int columnCount(const QModelIndex &parent) const override
Overridden from base class to provide the amount of columns.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Overridden from base class to provide assignment of an item when edited.
int rowCount(const QModelIndex &parent) const override
Overridden from base class to provide the amount of rows.
ObjectPropertyModel(QObject *parent=nullptr)
Constructor.
#define _MISC_CLASS
Definition misc/global.h:40
Definition Application.h:10