Add the additional action to form

This commit is contained in:
Albert Astals Cid 2017-03-03 00:41:06 +01:00
parent 56bcdad680
commit cfc158977f
3 changed files with 35 additions and 0 deletions

View file

@ -73,6 +73,19 @@ void FormField::setActivationAction( Action *action )
d->m_activateAction = action;
}
Action* FormField::additionalAction( AdditionalActionType type ) const
{
Q_D( const FormField );
return d->m_additionalActions.value(type);
}
void FormField::setAdditionalAction( AdditionalActionType type, Action *action )
{
Q_D( FormField );
delete d->m_additionalActions.value(type);
d->m_additionalActions[type] = action;
}
class Okular::FormFieldButtonPrivate : public Okular::FormFieldPrivate
{

View file

@ -93,6 +93,26 @@ class OKULARCORE_EXPORT FormField
Action* activationAction() const;
/**
* Describes the type of form additional action.
*
* @since 1.1
*/
enum AdditionalActionType
{
FieldModified, ///< An action to be performed when the user modifies the field
FormatField, ///< An action to be performed before the field is formatted to display its value
ValidateField, ///< An action to be performed when the field value changes
CalculateField, ///< An action to be performed when the field needs to be recalculated
};
/**
* Returns the additional action of the given @p type or @c nullptr if no action has been defined.
*
* @since 1.1
*/
Action* additionalAction( AdditionalActionType type ) const;
protected:
/// @cond PRIVATE
FormField( FormFieldPrivate &dd );
@ -101,6 +121,7 @@ class OKULARCORE_EXPORT FormField
/// @endcond
void setActivationAction( Action *action );
void setAdditionalAction( AdditionalActionType type, Action *action );
private:
Q_DISABLE_COPY( FormField )

View file

@ -33,6 +33,7 @@ class FormFieldPrivate
FormField::FieldType m_type;
QString m_default;
Action *m_activateAction;
QHash<int, Action*> m_additionalActions;
Q_DECLARE_PUBLIC( FormField )
FormField *q_ptr;