A template subject filter. More...
#include <SubjectFilterTemplate.h>
Signals | |
void | modificationStateChanged (bool is_modified) const |
Implement this function as a signal when implementing the object. | |
Signals inherited from Qtilities::Core::AbstractSubjectFilter | |
void | monitoredPropertyChanged (const char *property_name, QList< QObject * > objects=QList< QObject * >()) |
A signal which is emitted as soon as a monitored property of the observer or any of the installed subject filters changed. | |
void | propertyChangeFiltered (const char *property_name, QList< QObject * > objects=QList< QObject * >()) |
A signal which is emitted as soon as an property change event is filtered. |
Public Member Functions | |
AbstractSubjectFilter::EvaluationResult | evaluateAttachment (QObject *obj, QString *rejectMsg=0, bool silent=false) const |
Evaluates the attachment of a new subject to the filter's observer context. Use this function to check how an attachment will be handled. | |
AbstractSubjectFilter::EvaluationResult | evaluateDetachment (QObject *obj, QString *rejectMsg=0) const |
Evaluates the detachment of a subject from the filter's observer context. Use this function to check how an detachment will be handled. | |
QString | filterName () const |
Returns the name of the subject filter. | |
void | finalizeAttachment (QObject *obj, bool attachment_successful, bool import_cycle=false) |
Finalize the attachment of a the subject to the filter's observer context. | |
void | finalizeDetachment (QObject *obj, bool detachment_successful, bool subject_deleted=false) |
Finalize the detachment of a subject from the filter's observer context. | |
bool | initializeAttachment (QObject *obj, QString *rejectMsg, bool import_cycle=false) |
Initialize the attachment of a new subject to the filter's observer context. | |
bool | initializeDetachment (QObject *obj, QString *rejectMsg=0, bool subject_deleted=false) |
Initialize the detachment of a subject from the filter's observer context. | |
QStringList | monitoredProperties () const |
This function returns a QStringList with the names of all the properties which are monitored by this subject filter. | |
QStringList | reservedProperties () const |
This function returns a QStringList with the names of all the reserved properties of this subject filter. | |
Public Member Functions inherited from Qtilities::Core::AbstractSubjectFilter | |
virtual bool | isModificationStateMonitored () const |
Get if this subject filter's modification state is monitored by its observer context. | |
Observer * | observerContext () const |
Returns the observer context that this subject filter is attached to. | |
virtual void | setIsModificationStateMonitored (bool is_monitored) |
Set if this subject filter's modification state is monitored by its observer context. | |
virtual bool | setObserverContext (Observer *observer_context) |
Set the observer context for the subject filter. A subject filter is not usable when an observer context to operate in has not been set. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::IExportable | |
quint32 | applicationExportVersion () const |
Returns the application export version currently used by all your application's classes. | |
virtual void | clearExportTask () |
Clears the export task. | |
IExportable * | duplicate (QString *error_msg=0, int properties_to_copy=0, ExportResultFlags *result_flags=0) const |
Function which will create a duplicate (copy) of this object. | |
virtual ExportResultFlags | exportBinary (QDataStream &stream) const |
Allows exporting to a QDataStream. | |
virtual ITask * | exportTask () const |
Gets the task which must be used to log import/export information to. | |
Qtilities::ExportVersion | exportVersion () const |
Returns the export version currently used by all Qtilities classes. | |
virtual ExportResultFlags | exportXml (QDomDocument *doc, QDomElement *object_node) const |
Allows exporting to an XML document. A reference to the QDomElement to which the object's information must be added is provided, along with a reference to the QDomDocument. | |
virtual ExportResultFlags | importBinary (QDataStream &stream, QList< QPointer< QObject > > &import_list) |
Allows importing and reconstruction of the object state from information provided in a QDataStream. | |
virtual ExportResultFlags | importXml (QDomDocument *doc, QDomElement *object_node, QList< QPointer< QObject > > &import_list) |
Allows importing and reconstruction of data from information provided in a XML document. A reference to the QDomElement which contains the object's information is provided, along with a reference to the QDomDocument. | |
bool | isExportable () const |
Gets if this object must be part of it's parents' exports. | |
virtual void | setApplicationExportVersion (quint32 version) |
Sets the application export version currently used by all your application's classes. | |
virtual void | setExportTask (ITask *task) |
Sets the task which must be used to log import/export information to. | |
virtual void | setExportVersion (Qtilities::ExportVersion version) |
Returns the export version currently used by all Qtilities classes. | |
virtual void | setIsExportable (bool new_is_exportable) |
Sets if this object must be part of it's parents' exports. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::IObjectBase | |
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. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::IModificationNotifier | |
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. |
Protected Member Functions | |
bool | handleMonitoredPropertyChange (QObject *obj, const char *property_name, QDynamicPropertyChangeEvent *propertyChangeEvent) |
Function which should react to QDynamicPropertyChangeEvents on properties which are reserved by the subject filter. | |
InstanceFactoryInfo | instanceFactoryInfo () const |
The instance factory information which must be used when the exported object is reconstructed during an import. | |
bool | isModified () const |
Indicates the modification state of the object. | |
QObject * | objectBase () |
Returns the QObject* base of the interface. | |
const QObject * | objectBase () const |
Returns a const QObject* base of the interface. | |
ExportModeFlags | supportedFormats () const |
Provides information about the export format(s) supported by your implementation of IExportable. |
Additional Inherited Members | |
Public Types inherited from Qtilities::Core::AbstractSubjectFilter | |
enum | EvaluationResult { Allowed, Conditional, Rejected } |
Enumeration which defines the possible results of subject filter evaluation operations. More... | |
Public Types inherited from Qtilities::Core::Interfaces::IExportable | |
enum | ExportMode { None = 0, Binary = 1, XML = 2 } |
Possible export modes that an implementation of IExportable can support. More... | |
enum | Result { Complete = 0, Incomplete = 1, Failed = 2, FailedContinue = 4, VersionTooNew = 8, VersionTooOld = 16, VersionSupported = 32, SuccessResult = Complete | Incomplete | VersionSupported, FailedResult = Failed | FailedContinue | VersionTooNew | VersionTooOld } |
The possible results of an export/import operation. More... | |
Public Types inherited from Qtilities::Core::Interfaces::IModificationNotifier | |
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... | |
Protected Attributes inherited from Qtilities::Core::AbstractSubjectFilter | |
bool | filter_is_modification_state_monitored |
Indicates if the modification state of the filter is monitored by it's observer context. | |
Observer * | observer |
The observer context to which the subject filter is attached. |
A template subject filter.
Creating custom subject filters is an easy task if you understand how the initialization and finalization diagrams shown in the Subject filters section of the Observers article work. The SubjectFilterTemplate class should be used as a starting point when creating new subject filters. The new filter class needs to inherit from Qtilities::Core::AbstractSubjectFilter and reimplement the virtual abstract functions in order to work. The source code of the subject filters which comes as part of Qtilities is a good place to start when looking for examples of filter implementations.
|
virtual |
Evaluates the attachment of a new subject to the filter's observer context. Use this function to check how an attachment will be handled.
obj | The object to be evaluated |
rejectMsg | Provides a reject message when the evaluation failed. |
silent | When true, the attachment must be done in a silent way. That is, it should not show any dialogs. This is usefull when objects must be attached to observers without calling exec() on a dialog (such as the user input dialog for NamingPolicyFilters) which can lead to crashes when for example attaching objects inside an event filter. For more information on this topic see Unpredictable exec(). |
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
virtual |
Evaluates the detachment of a subject from the filter's observer context. Use this function to check how an detachment will be handled.
obj | The object to be evaluated |
rejectMsg | Provides a reject message when the evaluation failed. |
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
virtual |
Finalize the attachment of a the subject to the filter's observer context.
attachment_successful
is true, the object will already be attached to the observer context.obj | The object to be added. |
import_cycle | Indicates if the attachment call was made during an observer import cycle. In such cases the subject filter must not add exportable properties to the object since these properties will be added from the import source. Also, it is not neccesarry to validate the context in such cases. |
attachment_successful | True if the attachment was successful, false otherwise. |
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
virtual |
Finalize the detachment of a subject from the filter's observer context.
obj | The object to be detached. |
detachment_successful | True if the detachment was successfull, false otherwise. |
subject_deleted | Indicates if the detachment operation is happening because the subject was deleted. This allows for optimization inside implementations of this function. |
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
protectedvirtual |
Function which should react to QDynamicPropertyChangeEvents on properties which are reserved by the subject filter.
As soon as a subject is attached to an observer the observer installs a event filter on the subject which monitors dynamic property changes. When a dynamic property change event is received, the observer will route the event to the appropriate subject filter and call this function on the subject filter. Thus, this function will only be called when the property_name is a reserved property of the subject filter.
obj | The object on which the property change took place. |
property_name | The property name which changed. |
propertyChangeEvent | The QDynamicPropertyChangeEvent which triggered the event. |
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
virtual |
Initialize the attachment of a new subject to the filter's observer context.
obj | The object to be added. |
import_cycle | Indicates if the attachment call was made during an observer import cycle. In such cases the subject filter must not add exportable properties to the object since these properties will be added from the import source. Also, it is not neccesarry to validate the context in such cases. |
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
virtual |
Initialize the detachment of a subject from the filter's observer context.
obj | The object to be detached. |
rejectMsg | A reject message when the initialization fails. |
subject_deleted | Indicates if the detachment operation is happening because the subject was deleted. This allows for optimization inside implementations of this function. |
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
protectedvirtual |
The instance factory information which must be used when the exported object is reconstructed during an import.
For more information see The IExportable interface, what does it have to do with factories?.
Reimplemented from Qtilities::Core::Interfaces::IExportable.
|
virtualsignal |
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:
Implements Qtilities::Core::Interfaces::IModificationNotifier.
|
virtual |
This function returns a QStringList with the names of all the properties which are monitored by this subject filter.
Monitored properties are all properties that you use on your subject filter that does not appear in the reservedProperties() list. All of these properties will be monitored by the observer context in which the subject filter is installed. The property change events will be delivered to handleMonitoredPropertyChange().
When property changes are valid, the monitoredPropertyChanged() signal is emitted as soon as the property change is completed.
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
inlineprotectedvirtual |
Returns a const QObject* base of the interface.
This function can be used in const methods, but make sure that you don't modify things that should stay const. An example where this is used is when we want to get a property on an object in a const method. This is a const operation.
Implements Qtilities::Core::Interfaces::IObjectBase.
|
virtual |
This function returns a QStringList with the names of all the reserved properties of this subject filter.
Reserved properties are internal properties that cannot be changed. The observer will filter any attempted changes to these properties. To check if a property is reserved, see the Permisson
attribute in the property documentation. All Qtilities properties are defined in the Qtilities::Core::Properties namespace.
Reimplemented from Qtilities::Core::AbstractSubjectFilter.
|
protectedvirtual |
Provides information about the export format(s) supported by your implementation of IExportable.
Reimplemented from Qtilities::Core::Interfaces::IExportable.
Qtilities : Reference Documentation | Back to top |
Copyright © 2009-2013, Jaco Naudé
|