LeechCraft Monocle  0.6.70-13605-g8cd066ad6a
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  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #pragma once
31 
32 #include <memory>
33 #include <QtPlugin>
34 
35 class QRectF;
36 
37 namespace LC
38 {
39 namespace Monocle
40 {
45  enum class FormType
46  {
53  Text,
54 
61  Choice,
62 
69  Button
70  };
71 
86  class IFormField
87  {
88  public:
91  virtual ~IFormField () {}
92 
97  virtual FormType GetType () const = 0;
98 
105  virtual int GetID () const = 0;
106 
111  virtual QString GetName () const = 0;
112 
127  virtual QRectF GetRect () const = 0;
128 
136  virtual Qt::Alignment GetAlignment () const = 0;
137  };
138 
141  typedef std::shared_ptr<IFormField> IFormField_ptr;
142 
150  class IFormFieldText
151  {
152  public:
157  enum class Type
158  {
161  SingleLine,
162 
165  Multiline,
166 
169  File
170  };
171 
174  virtual ~IFormFieldText () {}
175 
182  virtual QString GetText () const = 0;
183 
190  virtual void SetText (const QString& text) = 0;
191 
196  virtual Type GetTextType () const = 0;
197 
206  virtual int GetMaximumLength () const = 0;
207 
215  virtual bool IsPassword () const = 0;
216 
223  virtual bool IsRichText () const = 0;
224  };
225 
233  class IFormFieldChoice
234  {
235  public:
240  enum class Type
241  {
248  Combobox,
249 
256  ListBox
257  };
258 
261  virtual ~IFormFieldChoice () {}
262 
267  virtual Type GetChoiceType () const = 0;
268 
281  virtual QStringList GetAllChoices () const = 0;
282 
296  virtual QList<int> GetCurrentChoices () const = 0;
297 
309  virtual void SetCurrentChoices (const QList<int>& choices) = 0;
310 
326  virtual QString GetEditChoice () const = 0;
327 
343  virtual void SetEditChoice (const QString& choice) = 0;
344 
356  virtual bool IsEditable () const = 0;
357  };
358 
366  class IFormFieldButton
367  {
368  public:
371  virtual ~IFormFieldButton () {}
372 
377  enum class Type
378  {
383  Pushbutton,
384 
390  Checkbox,
391 
398  };
399 
404  virtual Type GetButtonType () const = 0;
405 
413  virtual QString GetCaption () const = 0;
414 
423  virtual bool IsChecked () const = 0;
424 
441  virtual void SetChecked (bool state) = 0;
442 
460  virtual QList<int> GetButtonGroup () const = 0;
461 
469  virtual void HandleActivated () = 0;
470  };
471 }
472 }
473 
474 Q_DECLARE_INTERFACE (LC::Monocle::IFormField,
475  "org.LeechCraft.Monocle.IFormField/1.0")
476 Q_DECLARE_INTERFACE (LC::Monocle::IFormFieldText,
477  "org.LeechCraft.Monocle.IFormFieldText/1.0")
478 Q_DECLARE_INTERFACE (LC::Monocle::IFormFieldChoice,
479  "org.LeechCraft.Monocle.IFormFieldChoice/1.0")
480 Q_DECLARE_INTERFACE (LC::Monocle::IFormFieldButton,
481  "org.LeechCraft.Monocle.IFormFieldButton/1.0")
LC::Monocle::IFormFieldText::Type::Multiline
Multiline text edit.
LC::Monocle::IFormFieldText::IsPassword
virtual bool IsPassword() const =0
Returns whether this is a password entry field.
LC::Monocle::IFormFieldChoice::SetCurrentChoices
virtual void SetCurrentChoices(const QList< int > &choices)=0
Sets the currently selected choices for a listbox.
LC::Monocle::IFormFieldChoice::GetChoiceType
virtual Type GetChoiceType() const =0
Returns the exact type of this choice field.
LC::Monocle::IFormField_ptr
std::shared_ptr< IFormField > IFormField_ptr
A shared pointer to a IFormField.
Definition: iformfield.h:140
LC::Monocle::IFormFieldButton::IsChecked
virtual bool IsChecked() const =0
Returns whether the button is checked.
LC::Monocle::FormType::Choice
A single- and multiple choice field.
LC::Monocle::AnnotationType::Text
A simple text annotation.
LC::Monocle::IFormFieldButton::GetButtonType
virtual Type GetButtonType() const =0
Returns the exact type of this button field.
LC::Monocle::IFormFieldChoice::GetEditChoice
virtual QString GetEditChoice() const =0
Returns the current choice for a combobox.
LC::Monocle::IFormFieldButton::HandleActivated
virtual void HandleActivated()=0
Notifies the field that it has been triggered.
LC::Monocle::IFormField::~IFormField
virtual ~IFormField()
Virtual destructor.
Definition: iformfield.h:90
LC::Monocle::IFormFieldText::Type::SingleLine
Single line text edit.
LC::Monocle::IFormFieldText::~IFormFieldText
virtual ~IFormFieldText()
Virtual destructor.
Definition: iformfield.h:173
LC::Monocle::IFormField::GetType
virtual FormType GetType() const =0
Returns the type of this field.
LC::Monocle::IFormField::GetRect
virtual QRectF GetRect() const =0
Returns the rectangle this field occupies.
LC::Monocle::IFormFieldButton::GetCaption
virtual QString GetCaption() const =0
Returns the caption of this button.
LC::Monocle::IFormField::GetAlignment
virtual Qt::Alignment GetAlignment() const =0
Returns the alignment of the contents of this field.
LC::Monocle::IFormFieldText::GetMaximumLength
virtual int GetMaximumLength() const =0
Returns the maximum length of the text.
LC::Monocle::IFormFieldChoice::SetEditChoice
virtual void SetEditChoice(const QString &choice)=0
Sets the current choice for a combobox.
LC::Monocle::IFormFieldChoice::GetCurrentChoices
virtual QList< int > GetCurrentChoices() const =0
Returns the list of current choices for a listbox.
LC::Monocle::IFormFieldText::Type
Type
Describes various types of text entry fields.
Definition: iformfield.h:156
LC::Monocle::IFormFieldText::GetText
virtual QString GetText() const =0
Returns the current text value of this field.
LC::Monocle::IFormFieldButton::GetButtonGroup
virtual QList< int > GetButtonGroup() const =0
Returns the button group this button belongs to.
LC::Monocle::IFormFieldChoice::Type::Combobox
Combobox with choices.
LC::Monocle::FormType
FormType
Describes the possible types of a form field.
Definition: iformfield.h:44
LC::Monocle::IFormFieldChoice::GetAllChoices
virtual QStringList GetAllChoices() const =0
Returns all available choices.
LC::Monocle::IFormFieldChoice::Type
Type
Describes various types of choice fields.
Definition: iformfield.h:239
LC::Monocle::IFormFieldButton::Type::Pushbutton
A button that can be pushed.
LC::Monocle::IFormFieldText::SetText
virtual void SetText(const QString &text)=0
Sets the current text value of this field to text.
LC::Monocle::IFormFieldButton::~IFormFieldButton
virtual ~IFormFieldButton()
Virtual destructor.
Definition: iformfield.h:370
LC::Monocle::IFormFieldButton::SetChecked
virtual void SetChecked(bool state)=0
Updates the check state of this button.
LC::Monocle::IFormFieldText::IsRichText
virtual bool IsRichText() const =0
Returns whether rich text should be accepted.
LC::Monocle::IFormField::GetID
virtual int GetID() const =0
Returns the unique ID of this field.
LC::Monocle::IFormField::GetName
virtual QString GetName() const =0
Returns the user-visible name of this field.
LC
Definition: iannotation.h:41
LC::Monocle::IFormFieldButton::Type
Type
Describes various types of button fields.
Definition: iformfield.h:376
LC::Monocle::IFormFieldText::GetTextType
virtual Type GetTextType() const =0
Returns the exact type of this text entry field.
LC::Monocle::IFormFieldButton::Type::Radiobutton
A field that can be checked with respect to the check state of others.
LC::Monocle::IFormField
Base interface to be implemented by form fields.
Definition: iformfield.h:85
LC::Monocle::IFormFieldChoice::Type::ListBox
List widget with choices.
LC::Monocle::IFormFieldChoice::IsEditable
virtual bool IsEditable() const =0
Returns whether this combobox is editable.
LC::Monocle::IFormFieldButton::Type::Checkbox
A field that can be checked independently of others.
LC::Monocle::FormType::Button
A push button, radio button or check box.
LC::Monocle::IFormFieldChoice::~IFormFieldChoice
virtual ~IFormFieldChoice()
Virtual destructor.
Definition: iformfield.h:260
LC::Monocle::IFormFieldText::Type::File
File entry widget.