Computer Assisted Medical Intervention Tool Kit  version 5.2
QtAbstractPropertyBrowser Class Referenceabstract

QtAbstractPropertyBrowser provides a base class for implementing property browsers. More...

#include <qtpropertybrowser.h>

+ Inheritance diagram for QtAbstractPropertyBrowser:
+ Collaboration diagram for QtAbstractPropertyBrowser:

Public Slots

QtBrowserItemaddProperty (QtProperty *property)
 
QtBrowserIteminsertProperty (QtProperty *property, QtProperty *afterProperty)
 
void removeProperty (QtProperty *property)
 

Signals

void currentItemChanged (QtBrowserItem *)
 

Public Member Functions

void clear ()
 
QtBrowserItemcurrentItem () const
 
QList< QtBrowserItem * > items (QtProperty *property) const
 
QList< QtProperty * > properties () const
 
 QtAbstractPropertyBrowser (QWidget *parent=nullptr)
 
void setCurrentItem (QtBrowserItem *)
 
template<class PropertyManager >
void setFactoryForManager (PropertyManager *manager, QtAbstractEditorFactory< PropertyManager > *factory)
 
QtBrowserItemtopLevelItem (QtProperty *property) const
 
QList< QtBrowserItem * > topLevelItems () const
 
void unsetFactoryForManager (QtAbstractPropertyManager *manager)
 
 ~QtAbstractPropertyBrowser () override
 

Protected Member Functions

virtual QWidget * createEditor (QtProperty *property, QWidget *parent)
 
virtual void itemChanged (QtBrowserItem *item)=0
 
virtual void itemInserted (QtBrowserItem *item, QtBrowserItem *afterItem)=0
 
virtual void itemRemoved (QtBrowserItem *item)=0
 

Detailed Description

QtAbstractPropertyBrowser provides a base class for implementing property browsers.

A property browser is a widget that enables the user to edit a given set of properties. Each property is represented by a label specifying the property's name, and an editing widget (e.g. a line edit or a combobox) holding its value. A property can have zero or more subproperties.

The top level properties can be retrieved using the properties() function. To traverse each property's subproperties, use the QtProperty::subProperties() function. In addition, the set of top level properties can be manipulated using the addProperty(), insertProperty() and removeProperty() functions. Note that the QtProperty class provides a corresponding set of functions making it possible to manipulate the set of subproperties as well.

To remove all the properties from the property browser widget, use the clear() function. This function will clear the editor, but it will not delete the properties since they can still be used in other editors.

The properties themselves are created and managed by implementations of the QtAbstractPropertyManager class. A manager can handle (i.e. create and manage) properties of a given type. In the property browser the managers are associated with implementations of the QtAbstractEditorFactory: A factory is a class able to create an editing widget of a specified type.

When using a property browser widget, managers must be created for each of the required property types before the properties themselves can be created. To ensure that the properties' values will be displayed using suitable editing widgets, the managers must be associated with objects of the preferred factory implementations using the setFactoryForManager() function. The property browser will use these associations to determine which factory it should use to create the preferred editing widget.

Note that a factory can be associated with many managers, but a manager can only be associated with one single factory within the context of a single property browser. The associations between managers and factories can at any time be removed using the unsetFactoryForManager() function.

Whenever the property data changes or a property is inserted or removed, the itemChanged(), itemInserted() or itemRemoved() functions are called, respectively. These functions must be reimplemented in derived classes in order to update the property browser widget. Be aware that some property instances can appear several times in an abstract tree structure. For example:

QtProperty *property1, *property2, *property3;
property2->addSubProperty(property1);
property3->addSubProperty(property2);
editor->addProperty(property1);
editor->addProperty(property2);
editor->addProperty(property3);
QtAbstractPropertyBrowser provides a base class for implementing property browsers.
Definition: qtpropertybrowser.h:301
QtBrowserItem * addProperty(QtProperty *property)
Definition: qtpropertybrowser.cpp:1771
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:113
void addSubProperty(QtProperty *property)
Definition: qtpropertybrowser.cpp:393

The addProperty() function returns a QtBrowserItem that uniquely identifies the created item.

To make a property editable in the property browser, the createEditor() function must be called to provide the property with a suitable editing widget.

Note that there are two ready-made property browser implementations:

  1. QtGroupBoxPropertyBrowser
  2. QtTreePropertyBrowser
    QtAbstractPropertyManager, QtAbstractEditorFactoryBase

Constructor & Destructor Documentation

◆ QtAbstractPropertyBrowser()

QtAbstractPropertyBrowser::QtAbstractPropertyBrowser ( QWidget *  parent = nullptr)
explicit

Creates an abstract property browser with the given parent.

◆ ~QtAbstractPropertyBrowser()

QtAbstractPropertyBrowser::~QtAbstractPropertyBrowser ( )
override

Destroys the property browser, and destroys all the items that were created by this property browser.

Note that the properties that were displayed in the editor are not deleted since they still can be used in other editors. Neither does the destructor delete the property managers and editor factories that were used by this property browser widget unless this widget was their parent.

See also
QtAbstractPropertyManager::~QtAbstractPropertyManager()

References QtAbstractPropertyBrowserPrivate::clearIndex(), and topLevelItems().

+ Here is the call graph for this function:

Member Function Documentation

◆ addProperty

QtBrowserItem * QtAbstractPropertyBrowser::addProperty ( QtProperty property)
slot

Appends the given property (and its subproperties) to the property browser's list of top level properties. Returns the item created by property browser which is associated with the property. In order to get all children items created by the property browser in this call, the returned item should be traversed.

If the specified property is already added, this function does nothing and returns 0.

See also
insertProperty(), QtProperty::addSubProperty(), properties()

References insertProperty(), and QtAbstractPropertyBrowserPrivate::m_subItems.

Referenced by camitk::ObjectControllerPrivate::addClassProperties(), ObjectControllerPrivate::addClassProperties(), camitk::ObjectControllerPrivate::addDynamicProperties(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void QtAbstractPropertyBrowser::clear ( )

Removes all the properties from the editor, but does not delete them since they can still be used in other editors.

See also
removeProperty(), QtAbstractPropertyManager::clear()

References properties(), and removeProperty().

+ Here is the call graph for this function:

◆ createEditor()

QWidget * QtAbstractPropertyBrowser::createEditor ( QtProperty property,
QWidget *  parent 
)
protectedvirtual

Creates an editing widget (with the given parent) for the given property according to the previously established associations between property managers and editor factories.

If the property is created by a property manager which was not associated with any of the existing factories in this property editor, the function returns 0.

To make a property editable in the property browser, the createEditor() function must be called to provide the property with a suitable editing widget.

Reimplement this function to provide additional decoration for the editing widgets created by the installed factories.

See also
setFactoryForManager()

References QtAbstractEditorFactoryBase::createEditor().

Referenced by QtButtonPropertyBrowserPrivate::createEditor(), QtGroupBoxPropertyBrowserPrivate::createEditor(), and QtTreePropertyBrowserPrivate::createEditor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentItem()

QtBrowserItem * QtAbstractPropertyBrowser::currentItem ( ) const

Returns the current item in the property browser.

See also
setCurrentItem()

References QtAbstractPropertyBrowserPrivate::m_currentItem.

◆ currentItemChanged

void QtAbstractPropertyBrowser::currentItemChanged ( QtBrowserItem current)
signal

This signal is emitted when the current item changes. The current item is specified by current.

See also
QtAbstractPropertyBrowser::setCurrentItem()

Referenced by QtTreePropertyBrowser::QtTreePropertyBrowser(), and setCurrentItem().

+ Here is the caller graph for this function:

◆ insertProperty

QtBrowserItem * QtAbstractPropertyBrowser::insertProperty ( QtProperty property,
QtProperty afterProperty 
)
slot

Inserts the given property (and its subproperties) after the specified afterProperty in the browser's list of top level properties. Returns item created by property browser which is associated with the property. In order to get all children items created by the property browser in this call returned item should be traversed.

If the specified afterProperty is 0, the given property is inserted at the beginning of the list. If property is already inserted, this function does nothing and returns 0.

See also
addProperty(), QtProperty::insertSubProperty(), properties()

References QtAbstractPropertyBrowserPrivate::createBrowserIndexes(), QtAbstractPropertyBrowserPrivate::insertSubTree(), QtAbstractPropertyBrowserPrivate::m_subItems, properties(), and topLevelItem().

Referenced by addProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ itemChanged()

void QtAbstractPropertyBrowser::itemChanged ( QtBrowserItem item)
protectedpure virtual

This function is called whenever a property's data changes, passing a pointer to the item of property as parameter.

This function must be reimplemented in derived classes in order to update the property browser widget whenever a property's name, tool tip, status tip, "what's this" text, value text or value icon changes.

Note that if the property browser contains several occurrences of the same property, this method will be called once for each occurrence (with a different item each time).

See also
QtProperty, items()

Implemented in QtTreePropertyBrowser, QtGroupBoxPropertyBrowser, and QtButtonPropertyBrowser.

Referenced by QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged().

+ Here is the caller graph for this function:

◆ itemInserted()

void QtAbstractPropertyBrowser::itemInserted ( QtBrowserItem insertedItem,
QtBrowserItem precedingItem 
)
protectedpure virtual

This function is called to update the widget whenever a property is inserted or added to the property browser, passing pointers to the insertedItem of property and the specified precedingItem as parameters.

If precedingItem is 0, the insertedItem was put at the beginning of its parent item's list of subproperties. If the parent of insertedItem is 0, the insertedItem was added as a top level property of this property browser.

This function must be reimplemented in derived classes. Note that if the insertedItem's property has subproperties, this method will be called for those properties as soon as the current call is finished.

See also
insertProperty(), addProperty()

Implemented in QtTreePropertyBrowser, QtGroupBoxPropertyBrowser, and QtButtonPropertyBrowser.

Referenced by QtAbstractPropertyBrowserPrivate::createBrowserIndex().

+ Here is the caller graph for this function:

◆ itemRemoved()

void QtAbstractPropertyBrowser::itemRemoved ( QtBrowserItem item)
protectedpure virtual

This function is called to update the widget whenever a property is removed from the property browser, passing the pointer to the item of the property as parameters. The passed item is deleted just after this call is finished.

If the the parent of item is 0, the removed item was a top level property in this editor.

This function must be reimplemented in derived classes. Note that if the removed item's property has subproperties, this method will be called for those properties just before the current call is started.

See also
removeProperty()

Implemented in QtTreePropertyBrowser, QtGroupBoxPropertyBrowser, and QtButtonPropertyBrowser.

Referenced by QtAbstractPropertyBrowserPrivate::removeBrowserIndex().

+ Here is the caller graph for this function:

◆ items()

QList< QtBrowserItem * > QtAbstractPropertyBrowser::items ( QtProperty property) const

Returns the property browser's list of all items associated with the given property.

There is one item per instance of the property in the browser.

See also
topLevelItem()

References QtAbstractPropertyBrowserPrivate::m_propertyToIndexes.

◆ properties()

QList< QtProperty * > QtAbstractPropertyBrowser::properties ( ) const

Returns the property browser's list of top level properties.

To traverse the subproperties, use the QtProperty::subProperties() function.

See also
addProperty(), insertProperty(), removeProperty()

References QtAbstractPropertyBrowserPrivate::m_subItems.

Referenced by clear(), insertProperty(), and removeProperty().

+ Here is the caller graph for this function:

◆ removeProperty

void QtAbstractPropertyBrowser::removeProperty ( QtProperty property)
slot

Removes the specified property (and its subproperties) from the property browser's list of top level properties. All items that were associated with the given property and its children are deleted.

Note that the properties are not deleted since they can still be used in other editors.

See also
clear(), QtProperty::removeSubProperty(), properties()

References QtAbstractPropertyBrowserPrivate::m_subItems, properties(), QtAbstractPropertyBrowserPrivate::removeBrowserIndexes(), and QtAbstractPropertyBrowserPrivate::removeSubTree().

Referenced by clear(), camitk::ObjectController::setObject(), ObjectController::setObject(), and QtAbstractPropertyBrowserPrivate::slotPropertyDestroyed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCurrentItem()

void QtAbstractPropertyBrowser::setCurrentItem ( QtBrowserItem item)

Sets the current item in the property browser to item.

See also
currentItem(), currentItemChanged()

References currentItemChanged(), and QtAbstractPropertyBrowserPrivate::m_currentItem.

Referenced by QtTreePropertyBrowserPrivate::slotCurrentTreeItemChanged().

+ Here is the caller graph for this function:

◆ setFactoryForManager()

template<class PropertyManager >
void QtAbstractPropertyBrowser::setFactoryForManager ( PropertyManager *  manager,
QtAbstractEditorFactory< PropertyManager > *  factory 
)
inline

Connects the given manager to the given factory, ensuring that properties of the manager's type will be displayed with an editing widget suitable for their value.

For example:

QtDoublePropertyManager *doubleManager;
QtProperty *myInteger = intManager->addProperty();
QtProperty *myDouble = doubleManager->addProperty();
QtSpinBoxFactory *spinBoxFactory;
QtDoubleSpinBoxFactory *doubleSpinBoxFactory;
editor->setFactoryForManager(intManager, spinBoxFactory);
editor->setFactoryForManager(doubleManager, doubleSpinBoxFactory);
editor->addProperty(myInteger);
editor->addProperty(myDouble);
void setFactoryForManager(PropertyManager *manager, QtAbstractEditorFactory< PropertyManager > *factory)
Definition: qtpropertybrowser.h:315
QtProperty * addProperty(const QString &name=QString())
Definition: qtpropertybrowser.cpp:748
The QtDoublePropertyManager provides and manages double properties.
Definition: qtpropertymanager.h:164
The QtDoubleSpinBoxFactory class provides QDoubleSpinBox widgets for properties created by QtDoublePr...
Definition: qteditorfactory.h:167
The QtIntPropertyManager provides and manages int properties.
Definition: qtpropertymanager.h:92
The description of this class will come soon !
Definition: qteditorfactory.h:61

In this example the myInteger property's value is displayed with a QSpinBox widget, while the myDouble property's value is displayed with a QDoubleSpinBox widget.

Note that a factory can be associated with many managers, but a manager can only be associated with one single factory. If the given manager already is associated with another factory, the old association is broken before the new one established.

This function ensures that the given manager and the given factory are compatible, and it automatically calls the QtAbstractEditorFactory::addPropertyManager() function if necessary.

See also
unsetFactoryForManager()

References QtAbstractEditorFactory< PropertyManager >::addPropertyManager().

Referenced by main(), MainWindow::MainWindow(), ObjectController::ObjectController(), and camitk::ObjectController::ObjectController().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ topLevelItem()

QtBrowserItem * QtAbstractPropertyBrowser::topLevelItem ( QtProperty property) const

Returns the top-level items associated with the given property.

Returns 0 if property wasn't inserted into this property browser or isn't a top-level one.

See also
topLevelItems(), items()

References QtAbstractPropertyBrowserPrivate::m_topLevelPropertyToIndex.

Referenced by insertProperty().

+ Here is the caller graph for this function:

◆ topLevelItems()

QList< QtBrowserItem * > QtAbstractPropertyBrowser::topLevelItems ( ) const

Returns the list of top-level items.

See also
topLevelItem()

References QtAbstractPropertyBrowserPrivate::m_topLevelIndexes.

Referenced by ~QtAbstractPropertyBrowser().

+ Here is the caller graph for this function:

◆ unsetFactoryForManager()

void QtAbstractPropertyBrowser::unsetFactoryForManager ( QtAbstractPropertyManager manager)

Removes the association between the given manager and the factory bound to it, automatically calling the QtAbstractEditorFactory::removePropertyManager() function if necessary.

See also
setFactoryForManager()

References QtAbstractEditorFactoryBase::breakConnection().

+ Here is the call graph for this function:

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