Seamly2D
Code documentation
VPE::VPropertyModel Class Reference

This is the base model for managing all the properties and passing them to the view. More...

#include <vpropertymodel.h>

Inheritance diagram for VPE::VPropertyModel:
Collaboration diagram for VPE::VPropertyModel:

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 VPropertycreateProperty (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 VPropertygetProperty (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 VPropertygetProperty (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 VPropertySetgetPropertySet () 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 VPropertySettakePropertySet (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 VPropertytakeProperty (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

VPropertyModelPrivated_ptr
 The model data. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ VPropertyModel() [1/2]

VPE::VPropertyModel::VPropertyModel ( QObject *  parent = nullptr)
explicit

Definition at line 36 of file vpropertymodel.cpp.

◆ ~VPropertyModel()

VPE::VPropertyModel::~VPropertyModel ( )
virtual

Definition at line 41 of file vpropertymodel.cpp.

◆ VPropertyModel() [2/2]

VPE::VPropertyModel::VPropertyModel ( VPropertyModelPrivate d,
QObject *  parent = nullptr 
)
explicitprotected

Protected constructor passing the private object.

Definition at line 30 of file vpropertymodel.cpp.

Member Function Documentation

◆ addProperty()

bool VPE::VPropertyModel::addProperty ( VProperty property,
const QString &  id,
const QString &  parentid = QString(),
bool  emitsignals = true 
)
virtual

Adds the property to the model and attaches it to the parentid.

Parameters
emitsignalsIf 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().

◆ clear()

void VPE::VPropertyModel::clear ( bool  emit_signals = true)
virtual

Clears the model, deletes the property set managed by this model.

Parameters
emit_signalsDefault: 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().

◆ columnCount()

int VPE::VPropertyModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Returns the number of columns.

Definition at line 250 of file vpropertymodel.cpp.

◆ createProperty()

VPE::VProperty * VPE::VPropertyModel::createProperty ( const QString &  id,
const QString &  name,
const QString &  parentid = QString(),
const QVariant &  data = QVariant() 
)
virtual

Creates a property and adds it to the model.

Definition at line 79 of file vpropertymodel.cpp.

References VPE::VProperty::setValue().

◆ data()

QVariant VPE::VPropertyModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual

Returns the data of an model index.

Definition at line 192 of file vpropertymodel.cpp.

References VPE::VProperty::data().

◆ flags()

Qt::ItemFlags VPE::VPropertyModel::flags ( const QModelIndex &  index) const
virtual

Returns the item flags for the given index.

Definition at line 156 of file vpropertymodel.cpp.

References VPE::VProperty::flags().

◆ getIndexFromProperty()

QModelIndex VPE::VPropertyModel::getIndexFromProperty ( VProperty property,
int  column = 0 
) const
protectedvirtual

Gets a property by its ModelIndex.

Definition at line 277 of file vpropertymodel.cpp.

References VPE::VProperty::getChildRow(), and VPE::VProperty::getParent().

◆ getProperty() [1/2]

VPE::VProperty * VPE::VPropertyModel::getProperty ( const QModelIndex &  index) const
virtual

Gets a property by its ModelIndex.

Parameters
indexThe modelIndex of the property.
Returns
Returns the property with the given index, or NULL if none such property exists

Definition at line 258 of file vpropertymodel.cpp.

◆ getProperty() [2/2]

VPE::VProperty * VPE::VPropertyModel::getProperty ( const QString &  id)
virtual

Gets a property by it's ID.

Definition at line 93 of file vpropertymodel.cpp.

◆ getPropertyID()

QString VPE::VPropertyModel::getPropertyID ( const VProperty prop) const
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.

Returns
Returns the ID under which the property is stored within the model

Definition at line 272 of file vpropertymodel.cpp.

◆ getPropertySet()

const VPE::VPropertySet * VPE::VPropertyModel::getPropertySet ( ) const
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().

Returns
A constant pointer to the property set or NULL if there currently is none.

Definition at line 306 of file vpropertymodel.cpp.

Referenced by VPE::VPropertyFormView::setModel(), and VPE::VPropertyFormView::updatePropertyList().

◆ headerData()

QVariant VPE::VPropertyModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
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.

◆ index()

QModelIndex VPE::VPropertyModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
virtual

Returns the model index at row/column.

Definition at line 99 of file vpropertymodel.cpp.

References VPE::VProperty::getChild(), and Properties.

◆ onDataChangedByEditor

void VPE::VPropertyModel::onDataChangedByEditor ( VProperty property)
signal

This signal is being emitted, when the setData method is being called.

Referenced by VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser().

◆ onDataChangedByModel

void VPE::VPropertyModel::onDataChangedByModel ( VProperty property)
slot

This function causes the views to update the property.

Definition at line 296 of file vpropertymodel.cpp.

Referenced by VPE::VPropertyFormView::dataSubmitted().

◆ parent()

QModelIndex VPE::VPropertyModel::parent ( const QModelIndex &  index) const
virtual

Returns the parent of one model index.

Definition at line 128 of file vpropertymodel.cpp.

References VPE::VProperty::getChildRow(), and VPE::VProperty::getParent().

◆ removeProperty()

void VPE::VPropertyModel::removeProperty ( const QString &  id)
virtual

Removes a property from the model and deletes it.

Definition at line 353 of file vpropertymodel.cpp.

◆ rowCount()

int VPE::VPropertyModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Returns the number of rows.

Definition at line 228 of file vpropertymodel.cpp.

References VPE::VProperty::getRowCount().

◆ setData()

bool VPE::VPropertyModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
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().

◆ setPropertySet()

void VPE::VPropertyModel::setPropertySet ( VPropertySet property_set,
bool  emit_signals = true 
)
virtual

Sets a new property set. The model will take ownership of the property set. The old property set will be deleted.

Parameters
property_setThe new property set. Setting this to NULL has the same effect as calling clear.
emit_signalsDefault: 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.

◆ takeProperty()

VPE::VProperty * VPE::VPropertyModel::takeProperty ( const QString &  id)
virtual

Removes a property from the model and returns it.

Definition at line 339 of file vpropertymodel.cpp.

◆ takePropertySet()

VPE::VPropertySet * VPE::VPropertyModel::takePropertySet ( VPropertySet new_property_set = nullptr,
bool  emit_signals = true 
)
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.

Parameters
new_property_setThe new property set to replace the old one with. Default: NULL
emit_signalsDefault: true. Set this to false if you want to prevent the model from emmiting the reset model signals
Returns
A constant pointer to the property set or NULL if there currently is none.

Definition at line 316 of file vpropertymodel.cpp.

Member Data Documentation

◆ d_ptr

VPropertyModelPrivate* VPE::VPropertyModel::d_ptr
protected

The model data.

Definition at line 165 of file vpropertymodel.h.


The documentation for this class was generated from the following files: