This is the base model for managing all the properties and passing them to the view. More...
#include <vpropertymodel.h>
Public Slots | |
void | onDataChangedByModel (VProperty *property) |
This function causes the views to update the property. More... | |
Signals | |
void | onDataChangedByEditor (VProperty *property) |
This signal is being emitted, when the setData method is being called. More... | |
Public Member Functions | |
VPropertyModel (QObject *parent=nullptr) | |
virtual | ~VPropertyModel () Q_DECL_OVERRIDE |
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. More... | |
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. More... | |
virtual VProperty * | getProperty (const QString &id) |
Gets a property by it's ID. More... | |
virtual Qt::ItemFlags | flags (const QModelIndex &index) const Q_DECL_OVERRIDE |
Returns the item flags for the given index. More... | |
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. More... | |
virtual QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE |
Returns the model index at row/column. More... | |
virtual QModelIndex | parent (const QModelIndex &index) const Q_DECL_OVERRIDE |
Returns the parent of one model index. More... | |
virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE |
Returns the data of an model index. More... | |
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. More... | |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE |
Returns the number of rows. More... | |
virtual int | columnCount (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE |
Returns the number of columns. More... | |
virtual VProperty * | getProperty (const QModelIndex &index) const |
Gets a property by its ModelIndex. More... | |
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 manages the properties and not the properties themselves handle the IDs. More... | |
virtual const VPropertySet * | getPropertySet () const |
Returns a const pointer to the property set managed by this model. If you want to manipulate the property set, either use the methods provided by the model or use takePropertySet() and setPropertySet(). More... | |
virtual void | clear (bool emit_signals=true) |
Clears the model, deletes the property set managed by this model. More... | |
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 replaced by the new one. More... | |
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 be deleted. More... | |
virtual VProperty * | takeProperty (const QString &id) |
Removes a property from the model and returns it. More... | |
virtual void | removeProperty (const QString &id) |
Removes a property from the model and deletes it. More... | |
Protected Member Functions | |
virtual QModelIndex | getIndexFromProperty (VProperty *property, int column=0) const |
Gets a property by its ModelIndex. More... | |
VPropertyModel (VPropertyModelPrivate *d, QObject *parent=nullptr) | |
Protected constructor passing the private object. More... | |
Protected Attributes | |
VPropertyModelPrivate * | d_ptr |
The model data. More... | |
This is the base model for managing all the properties and passing them to the view.
When you create your own "proxy models", this is the place to start: just subclass VPropertyModel and extend the new class. Have a look at existing examples of proxies.
Note that in this context, the term "proxy model" does not refer to VProxyModel as that is another concept. The idea behind "proxy models" in the QtPropertyExplorer framework is to provide an convenient interface which takes data as your application (or a third-party-library) provides it, and converts this data to VProperty-objects, manage them and produce output for the views.
In most cases, you will not need to rewrite the basic functions of QAbstractItemModel, as VPropertyModel provides standard implementations to work with. Thus, instead of subclassing VPropertyModel, it is also possible to use VPropertyModel directly (as it is not an abstract class). This might be more convenient in some cases.
Definition at line 62 of file vpropertymodel.h.
|
explicit |
Definition at line 36 of file vpropertymodel.cpp.
|
virtual |
Definition at line 41 of file vpropertymodel.cpp.
|
explicitprotected |
Protected constructor passing the private object.
Definition at line 30 of file vpropertymodel.cpp.
|
virtual |
Adds the property to the model and attaches it to the parentid.
emitsignals | If this is set to false, this function will not call beginInsertRows() and endInsertRows(), so it has to be called from a subclass |
Definition at line 48 of file vpropertymodel.cpp.
References VPE::VProperty::getRowCount().
Referenced by VToolOptionsPropertyBrowser::addProperty().
|
virtual |
Clears the model, deletes the property set managed by this model.
emit_signals | Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals |
Definition at line 311 of file vpropertymodel.cpp.
Referenced by VToolOptionsPropertyBrowser::clearPropertyBrowser(), and VToolOptionsPropertyBrowser::itemClicked().
|
virtual |
Returns the number of columns.
Definition at line 250 of file vpropertymodel.cpp.
|
virtual |
Creates a property and adds it to the model.
Definition at line 79 of file vpropertymodel.cpp.
References VPE::VProperty::setValue().
|
virtual |
Returns the data of an model index.
Definition at line 192 of file vpropertymodel.cpp.
References VPE::VProperty::data().
|
virtual |
Returns the item flags for the given index.
Definition at line 156 of file vpropertymodel.cpp.
References VPE::VProperty::flags().
|
protectedvirtual |
Gets a property by its ModelIndex.
Definition at line 277 of file vpropertymodel.cpp.
References VPE::VProperty::getChildRow(), and VPE::VProperty::getParent().
|
virtual |
Gets a property by its ModelIndex.
index | The modelIndex of the property. |
Definition at line 258 of file vpropertymodel.cpp.
|
virtual |
Gets a property by it's ID.
Definition at line 93 of file vpropertymodel.cpp.
|
virtual |
Returns the ID of the property within the model The concept of property IDs is, that the object that manages the properties and not the properties themselves handle the IDs.
Definition at line 272 of file vpropertymodel.cpp.
|
virtual |
Returns a const pointer to the property set managed by this model. If you want to manipulate the property set, either use the methods provided by the model or use takePropertySet() and setPropertySet().
Definition at line 306 of file vpropertymodel.cpp.
Referenced by VPE::VPropertyFormView::setModel(), and VPE::VPropertyFormView::updatePropertyList().
|
virtual |
Returns the data for the given role and section in the header with the specified orientation.
Definition at line 204 of file vpropertymodel.cpp.
|
virtual |
Returns the model index at row/column.
Definition at line 99 of file vpropertymodel.cpp.
References VPE::VProperty::getChild(), and Properties.
|
signal |
This signal is being emitted, when the setData method is being called.
Referenced by VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser().
|
slot |
This function causes the views to update the property.
Definition at line 296 of file vpropertymodel.cpp.
Referenced by VPE::VPropertyFormView::dataSubmitted().
|
virtual |
Returns the parent of one model index.
Definition at line 128 of file vpropertymodel.cpp.
References VPE::VProperty::getChildRow(), and VPE::VProperty::getParent().
|
virtual |
Removes a property from the model and deletes it.
Definition at line 353 of file vpropertymodel.cpp.
|
virtual |
Returns the number of rows.
Definition at line 228 of file vpropertymodel.cpp.
References VPE::VProperty::getRowCount().
|
virtual |
Sets the role data for the item at index to value.
Definition at line 168 of file vpropertymodel.cpp.
References VPE::VProperty::getUpdateParent(), and VPE::VProperty::setData().
|
virtual |
Sets a new property set. The model will take ownership of the property set. The old property set will be deleted.
property_set | The new property set. Setting this to NULL has the same effect as calling clear. |
emit_signals | Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals |
Definition at line 333 of file vpropertymodel.cpp.
|
virtual |
Removes a property from the model and returns it.
Definition at line 339 of file vpropertymodel.cpp.
|
virtual |
Removes the current property set and returns it. If new_property_set is set, the old one will be replaced by the new one.
new_property_set | The new property set to replace the old one with. Default: NULL |
emit_signals | Default: true. Set this to false if you want to prevent the model from emmiting the reset model signals |
Definition at line 316 of file vpropertymodel.cpp.
|
protected |
The model data.
Definition at line 165 of file vpropertymodel.h.