LeechCraft Monocle  0.6.70-16373-g319c272718
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 class QRectF;
16 
17 namespace LC::Monocle
18 {
23  enum class FormType
24  {
31  Text,
32 
39  Choice,
40 
47  Button
48  };
49 
64  class IFormField
65  {
66  public:
69  virtual ~IFormField () {}
70 
75  virtual FormType GetType () const = 0;
76 
83  virtual int GetID () const = 0;
84 
89  virtual QString GetName () const = 0;
90 
105  virtual QRectF GetRect () const = 0;
106 
114  virtual Qt::Alignment GetAlignment () const = 0;
115  };
116 
119  typedef std::shared_ptr<IFormField> IFormField_ptr;
120 
129  {
130  public:
135  enum class Type
136  {
139  SingleLine,
140 
143  Multiline,
144 
147  File
148  };
149 
152  virtual ~IFormFieldText () {}
153 
160  virtual QString GetText () const = 0;
161 
168  virtual void SetText (const QString& text) = 0;
169 
174  virtual Type GetTextType () const = 0;
175 
184  virtual int GetMaximumLength () const = 0;
185 
193  virtual bool IsPassword () const = 0;
194 
201  virtual bool IsRichText () const = 0;
202  };
203 
212  {
213  public:
218  enum class Type
219  {
226  Combobox,
227 
234  ListBox
235  };
236 
239  virtual ~IFormFieldChoice () {}
240 
245  virtual Type GetChoiceType () const = 0;
246 
259  virtual QStringList GetAllChoices () const = 0;
260 
274  virtual QList<int> GetCurrentChoices () const = 0;
275 
287  virtual void SetCurrentChoices (const QList<int>& choices) = 0;
288 
304  virtual QString GetEditChoice () const = 0;
305 
321  virtual void SetEditChoice (const QString& choice) = 0;
322 
334  virtual bool IsEditable () const = 0;
335  };
336 
345  {
346  public:
349  virtual ~IFormFieldButton () {}
350 
355  enum class Type
356  {
361  Pushbutton,
362 
368  Checkbox,
369 
376  };
377 
382  virtual Type GetButtonType () const = 0;
383 
391  virtual QString GetCaption () const = 0;
392 
401  virtual bool IsChecked () const = 0;
402 
419  virtual void SetChecked (bool state) = 0;
420 
438  virtual QList<int> GetButtonGroup () const = 0;
439 
447  virtual LinkAction GetActivationAction () const = 0;
448  };
449 }
450 
451 Q_DECLARE_INTERFACE (LC::Monocle::IFormField,
452  "org.LeechCraft.Monocle.IFormField/1.0")
453 Q_DECLARE_INTERFACE (LC::Monocle::IFormFieldText,
454  "org.LeechCraft.Monocle.IFormFieldText/1.0")
455 Q_DECLARE_INTERFACE (LC::Monocle::IFormFieldChoice,
456  "org.LeechCraft.Monocle.IFormFieldChoice/1.0")
457 Q_DECLARE_INTERFACE (LC::Monocle::IFormFieldButton,
458  "org.LeechCraft.Monocle.IFormFieldButton/1.0")
virtual ~IFormFieldText()
Virtual destructor.
Definition: iformfield.h:152
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 ~IFormFieldButton()
Virtual destructor.
Definition: iformfield.h:349
virtual int GetID() const =0
Returns the unique ID of this field.
Type
Describes various types of choice fields.
Definition: iformfield.h:218
virtual QStringList GetAllChoices() const =0
Returns all available choices.
std::shared_ptr< IFormField > IFormField_ptr
A shared pointer to a IFormField.
Definition: iformfield.h:119
virtual ~IFormFieldChoice()
Virtual destructor.
Definition: iformfield.h:239
A single- and multiple choice field.
A simple text annotation.
Type
Describes various types of button fields.
Definition: iformfield.h:355
Interface to be implemented by text fields.
Definition: iformfield.h:128
virtual bool IsChecked() const =0
Returns whether the button is checked.
Interface to be implemented by button fields.
Definition: iformfield.h:344
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 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:135
FormType
Describes the possible types of a form field.
Definition: iformfield.h:23
A field that can be checked independently of others.
Base interface to be implemented by form fields.
Definition: iformfield.h:64
A push button, radio button or check box.
virtual QRectF GetRect() const =0
Returns the rectangle this field occupies.
std::variant< NoAction, NavigationAction, ExternalNavigationAction, UrlAction, CustomAction > LinkAction
Definition: ilink.h:110
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:211
Definition: iannotation.h:20
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.
virtual ~IFormField()
Virtual destructor.
Definition: iformfield.h:69