itom 1.3.0
ito::AbstractAddInConfigDialog Class Reference

abstract base class for configuration dialogs of plugins More...

#include <abstractAddInConfigDialog.h>

List of all members.

Public Types

enum  MessageLevel { msgLevelNo = 0, msgLevelErrorOnly = 1, msgLevelWarningOnly = 2, msgLevelWarningAndError = msgLevelErrorOnly | msgLevelWarningOnly }

Public Slots

virtual void parametersChanged (QMap< QString, ito::Param > params)=0
 slot invoked if any parameter of the plugin has been changed.

Public Member Functions

 AbstractAddInConfigDialog (ito::AddInBase *plugin)
 constructor.
virtual ~AbstractAddInConfigDialog ()
 destructor
virtual ito::RetVal applyParameters ()=0
 method to send changed parameters back to the plugin (needs to be overwritten)

Protected Member Functions

virtual ito::RetVal setPluginParameter (QSharedPointer< ito::ParamBase > param, MessageLevel msgLevel=msgLevelWarningAndError)
 invokes AddInBase::setParam of plugin in order to set the given parameter
virtual ito::RetVal setPluginParameters (const QVector< QSharedPointer< ito::ParamBase > > params, MessageLevel msgLevel=msgLevelWarningAndError)
 invokes AddInBase::setParamVector of plugin in order to set multiple given parameters
virtual ito::RetVal observeInvocation (ItomSharedSemaphore *waitCond, MessageLevel msgLevel) const
 observes the status of the given semaphore and returns after the semaphore has been released or a timeout occurred

Protected Attributes

QMap< QString, ito::Paramm_currentParameters

Private Attributes

AbstractAddInConfigDialogPrivated

Detailed Description

abstract base class for configuration dialogs of plugins

Inherit your plugin's configuration dialog from this class in order to benefit from many simplified and unified processes. Since the plugin runs in its own thread while the configuration dialog runs in the main thread, the communication between the plugin and its configuration dialog needs to be done via signal/slot connections or general invocations.

The methods of this class help in this process.

Communication plugin -> configuration dialog:

  • After the construction of the configuration dialog, the plugin automatically invokes the slot parametersChanged with all internal parameters of the plugin.
  • overload parametersChanged in order to set all widgets to the current values of the plugin

Communication configuration dialog -> plugin:

  • Just emit the accept() signal if the ok-button is clicked
  • Emit the reject() signal for the cancel button
  • call the applyParameters() method once an optional apply-button is clicked
  • Overload the applyParameters() method in order to send all changed values to the plugin (using setPluginParameter or setPluginParameters).
  • If the dialog is exit using the ok-button, applyParameters is automatically called as well

For implementing a configuration dialog, overload ito::AddInBase::hasConfigDialog and return 1. Additionally overload ito::AddInBase::showConfigDialog and create an instance of the configuration dialog that is directly passed to the api-function apiShowConfigurationDialog.


Member Enumeration Documentation

MessageLevel enumeration defines whether warnings and/or errors that might occur during some executions should be displayed with a message box.

Enumerator:
msgLevelNo 

no messagebox should information about warnings or errors

msgLevelErrorOnly 

a message box should only inform about errors

msgLevelWarningOnly 

a message box should only inform about warnings

msgLevelWarningAndError 

a message box should inform about warnings and errors


Member Function Documentation

virtual ito::RetVal ito::AbstractAddInConfigDialog::applyParameters ( ) [pure virtual]

method to send changed parameters back to the plugin (needs to be overwritten)

This method is automatically called once the OK-button (accept-role) of the configuration dialog is clicked and should also be called if the apply-button is clicked (only this needs to be done by the plugin).

In this method, check all changed parameters and send them to the plugin using setPluginParameter or setPluginParameters. This method needs to be implemented in every single configuration dialog.

ito::RetVal ito::AbstractAddInConfigDialog::observeInvocation ( ItomSharedSemaphore waitCond,
MessageLevel  msgLevel 
) const [protected, virtual]

observes the status of the given semaphore and returns after the semaphore has been released or a timeout occurred

This helper method is mainly called by setPluginParameter or setPluginParameters in order to wait until the parameters have been set within the plugin. The corresponding return value is obtained and returned or displayed in a message box (if desired).

Directly call this method after having invoked any other slot where an instance of ItomSharedSemaphore has been passed as wait condition. This method returns if the wait condition has been released by the receiver, if the invocation failed or if a timeout occurred. For any possible timeout the AddInBase::isAlive flag is continuously evaluated.

Parameters:
waitCondis the wait condition passed to the invokeMethod command.
msgLeveldefines if any warnings or errors should be displayed within an appropriate message box.
Returns:
RetVal returns retOk or any other warning or error depending on success.
See also:
setPluginParameter, setPluginParameters
virtual void ito::AbstractAddInConfigDialog::parametersChanged ( QMap< QString, ito::Param params) [pure virtual, slot]

slot invoked if any parameter of the plugin has been changed.

private data pointer of this class.

overload this method in order reset the widgets depending on the current states of the parameter. The first invocation can also be used in order to configure the configuration dialog depending on the current set of available parameters. This slot is automatically invoked right after the construction of the configuration dialog

map of parameters (usually equal to m_params member of ito::AddInBase)

ito::RetVal ito::AbstractAddInConfigDialog::setPluginParameter ( QSharedPointer< ito::ParamBase param,
MessageLevel  msgLevel = msgLevelWarningAndError 
) [protected, virtual]

invokes AddInBase::setParam of plugin in order to set the given parameter

Use this method to thread-safely set any desired parameter of the plugin. No direct call of setParam of the plugin is possible since the plugin usually runs in a secondary thread.

If the method was successful, the map m_currentParameters is updated with respect to param.

Parameters:
paramis the parameter to set.
msgLeveldefines if any warnings or errors should be displayed within an appropriate message box.
Returns:
RetVal returns retOk or any other warning or error depending on success.
See also:
observeInvocation
ito::RetVal ito::AbstractAddInConfigDialog::setPluginParameters ( const QVector< QSharedPointer< ito::ParamBase > >  params,
MessageLevel  msgLevel = msgLevelWarningAndError 
) [protected, virtual]

invokes AddInBase::setParamVector of plugin in order to set multiple given parameters

Use this method to thread-safely set any desired parameters of the plugin. No direct call of setParam or setParamVector of the plugin is possible since the plugin usually runs in a secondary thread.

If the method was successful, the map m_currentParameters is updated with respect to params.

Parameters:
paramsis a vector of parameters to set.
msgLeveldefines if any warnings or errors should be displayed within an appropriate message box.
Returns:
RetVal returns retOk or any other warning or error depending on success.
See also:
observeInvocation

Member Data Documentation

use this map to save the current values of all parameters. For instance it is conventient to copy the map given in parametersChanged to this map


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends