ACF $AcfVersion:0$
Public Types | Public Member Functions | Protected Member Functions | List of all members
idoc::CSelectedDocModelBinderComp Class Reference

Conditional model-observer binder depending on actual selection. More...

#include <CSelectedDocModelBinderComp.h>

Inheritance diagram for idoc::CSelectedDocModelBinderComp:
icomp::CComponentBase imod::TSingleModelObserverBase< IDocumentManager > icomp::IComponent imod::CSingleModelObserverBase istd::IPolymorphic imod::IObserver istd::IPolymorphic

Public Types

typedef icomp::CComponentBase BaseClass
 
typedef imod::TSingleModelObserverBase< IDocumentManagerBaseClass2
 

Public Member Functions

 CSelectedDocModelBinderComp ()
 
- Public Member Functions inherited from icomp::CComponentBase
 CComponentBase ()
 Create component and assign it to specific context.
 
virtual const icomp::IComponentGetParentComponent (bool ownerOnly=false) const override
 Get parent of this component.
 
virtual void * GetInterface (const istd::CClassInfo &interfaceType, const QByteArray &subId="") override
 Get access to specified component interface.
 
virtual IComponentContextSharedPtr GetComponentContext () const override
 Get access to component context describing all application-specified component information loaded from components registry.
 
virtual void SetComponentContext (const IComponentContextSharedPtr &contextPtr, const icomp::IComponent *parentPtr, bool isParentOwner) override
 Set component context of this component.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Protected Member Functions

void TryConnectObservers ()
 
void TryDisconnectObservers ()
 
virtual void BeforeUpdate (imod::IModel *modelPtr) override
 Callback invoked before an update of the observer's content occurs.
 
virtual void AfterUpdate (imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
 Callback invoked after an update of the observer's content occurs.
 
virtual void OnComponentCreated () override
 
virtual void OnComponentDestroyed () override
 
- Protected Member Functions inherited from icomp::CComponentBase
bool IsComponentActive () const
 Check if component is active.
 
virtual const icomp::IRealComponentStaticInfoGetComponentStaticInfo () const =0
 Get access to static info of this component.
 
- Protected Member Functions inherited from imod::TSingleModelObserverBase< IDocumentManager >
virtual IDocumentManager * CastFromModel (imod::IModel *modelPtr) const
 
 TSingleModelObserverBase ()
 
IDocumentManager * GetObservedObject () const
 Get instance of observed object.
 
IDocumentManager * GetObjectPtr () const
 Get instance of observed object.
 
bool AttachOrSetObject (IDocumentManager *objectPtr)
 Attach to model of object or set object pointer, if no connection is possible.
 
virtual bool OnModelAttached (imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
 Callback invoked when an observable model is about to be attached to this observer.
 
virtual bool OnModelDetached (imod::IModel *modelPtr) override
 Callback invoked when an observable model is about to be detached from this observer.
 
- Protected Member Functions inherited from imod::CSingleModelObserverBase
void SetModelPtr (imod::IModel *modelPtr)
 Set internal model pointer to specified value.
 
virtual void OnUpdate (const istd::IChangeable::ChangeSet &changeSet)
 Called on update of observed model.
 
 CSingleModelObserverBase ()
 
virtual ~CSingleModelObserverBase ()
 
imod::IModelGetObservedModel () const
 Get access to observed model.
 
imod::IModelGetModelPtr () const
 Get access to observed model.
 
void EnsureModelDetached ()
 Make sure this observer is detached.
 
void SetObservedIds (const istd::IChangeable::ChangeSet &changeMask)
 Set list of ID's beeing observed.
 
virtual bool IsModelAttached (const imod::IModel *modelPtr=NULL) const override
 Checks if the specified model is currently attached to this observer.
 

Additional Inherited Members

- Protected Types inherited from imod::TSingleModelObserverBase< IDocumentManager >
typedef CSingleModelObserverBase BaseClass
 
typedef IDocumentManager ModelType
 
- Protected Types inherited from imod::CSingleModelObserverBase
typedef imod::IModel ModelType
 
- Static Protected Member Functions inherited from icomp::CComponentBase
static const icomp::IRealComponentStaticInfoInitStaticInfo (IComponent *componentPtr)
 
static QByteArray GetComponentId (const icomp::IComponentContext *componentContextPtr, const QByteArray &contextId=QByteArray())
 
- Static Protected Attributes inherited from imod::CSingleModelObserverBase
static const istd::IChangeable::ChangeSet s_undoChanges
 

Detailed Description

Conditional model-observer binder depending on actual selection.

This component allows to work-around of problems with observing of selected document or view. It connects model with observer only if some document (or view) is currently selected. Please note, that there is no assumption that connected model must be the same as observed model.

Definition at line 24 of file CSelectedDocModelBinderComp.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 29 of file CSelectedDocModelBinderComp.h.

◆ BaseClass2

Definition at line 30 of file CSelectedDocModelBinderComp.h.

Constructor & Destructor Documentation

◆ CSelectedDocModelBinderComp()

idoc::CSelectedDocModelBinderComp::CSelectedDocModelBinderComp ( )

Member Function Documentation

◆ AfterUpdate()

virtual void idoc::CSelectedDocModelBinderComp::AfterUpdate ( imod::IModel modelPtr,
const istd::IChangeable::ChangeSet changeSet 
)
overrideprotectedvirtual

Callback invoked after an update of the observer's content occurs.

This is the primary notification method where observers react to model changes. It's called after the model has finished updating its state. The implementation should examine the changeSet to determine what changed and update accordingly.

Parameters
modelPtrPointer to the model that has changed
changeSetContains information about what changed in the model. Use changeSet.Contains(changeId) to check for specific changes. The changeSet respects the mask specified in OnModelAttached().
Note
This is typically where you update your GUI, recalculate derived values, or trigger other dependent operations.
Keep this method fast - it's called frequently and may block the UI thread.
Use the changeSet to perform incremental updates rather than refreshing everything.
virtual void AfterUpdate(IModel* modelPtr,
const istd::IChangeable::ChangeSet& changeSet)
{
CMyModel* model = dynamic_cast<CMyModel*>(modelPtr);
if (!model) return;
// Selective update based on what changed
if (changeSet.Contains(CMyModel::CF_NAME_CHANGED)) {
m_nameLabel->setText(model->GetName());
}
if (changeSet.Contains(CMyModel::CF_VALUE_CHANGED)) {
m_valueSpinBox->setValue(model->GetValue());
RecalculateDependentValues();
}
// Re-enable signals if blocked in BeforeUpdate
if (m_widget) {
m_widget->blockSignals(false);
}
}
virtual void AfterUpdate(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
Callback invoked after an update of the observer's content occurs.
Set of change flags (its IDs).
Definition IChangeable.h:36
bool Contains(int changeId) const
Check if there is specific change flag in the set.
See also
BeforeUpdate(), OnModelAttached()

Reimplemented from imod::CSingleModelObserverBase.

◆ BeforeUpdate()

virtual void idoc::CSelectedDocModelBinderComp::BeforeUpdate ( imod::IModel modelPtr)
overrideprotectedvirtual

Callback invoked before an update of the observer's content occurs.

This method is called at the start of a model update cycle, before any data actually changes. It allows the observer to prepare for the update, such as saving current state for comparison or disabling UI updates temporarily.

Parameters
modelPtrPointer to the model that is about to change
Warning
In some error cases, this method may be called without a subsequent AfterUpdate() call. Don't rely on AfterUpdate() always being called.
Note
This method is optional to implement - if you don't need preparation logic, just provide an empty implementation.
virtual void BeforeUpdate(IModel* modelPtr)
{
// Example: Block signals to prevent multiple GUI updates
if (m_widget) {
m_widget->blockSignals(true);
}
// Example: Save state for delta comparison
m_previousValue = m_currentValue;
}
virtual void BeforeUpdate(imod::IModel *modelPtr) override
Callback invoked before an update of the observer's content occurs.
See also
AfterUpdate()

Reimplemented from imod::CSingleModelObserverBase.

◆ OnComponentCreated()

virtual void idoc::CSelectedDocModelBinderComp::OnComponentCreated ( )
overrideprotectedvirtual

Reimplemented from icomp::CComponentBase.

◆ OnComponentDestroyed()

virtual void idoc::CSelectedDocModelBinderComp::OnComponentDestroyed ( )
overrideprotectedvirtual

Reimplemented from icomp::CComponentBase.

◆ TryConnectObservers()

void idoc::CSelectedDocModelBinderComp::TryConnectObservers ( )
protected

◆ TryDisconnectObservers()

void idoc::CSelectedDocModelBinderComp::TryDisconnectObservers ( )
protected

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