21 #ifndef VPROPERTYMODEL_H
22 #define VPROPERTYMODEL_H
24 #include <qcompilerdetection.h>
25 #include <QAbstractItemModel>
27 #include <QMetaObject>
28 #include <QModelIndex>
40 class VPropertyModelPrivate;
72 virtual bool addProperty(
VProperty* property,
const QString&
id,
const QString& parentid = QString(),
73 bool emitsignals =
true);
77 const QVariant&
data = QVariant());
83 virtual Qt::ItemFlags
flags (
const QModelIndex&
index)
const Q_DECL_OVERRIDE;
86 virtual bool setData (
const QModelIndex&
index,
const QVariant& value,
int role = Qt::EditRole) Q_DECL_OVERRIDE;
89 virtual QModelIndex
index (
int row,
int column,
const QModelIndex &
parent = QModelIndex() )
const Q_DECL_OVERRIDE;
92 virtual QModelIndex
parent (
const QModelIndex&
index)
const Q_DECL_OVERRIDE;
95 virtual QVariant
data (
const QModelIndex&
index,
int role = Qt::DisplayRole)
const Q_DECL_OVERRIDE;
98 virtual QVariant
headerData (
int section, Qt::Orientation orientation,
99 int role = Qt::DisplayRole)
const Q_DECL_OVERRIDE;
102 virtual int rowCount (
const QModelIndex &
parent = QModelIndex() )
const Q_DECL_OVERRIDE;
105 virtual int columnCount (
const QModelIndex &
parent = QModelIndex() )
const Q_DECL_OVERRIDE;
126 virtual void clear(
bool emit_signals =
true);
This is the base model for managing all the properties and passing them to the view.
virtual QModelIndex getIndexFromProperty(VProperty *property, int column=0) const
Gets a property by its ModelIndex.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
Returns the number of columns.
VPropertyModelPrivate * d_ptr
The model data.
virtual Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE
Returns the item flags for the given index.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Returns the data of an model index.
void onDataChangedByModel(VProperty *property)
This function causes the views to update the property.
virtual ~VPropertyModel() Q_DECL_OVERRIDE
VPropertyModel(QObject *parent=nullptr)
virtual VProperty * createProperty(const QString &id, const QString &name, const QString &parentid=QString(), const QVariant &data=QVariant())
Creates a property and adds it to the model.
virtual QString getPropertyID(const VProperty *prop) const
Returns the ID of the property within the model The concept of property IDs is, that the object that ...
virtual void removeProperty(const QString &id)
Removes a property from the model and deletes it.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Returns the data for the given role and section in the header with the specified orientation.
virtual VPropertySet * takePropertySet(VPropertySet *new_property_set=nullptr, bool emit_signals=true)
Removes the current property set and returns it. If new_property_set is set, the old one will be repl...
virtual void setPropertySet(VPropertySet *property_set, bool emit_signals=true)
Sets a new property set. The model will take ownership of the property set. The old property set will...
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
Returns the number of rows.
virtual bool addProperty(VProperty *property, const QString &id, const QString &parentid=QString(), bool emitsignals=true)
Adds the property to the model and attaches it to the parentid.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
Returns the model index at row/column.
virtual VProperty * takeProperty(const QString &id)
Removes a property from the model and returns it.
virtual VProperty * getProperty(const QString &id)
Gets a property by it's ID.
virtual void clear(bool emit_signals=true)
Clears the model, deletes the property set managed by this model.
void onDataChangedByEditor(VProperty *property)
This signal is being emitted, when the setData method is being called.
virtual QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE
Returns the parent of one model index.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) Q_DECL_OVERRIDE
Sets the role data for the item at index to value.
virtual const VPropertySet * getPropertySet() const
Returns a const pointer to the property set managed by this model. If you want to manipulate the prop...
VPropertySet is a simple class for managing a set of properties. If you don't need all the Model-func...