MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Showcase::WidgetInstance Class Reference

This is an instance class for components that create widgets. More...

#include <WidgetComponent.hpp>

Inheritance diagram for Showcase::WidgetInstance:
Showcase::UIComponentInstance Showcase::ComponentInstance

Public Member Functions

 WidgetInstance (ComponentPtr comp, MultiWidgets::WidgetPtr instance)
 Create a new WidgetInstance. More...
 
virtual void removeInstance () override
 Allows removing component instance when the component is removed. More...
 
void init ()
 
virtual MultiWidgets::WidgetPtr widgetInstance () override
 After first call of this, user of the component is required to keep track of the widget. More...
 
virtual void propertyReceived (const PropertyKey &key, const PropertyValue &value) override
 Called for each property found for the creator component This function may be called same time from multiple threads. More...
 
virtual void propertyLost (const PropertyKey &key, const PropertyValue &value) override
 Called when a property is unset for the component This function may be called same time from multiple threads. More...
 
virtual void componentAddedToSlot (const QByteArray &slotName, std::shared_ptr< Component > comp) override
 Creates an instance of the component and adds it as a child of this instance's widget Sets up event passing between this instance and the new instance If you override this, call setupEvents to set up event passing.
 
MultiWidgets::WidgetPtr createInstanceWidget (const QByteArray &slotName, std::shared_ptr< Component > comp, bool addToThisWidget=true)
 Same behaviour as componentAddedToSlot, but returns the created widget. More...
 
virtual void componentRemovedFromSlot (const QByteArray &slotName, std::shared_ptr< Component > comp) override
 Removes event passing between this instance and the removed component If you override this, call removeEvents to clear event passing.
 
void setupEvents (WidgetInstance &instance, MultiWidgets::Widget &source)
 Setup event passing for new instance under this instance.
 
void removeEvents (WidgetInstance &instance, MultiWidgets::Widget &source)
 Remove event passing from removed instance under this instance.
 
- Public Member Functions inherited from Showcase::UIComponentInstance
 UIComponentInstance (std::shared_ptr< Component > component)
 Create a new instance from the given component. More...
 
virtual void setContent (const QByteArray &slotName, std::shared_ptr< ContentNode > content)
 Set a new content set for this instance. More...
 
virtual void removeContent (const QByteArray &slotName, std::shared_ptr< ContentNode > content)
 Remove content set from this instance. More...
 
virtual void contentNodeFound (std::shared_ptr< ContentNode > node, std::shared_ptr< ContentNode > parent=nullptr)
 Called when a new content node is found in a content graph. More...
 
virtual void contentNodeLost (std::shared_ptr< ContentNode > node, std::shared_ptr< ContentNode > parent=nullptr)
 Called when a content node is lost. More...
 
virtual void contentNodeLostProperty (std::shared_ptr< ContentNode > contentNode, const Property &prop)
 Called when a content node has lost a property. More...
 
virtual void contentNodeReceivedProperty (std::shared_ptr< ContentNode > contentNode, const Property &prop)
 Called when a content node has found a property. More...
 
- Public Member Functions inherited from Showcase::ComponentInstance
 ComponentInstance (std::shared_ptr< Component > component)
 Create a new instance from the given component. More...
 
virtual ~ComponentInstance ()
 Each subclass needs to do needed clean up in their own destructors (should be enough to call removeInstance) More...
 
virtual MultiWidgets::OperatorPtr operatorInstance (MultiWidgets::Widget &host, bool immediate=false)
 Assigns the operator to the given widget. More...
 
std::shared_ptr< Componentcreator () const
 An instance is always tied to a component and can't exist without the component that created it. More...
 

Static Public Member Functions

static void setupEvents (MultiWidgets::Widget &host, MultiWidgets::Widget &child)
 This can be used to setup events for widgets from stock components.
 

Additional Inherited Members

- Protected Member Functions inherited from Showcase::ComponentInstance
void onDelete ()
 This needs to be set up so that when the actual instance (not this proxy object) is removed this is called (f.ex. More...
 

Detailed Description

This is an instance class for components that create widgets.

Examples:
ContentExampleWidget.cpp.

Constructor & Destructor Documentation

Showcase::WidgetInstance::WidgetInstance ( ComponentPtr  comp,
MultiWidgets::WidgetPtr  instance 
)

Create a new WidgetInstance.

Parameters
compthe WidgetComponent that created this instance
instancethe widget this instance is linked to. Instance must always be linked to a widget, and its lifetime is tied to the widget

Member Function Documentation

MultiWidgets::WidgetPtr Showcase::WidgetInstance::createInstanceWidget ( const QByteArray &  slotName,
std::shared_ptr< Component comp,
bool  addToThisWidget = true 
)

Same behaviour as componentAddedToSlot, but returns the created widget.

void Showcase::WidgetInstance::init ( )

Because of the visibility rules need to do dynamic cast...

void Showcase::WidgetInstance::propertyLost ( const PropertyKey key,
const PropertyValue &  value 
)
overridevirtual

Called when a property is unset for the component This function may be called same time from multiple threads.

Parameters
keyidentifies the target property
valuevalue for the property

Should not be possible unless we are waiting to be destroyed

Reimplemented from Showcase::ComponentInstance.

void Showcase::WidgetInstance::propertyReceived ( const PropertyKey key,
const PropertyValue &  value 
)
overridevirtual

Called for each property found for the creator component This function may be called same time from multiple threads.

Parameters
keyidentifies the target property
valuenew value set for the property

Should not be possible unless we are waiting to be destroyed

Reimplemented from Showcase::ComponentInstance.

void Showcase::WidgetInstance::removeInstance ( )
overridevirtual

Allows removing component instance when the component is removed.

Implementations must not call instanceDestroyed of the associated component

Reimplemented from Showcase::UIComponentInstance.

MultiWidgets::WidgetPtr Showcase::WidgetInstance::widgetInstance ( )
overridevirtual

After first call of this, user of the component is required to keep track of the widget.

componentInstance erases the last strong pointer to widget after this

Reimplemented from Showcase::ComponentInstance.