All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions
Qtilities::Core::Interfaces::IModificationNotifier Class Reference

Interface which allows objects to broadcast changes made to them. More...

#include <IModificationNotifier.h>

Inheritance diagram for Qtilities::Core::Interfaces::IModificationNotifier:
Inheritance graph
[legend]

List of all members.

Public Types

enum  NotificationTarget { NotifyNone = 0, NotifyListeners = 1, NotifySubjects = 2 }
 The targets which should be notified when the state of the object implementing this interface changes. More...

Public Member Functions

virtual bool isModified () const =0
 Indicates the modification state of the object.
virtual void modificationStateChanged (bool is_modified) const =0
 Implement this function as a signal when implementing the object.
virtual void setModificationState (bool new_state, NotificationTargets notification_targets=NotifyListeners, bool force_notifications=false)=0
 Sets the modification state of the object. Returns true if it was successfull.
- Public Member Functions inherited from Qtilities::Core::Interfaces::IObjectBase
virtual QObject * objectBase ()=0
 Returns the QObject* base of the interface.
virtual const QObject * objectBase () const =0
 Returns a const QObject* base of the interface.
QString objectOriginID () const
 Allows interfaces to provide some sort of source identification.
void setObjectOriginID (const QString &object_origin_id)
 Allows setting of the object source ID of this interface implementation.

Detailed Description

Interface which allows objects to broadcast changes made to them.

Objects can implement this interface if they want to broadcast information when they are modified.

For example: The project manager will manage project items that implement this interface. When a project item's state changes, it will emit its modificationStateChanged() signal which notifies the user that the project changed. When the user saves the project, the project manager will call the setModificationState() slot on all its project items and all objects in the project tree will have their modification state set to false.

When you want to connect to the modificationStateChange signal on this interface, connect to it on the object returned by objectBase().


Member Enumeration Documentation

The targets which should be notified when the state of the object implementing this interface changes.

Enumerator:
NotifyNone 

No targets will be notified about the modification state change.

NotifyListeners 

Notify all listeners connected to the modification state change signals.

See also:
modificationStateChanged()
NotifySubjects 

Notify all subjects about the new state. The new state will be set on all subjects as well.


Member Function Documentation

virtual void Qtilities::Core::Interfaces::IModificationNotifier::modificationStateChanged ( bool  is_modified) const
pure virtual

Implement this function as a signal when implementing the object.

Because this interface does not use the Q_OBJECT macro, you cannot connect to this signal directly. Instead you need to connect to the signal on the base object implementing this interface as follows:

connect(iface->objectBase(),SIGNAL(modificationStateChanged(bool)),SLOT(yourSlot(bool)));

Implemented in Qtilities::Core::Observer, Qtilities::ProjectManagement::ProjectManager, Qtilities::Core::ObserverHints, Qtilities::Core::ActivityPolicyFilter, Qtilities::CoreGui::NamingPolicyFilter, Qtilities::CoreGui::CodeEditorWidget, Qtilities::Core::SubjectTypeFilter, Qtilities::ProjectManagement::ObserverProjectItemWrapper, Qtilities::CoreGui::TreeItemBase, Qtilities::Core::SubjectFilterTemplate, Qtilities::ProjectManagement::CodeEditorProjectItemWrapper, and Qtilities::ProjectManagement::Project.

virtual void Qtilities::Core::Interfaces::IModificationNotifier::setModificationState ( bool  new_state,
NotificationTargets  notification_targets = NotifyListeners,
bool  force_notifications = false 
)
pure virtual

Sets the modification state of the object. Returns true if it was successfull.

When implementing this interface, the setModificationState() function must be declared as a slot.

Parameters:
notification_targetsIndicates which targets must be notified of the change in modification state. By default all listeners are notified.
force_notificationsForces the object to deliver modification state changes even if the new_state is the same as its current state.
See also:
NotificationTarget


Qtilities : Reference Documentation Back to top Copyright © 2009-2013, Jaco Naudé