Okular

form.h
1 /***************************************************************************
2  * Copyright (C) 2007 by Pino Toscano <[email protected]> *
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 #ifndef _OKULAR_FORM_H_
11 #define _OKULAR_FORM_H_
12 
13 #include "annotations.h"
14 #include "area.h"
15 #include "okularcore_export.h"
16 #include "signatureutils.h"
17 
18 #include <QStringList>
19 
20 #include <memory>
21 
22 namespace Okular
23 {
24 class Action;
25 class Page;
26 class PagePrivate;
27 class FormFieldPrivate;
28 class FormFieldButtonPrivate;
29 class FormFieldTextPrivate;
30 class FormFieldChoicePrivate;
31 class FormFieldSignaturePrivate;
32 
41 class OKULARCORE_EXPORT FormField
42 {
44  friend class Page;
45  friend class PagePrivate;
47 
48 public:
52  enum FieldType {
56  FormSignature
57  };
58 
59  virtual ~FormField();
60 
64  FieldType type() const;
65 
69  virtual NormalizedRect rect() const = 0;
70 
74  virtual int id() const = 0;
75 
80  virtual QString name() const = 0;
81 
86  virtual QString uiName() const = 0;
87 
94  virtual QString fullyQualifiedName() const = 0;
95 
99  virtual bool isReadOnly() const;
100 
106  virtual void setReadOnly(bool value);
107 
111  virtual bool isVisible() const;
112 
118  virtual void setVisible(bool value);
119 
125  virtual bool isPrintable() const;
126 
132  virtual void setPrintable(bool value);
133 
134  Action *activationAction() const;
135 
146  };
147 
153  Action *additionalAction(AdditionalActionType type) const;
154 
155  /* Returns the additional action of the given @p type or @c nullptr if no action has been defined.
156  *
157  * This is for actions of annotation widgets associated with the FormField
158  *
159  * @since 1.5
160  */
161  Action *additionalAction(Annotation::AdditionalActionType type) const;
162 
163 protected:
165  FormField(FormFieldPrivate &dd);
166  Q_DECLARE_PRIVATE(FormField)
167  FormFieldPrivate *d_ptr;
169 
170  void setActivationAction(Action *action);
171  void setAdditionalAction(AdditionalActionType type, Action *action);
172  void setAdditionalAction(Annotation::AdditionalActionType type, Action *action);
173 
174 private:
175  Q_DISABLE_COPY(FormField)
176 };
177 
186 class OKULARCORE_EXPORT FormFieldButton : public FormField
187 {
188 public:
192  enum ButtonType {
195  Radio
196  };
197 
198  ~FormFieldButton() override;
199 
203  virtual ButtonType buttonType() const = 0;
204 
208  virtual QString caption() const = 0;
209 
213  virtual bool state() const = 0;
214 
218  virtual void setState(bool state);
219 
226  virtual QList<int> siblings() const = 0;
227 
233  virtual void setIcon(Okular::FormField *field);
234 
235 protected:
236  FormFieldButton();
237 
238 private:
239  Q_DECLARE_PRIVATE(FormFieldButton)
240  Q_DISABLE_COPY(FormFieldButton)
241 };
242 
249 class OKULARCORE_EXPORT FormFieldText : public FormField
250 {
251 public:
255  enum TextType {
258  FileSelect
259  };
260 
261  ~FormFieldText() override;
262 
266  virtual TextType textType() const = 0;
267 
271  virtual QString text() const = 0;
272 
280  virtual void setText(const QString &text);
281 
288  virtual bool isPassword() const;
289 
293  virtual bool isRichText() const;
294 
299  virtual int maximumLength() const;
300 
304  virtual Qt::Alignment textAlignment() const;
305 
312  virtual bool canBeSpellChecked() const;
313 
319  virtual void setAppearanceText(const QString &text) = 0;
320 
321 protected:
322  FormFieldText();
323 
324 private:
325  Q_DECLARE_PRIVATE(FormFieldText)
326  Q_DISABLE_COPY(FormFieldText)
327 };
328 
336 class OKULARCORE_EXPORT FormFieldChoice : public FormField
337 {
338 public:
342  enum ChoiceType {
344  ListBox
345  };
346 
347  ~FormFieldChoice() override;
348 
352  virtual ChoiceType choiceType() const = 0;
353 
357  virtual QStringList choices() const = 0;
358 
365  virtual bool isEditable() const;
366 
373  virtual bool multiSelect() const;
374 
380  virtual QList<int> currentChoices() const = 0;
381 
385  virtual void setCurrentChoices(const QList<int> &choices);
386 
392  virtual QString editChoice() const;
393 
399  virtual void setEditChoice(const QString &text);
400 
404  virtual Qt::Alignment textAlignment() const;
405 
412  virtual bool canBeSpellChecked() const;
413 
419  QString exportValueForChoice(const QString &choice) const;
420 
421 protected:
422  FormFieldChoice();
423 
431  void setExportValues(const QMap<QString, QString> &values);
432 
433 private:
434  Q_DECLARE_PRIVATE(FormFieldChoice)
435  Q_DISABLE_COPY(FormFieldChoice)
436 };
437 
443 class OKULARCORE_EXPORT FormFieldSignature : public FormField
444 {
445 public:
449  enum SignatureType { AdbePkcs7sha1, AdbePkcs7detached, EtsiCAdESdetached, UnknownType };
450 
451  ~FormFieldSignature() override;
452 
456  virtual SignatureType signatureType() const = 0;
457 
461  virtual const SignatureInfo &signatureInfo() const = 0;
462 
463 protected:
465 
466 private:
467  Q_DECLARE_PRIVATE(FormFieldSignature)
468  Q_DISABLE_COPY(FormFieldSignature)
469 };
470 
471 }
472 
473 Q_DECLARE_METATYPE(const Okular::FormFieldSignature *);
474 
475 #endif
TextType
The types of text field.
Definition: form.h:255
A choice field. See FormFieldChoice::ChoiceType.
Definition: form.h:55
A NormalizedRect is a rectangle which can be defined by two NormalizedPoints.
Definition: area.h:191
FieldType
The types of form field.
Definition: form.h:52
A field of variable text. See FormFieldText::TextType.
Definition: form.h:54
A combo box choice field.
Definition: form.h:343
global.h
Definition: action.h:19
A "button". See FormFieldButton::ButtonType.
Definition: form.h:53
typedef Alignment
An action to be performed when the field needs to be recalculated.
Definition: form.h:145
Interface of a text form field.
Definition: form.h:249
ButtonType
The types of button field.
Definition: form.h:192
An action to be performed when the user modifies the field.
Definition: form.h:142
A simple singleline text field.
Definition: form.h:256
AdditionalActionType
Describes the type of form additional action.
Definition: form.h:141
An action to be performed before the field is formatted to display its value.
Definition: form.h:143
Interface of a choice form field.
Definition: form.h:336
Collector for all the data belonging to a page.
Definition: page.h:52
Interface of a signature form field.
Definition: form.h:443
A helper class to store information about digital signature.
A simple push button.
Definition: form.h:193
ChoiceType
The types of choice field.
Definition: form.h:342
AdditionalActionType
Describes the type of additional actions.
Definition: annotations.h:183
Encapsulates data that describes an action.
Definition: action.h:43
SignatureType
The types of signature.
Definition: form.h:449
Annotation struct holds properties shared by all annotations.
Definition: annotations.h:88
A multiline text field.
Definition: form.h:257
An action to be performed when the field value changes.
Definition: form.h:144
Interface of a button form field.
Definition: form.h:186
The base interface of a form field.
Definition: form.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Sep 20 2020 22:35:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.