mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-05 23:49:20 +00:00
Add the additional action to form
This commit is contained in:
parent
56bcdad680
commit
cfc158977f
|
@ -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
|
||||
{
|
||||
|
|
21
core/form.h
21
core/form.h
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue