1 /***************************************************************************
2 * Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
14 #include <QtCore/QVariant>
18 using namespace Okular
;
20 FormFieldPrivate::FormFieldPrivate( FormField::FieldType type
)
21 : m_type( type
), m_activateAction( 0 )
25 FormFieldPrivate::~FormFieldPrivate()
27 delete m_activateAction
;
30 void FormFieldPrivate::setDefault()
36 FormField::FormField( FormFieldPrivate
&dd
)
42 FormField::~FormField()
47 FormField::FieldType
FormField::type() const
49 Q_D( const FormField
);
53 bool FormField::isReadOnly() const
58 bool FormField::isVisible() const
63 Action
* FormField::activationAction() const
65 Q_D( const FormField
);
66 return d
->m_activateAction
;
69 void FormField::setActivationAction( Action
*action
)
72 delete d
->m_activateAction
;
73 d
->m_activateAction
= action
;
77 class Okular::FormFieldButtonPrivate
: public Okular::FormFieldPrivate
80 FormFieldButtonPrivate()
81 : FormFieldPrivate( FormField::FormButton
)
85 Q_DECLARE_PUBLIC( FormFieldButton
)
87 void setValue( const QString
& v
)
89 Q_Q( FormFieldButton
);
90 q
->setState( QVariant( v
).toBool() );
95 Q_Q( const FormFieldButton
);
96 return qVariantFromValue
<bool>( q
->state() ).toString();
101 FormFieldButton::FormFieldButton()
102 : FormField( *new FormFieldButtonPrivate() )
106 FormFieldButton::~FormFieldButton()
110 void FormFieldButton::setState( bool )
115 class Okular::FormFieldTextPrivate
: public Okular::FormFieldPrivate
118 FormFieldTextPrivate()
119 : FormFieldPrivate( FormField::FormText
)
123 Q_DECLARE_PUBLIC( FormFieldText
)
125 void setValue( const QString
& v
)
127 Q_Q( FormFieldText
);
131 QString
value() const
133 Q_Q( const FormFieldText
);
139 FormFieldText::FormFieldText()
140 : FormField( *new FormFieldTextPrivate() )
144 FormFieldText::~FormFieldText()
148 void FormFieldText::setText( const QString
& )
152 bool FormFieldText::isPassword() const
157 bool FormFieldText::isRichText() const
162 int FormFieldText::maximumLength() const
167 Qt::Alignment
FormFieldText::textAlignment() const
169 return Qt::AlignVCenter
| Qt::AlignLeft
;
172 bool FormFieldText::canBeSpellChecked() const
178 class Okular::FormFieldChoicePrivate
: public Okular::FormFieldPrivate
181 FormFieldChoicePrivate()
182 : FormFieldPrivate( FormField::FormChoice
)
186 Q_DECLARE_PUBLIC( FormFieldChoice
)
188 void setValue( const QString
& v
)
190 Q_Q( FormFieldChoice
);
191 QStringList choices
= v
.split( ';', QString::SkipEmptyParts
);
192 QList
<int> newchoices
;
193 foreach ( const QString
& str
, choices
)
196 int val
= str
.toInt( &ok
);
198 newchoices
.append( val
);
200 if ( !newchoices
.isEmpty() )
201 q
->setCurrentChoices( newchoices
);
204 QString
value() const
206 Q_Q( const FormFieldChoice
);
207 QList
<int> choices
= q
->currentChoices();
210 foreach ( int c
, choices
)
212 list
.append( QString::number( c
) );
214 return list
.join( QLatin1String( ";" ) );
219 FormFieldChoice::FormFieldChoice()
220 : FormField( *new FormFieldChoicePrivate() )
224 FormFieldChoice::~FormFieldChoice()
228 bool FormFieldChoice::isEditable() const
233 bool FormFieldChoice::multiSelect() const
238 void FormFieldChoice::setCurrentChoices( const QList
< int >& )
242 Qt::Alignment
FormFieldChoice::textAlignment() const
244 return Qt::AlignVCenter
| Qt::AlignLeft
;
247 bool FormFieldChoice::canBeSpellChecked() const