LeechCraft Monocle  0.6.70-18450-gabe19ee3b0
Modular document viewer for LeechCraft
iformfield.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <memory>
12 #include <QtPlugin>
13 #include "ilink.h"
14 
15 namespace LC::Monocle
16 {
21  enum class FormType
22  {
29  Text,
30 
37  Choice,
38 
45  Button
46  };
47 
62  class IFormField
63  {
64  public:
67  virtual ~IFormField () = default;
68 
73  virtual FormType GetType () const = 0;
74 
81  virtual int GetID () const = 0;
82 
87  virtual QString GetName () const = 0;
88 
98  virtual PageRelativeRectBase GetRect () const = 0;
99 
107  virtual Qt::Alignment GetAlignment () const = 0;
108  };
109 
112  typedef std::shared_ptr<IFormField> IFormField_ptr;
113 
122  {
123  public:
128  enum class Type
129  {
132  SingleLine,
133 
136  Multiline,
137 
140  File
141  };
142 
145  virtual ~IFormFieldText () = default;
146 
153  virtual QString GetText () const = 0;
154 
161  virtual void SetText (const QString& text) = 0;
162 
167  virtual Type GetTextType () const = 0;
168 
177  virtual int GetMaximumLength () const = 0;
178 
186  virtual bool IsPassword () const = 0;
187 
194  virtual bool IsRichText () const = 0;
195  };
196 
205  {
206  public:
211  enum class Type
212  {
219  Combobox,
220 
227  ListBox
228  };
229 
232  virtual ~IFormFieldChoice () = default;
233 
238  virtual Type GetChoiceType () const = 0;
239 
252  virtual QStringList GetAllChoices () const = 0;
253 
267  virtual QList<int> GetCurrentChoices () const = 0;
268 
280  virtual void SetCurrentChoices (const QList<int>& choices) = 0;
281 
297  virtual QString GetEditChoice () const = 0;
298 
314  virtual void SetEditChoice (const QString& choice) = 0;
315 
327  virtual bool IsEditable () const = 0;
328  };
329 
338  {
339  public:
342  virtual ~IFormFieldButton () = default;
343 
348  enum class Type
349  {
354  Pushbutton,
355 
361  Checkbox,
362 
369  };
370 
375  virtual Type GetButtonType () const = 0;
376 
384  virtual QString GetCaption () const = 0;
385 
394  virtual bool IsChecked () const = 0;
395 
412  virtual void SetChecked (bool state) = 0;
413 
431  virtual QList<int> GetButtonGroup () const = 0;
432 
440  virtual LinkAction GetActivationAction () const = 0;
441  };
442 }
virtual void SetChecked(bool state)=0
Updates the check state of this button.
virtual QList< int > GetCurrentChoices() const =0
Returns the list of current choices for a listbox.
virtual bool IsEditable() const =0
Returns whether this combobox is editable.
virtual PageRelativeRectBase GetRect() const =0
Returns the rectangle this field occupies.
virtual int GetID() const =0
Returns the unique ID of this field.
Type
Describes various types of choice fields.
Definition: iformfield.h:211
virtual QStringList GetAllChoices() const =0
Returns all available choices.
virtual ~IFormFieldChoice()=default
Virtual destructor.
virtual ~IFormFieldText()=default
Virtual destructor.
std::shared_ptr< IFormField > IFormField_ptr
A shared pointer to a IFormField.
Definition: iformfield.h:112
A single- and multiple choice field.
A simple text annotation.
Type
Describes various types of button fields.
Definition: iformfield.h:348
Interface to be implemented by text fields.
Definition: iformfield.h:121
virtual bool IsChecked() const =0
Returns whether the button is checked.
Interface to be implemented by button fields.
Definition: iformfield.h:337
virtual bool IsRichText() const =0
Returns whether rich text should be accepted.
virtual QString GetEditChoice() const =0
Returns the current choice for a combobox.
virtual bool IsPassword() const =0
Returns whether this is a password entry field.
virtual Type GetTextType() const =0
Returns the exact type of this text entry field.
virtual Type GetButtonType() const =0
Returns the exact type of this button field.
virtual int GetMaximumLength() const =0
Returns the maximum length of the text.
A field that can be checked with respect to the check state of others.
virtual ~IFormFieldButton()=default
Virtual destructor.
virtual QString GetText() const =0
Returns the current text value of this field.
virtual void SetCurrentChoices(const QList< int > &choices)=0
Sets the currently selected choices for a listbox.
Type
Describes various types of text entry fields.
Definition: iformfield.h:128
FormType
Describes the possible types of a form field.
Definition: iformfield.h:21
A field that can be checked independently of others.
Base interface to be implemented by form fields.
Definition: iformfield.h:62
A push button, radio button or check box.
std::variant< NoAction, NavigationAction, ExternalNavigationAction, UrlAction, CustomAction > LinkAction
Definition: ilink.h:107
virtual QList< int > GetButtonGroup() const =0
Returns the button group this button belongs to.
virtual Qt::Alignment GetAlignment() const =0
Returns the alignment of the contents of this field.
virtual Type GetChoiceType() const =0
Returns the exact type of this choice field.
virtual LinkAction GetActivationAction() const =0
Returns the action associated with this button.
Interface to be implemented by choice fields.
Definition: iformfield.h:204
virtual ~IFormField()=default
Virtual destructor.
virtual FormType GetType() const =0
Returns the type of this field.
virtual QString GetCaption() const =0
Returns the caption of this button.
virtual void SetText(const QString &text)=0
Sets the current text value of this field to text.
virtual void SetEditChoice(const QString &choice)=0
Sets the current choice for a combobox.
virtual QString GetName() const =0
Returns the user-visible name of this field.