Commit cfc15897 authored by Albert Astals Cid's avatar Albert Astals Cid

Add the additional action to form

parent 56bcdad6
......@@ -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
{
......
......@@ -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 )
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment