• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
  • core
form.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
3  * *
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  ***************************************************************************/
9 
10 #include "form.h"
11 #include "form_p.h"
12 
13 // qt includes
14 #include <QtCore/QVariant>
15 
16 #include "action.h"
17 
18 using namespace Okular;
19 
20 FormFieldPrivate::FormFieldPrivate( FormField::FieldType type )
21  : m_type( type ), m_activateAction( 0 )
22 {
23 }
24 
25 FormFieldPrivate::~FormFieldPrivate()
26 {
27  delete m_activateAction;
28 }
29 
30 void FormFieldPrivate::setDefault()
31 {
32  m_default = value();
33 }
34 
35 
36 FormField::FormField( FormFieldPrivate &dd )
37  : d_ptr( &dd )
38 {
39  d_ptr->q_ptr = this;
40 }
41 
42 FormField::~FormField()
43 {
44  delete d_ptr;
45 }
46 
47 FormField::FieldType FormField::type() const
48 {
49  Q_D( const FormField );
50  return d->m_type;
51 }
52 
53 bool FormField::isReadOnly() const
54 {
55  return false;
56 }
57 
58 bool FormField::isVisible() const
59 {
60  return true;
61 }
62 
63 Action* FormField::activationAction() const
64 {
65  Q_D( const FormField );
66  return d->m_activateAction;
67 }
68 
69 void FormField::setActivationAction( Action *action )
70 {
71  Q_D( FormField );
72  delete d->m_activateAction;
73  d->m_activateAction = action;
74 }
75 
76 
77 class Okular::FormFieldButtonPrivate : public Okular::FormFieldPrivate
78 {
79  public:
80  FormFieldButtonPrivate()
81  : FormFieldPrivate( FormField::FormButton )
82  {
83  }
84 
85  Q_DECLARE_PUBLIC( FormFieldButton )
86 
87  void setValue( const QString& v )
88  {
89  Q_Q( FormFieldButton );
90  q->setState( QVariant( v ).toBool() );
91  }
92 
93  QString value() const
94  {
95  Q_Q( const FormFieldButton );
96  return qVariantFromValue<bool>( q->state() ).toString();
97  }
98 };
99 
100 
101 FormFieldButton::FormFieldButton()
102  : FormField( *new FormFieldButtonPrivate() )
103 {
104 }
105 
106 FormFieldButton::~FormFieldButton()
107 {
108 }
109 
110 void FormFieldButton::setState( bool )
111 {
112 }
113 
114 
115 class Okular::FormFieldTextPrivate : public Okular::FormFieldPrivate
116 {
117  public:
118  FormFieldTextPrivate()
119  : FormFieldPrivate( FormField::FormText )
120  {
121  }
122 
123  Q_DECLARE_PUBLIC( FormFieldText )
124 
125  void setValue( const QString& v )
126  {
127  Q_Q( FormFieldText );
128  q->setText( v );
129  }
130 
131  QString value() const
132  {
133  Q_Q( const FormFieldText );
134  return q->text();
135  }
136 };
137 
138 
139 FormFieldText::FormFieldText()
140  : FormField( *new FormFieldTextPrivate() )
141 {
142 }
143 
144 FormFieldText::~FormFieldText()
145 {
146 }
147 
148 void FormFieldText::setText( const QString& )
149 {
150 }
151 
152 bool FormFieldText::isPassword() const
153 {
154  return false;
155 }
156 
157 bool FormFieldText::isRichText() const
158 {
159  return false;
160 }
161 
162 int FormFieldText::maximumLength() const
163 {
164  return -1;
165 }
166 
167 Qt::Alignment FormFieldText::textAlignment() const
168 {
169  return Qt::AlignVCenter | Qt::AlignLeft;
170 }
171 
172 bool FormFieldText::canBeSpellChecked() const
173 {
174  return false;
175 }
176 
177 
178 class Okular::FormFieldChoicePrivate : public Okular::FormFieldPrivate
179 {
180  public:
181  FormFieldChoicePrivate()
182  : FormFieldPrivate( FormField::FormChoice )
183  {
184  }
185 
186  Q_DECLARE_PUBLIC( FormFieldChoice )
187 
188  void setValue( const QString& v )
189  {
190  Q_Q( FormFieldChoice );
191  QStringList choices = v.split( ';', QString::SkipEmptyParts );
192  QList<int> newchoices;
193  foreach ( const QString& str, choices )
194  {
195  bool ok = true;
196  int val = str.toInt( &ok );
197  if ( ok )
198  newchoices.append( val );
199  }
200  if ( !newchoices.isEmpty() )
201  q->setCurrentChoices( newchoices );
202  }
203 
204  QString value() const
205  {
206  Q_Q( const FormFieldChoice );
207  QList<int> choices = q->currentChoices();
208  qSort( choices );
209  QStringList list;
210  foreach ( int c, choices )
211  {
212  list.append( QString::number( c ) );
213  }
214  return list.join( QLatin1String( ";" ) );
215  }
216 };
217 
218 
219 FormFieldChoice::FormFieldChoice()
220  : FormField( *new FormFieldChoicePrivate() )
221 {
222 }
223 
224 FormFieldChoice::~FormFieldChoice()
225 {
226 }
227 
228 bool FormFieldChoice::isEditable() const
229 {
230  return false;
231 }
232 
233 bool FormFieldChoice::multiSelect() const
234 {
235  return false;
236 }
237 
238 void FormFieldChoice::setCurrentChoices( const QList< int >& )
239 {
240 }
241 
242 QString FormFieldChoice::editChoice() const
243 {
244  return QString();
245 }
246 
247 void FormFieldChoice::setEditChoice( const QString& )
248 {
249 }
250 
251 Qt::Alignment FormFieldChoice::textAlignment() const
252 {
253  return Qt::AlignVCenter | Qt::AlignLeft;
254 }
255 
256 bool FormFieldChoice::canBeSpellChecked() const
257 {
258  return false;
259 }
260 
Okular::FormField::~FormField
virtual ~FormField()
Definition: form.cpp:42
Okular::FormFieldChoice::setEditChoice
virtual void setEditChoice(const QString &text)
Sets the text entered into an editable combo box choice field.
Definition: form.cpp:247
Okular::FormFieldText::isRichText
virtual bool isRichText() const
Whether this text field should allow rich text.
Definition: form.cpp:157
Okular::FormFieldButton::~FormFieldButton
virtual ~FormFieldButton()
Definition: form.cpp:106
Okular::FormFieldPrivate
Definition: form_p.h:22
Okular::FormField::activationAction
Action * activationAction() const
Definition: form.cpp:63
Okular::FormFieldPrivate::value
virtual QString value() const =0
Okular::FormField::FieldType
FieldType
The types of form field.
Definition: form.h:47
Okular::FormFieldChoice::isEditable
virtual bool isEditable() const
Whether this ComboBox is editable, ie the user can type in a custom value.
Definition: form.cpp:228
Okular::FormFieldPrivate::m_default
QString m_default
Definition: form_p.h:34
Okular::FormField::isVisible
virtual bool isVisible() const
Whether this form field is visible.
Definition: form.cpp:58
Okular::FormFieldChoice::FormFieldChoice
FormFieldChoice()
Definition: form.cpp:219
Okular::FormFieldText::~FormFieldText
virtual ~FormFieldText()
Definition: form.cpp:144
Okular::FormFieldText
Interface of a text form field.
Definition: form.h:176
Okular::FormFieldChoice::editChoice
virtual QString editChoice() const
The text entered into an editable combo box choice field.
Definition: form.cpp:242
Okular::FormFieldPrivate::~FormFieldPrivate
virtual ~FormFieldPrivate()
Definition: form.cpp:25
Okular::FormFieldChoice::textAlignment
virtual Qt::Alignment textAlignment() const
The alignment of the text within the field.
Definition: form.cpp:251
action.h
Okular::FormFieldChoice
Interface of a choice form field.
Definition: form.h:258
Okular::FormField::setActivationAction
void setActivationAction(Action *action)
Definition: form.cpp:69
form.h
Okular::FormFieldButton::FormFieldButton
FormFieldButton()
Definition: form.cpp:101
Okular::FormFieldChoice::canBeSpellChecked
virtual bool canBeSpellChecked() const
Whether the text inserted manually in the field (where possible) can be spell-checked.
Definition: form.cpp:256
Okular::FormFieldText::maximumLength
virtual int maximumLength() const
The maximum length allowed for the text of text field, or -1 if there is no limitation for the text...
Definition: form.cpp:162
Okular::FormFieldPrivate::setDefault
void setDefault()
Definition: form.cpp:30
Okular::FormFieldChoice::~FormFieldChoice
virtual ~FormFieldChoice()
Definition: form.cpp:224
Okular::FormFieldChoice::multiSelect
virtual bool multiSelect() const
Whether more than one choice of this ListBox can be selected at the same time.
Definition: form.cpp:233
Okular::FormField::type
FieldType type() const
The type of the field.
Definition: form.cpp:47
Okular::FormField::isReadOnly
virtual bool isReadOnly() const
Whether the field is read-only.
Definition: form.cpp:53
Okular::FormFieldChoice::setCurrentChoices
virtual void setCurrentChoices(const QList< int > &choices)
Sets the selected choices to choices .
Definition: form.cpp:238
Okular::Action
Encapsulates data that describes an action.
Definition: action.h:43
Okular::FormFieldPrivate::m_activateAction
Action * m_activateAction
Definition: form_p.h:35
Okular::FormFieldPrivate::FormFieldPrivate
FormFieldPrivate(FormField::FieldType type)
Definition: form.cpp:20
Okular::FormFieldButton::setState
virtual void setState(bool state)
Sets the state of the button to the new state .
Definition: form.cpp:110
Okular::FormFieldText::isPassword
virtual bool isPassword() const
Whether this text field is a password input, eg its text must be replaced with asterisks.
Definition: form.cpp:152
Okular::FormFieldText::setText
virtual void setText(const QString &text)
Sets the new text in the text field.
Definition: form.cpp:148
Okular::FormFieldText::FormFieldText
FormFieldText()
Definition: form.cpp:139
form_p.h
Okular::FormFieldText::textAlignment
virtual Qt::Alignment textAlignment() const
The alignment of the text within the field.
Definition: form.cpp:167
Okular::FormFieldText::canBeSpellChecked
virtual bool canBeSpellChecked() const
Whether the text inserted manually in the field (where possible) can be spell-checked.
Definition: form.cpp:172
Okular::FormFieldButton
Interface of a button form field.
Definition: form.h:118
Okular::FormField
The base interface of a form field.
Definition: form.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal