Remoto - VFS: VFS_form_field Class Reference
Remoto - VFS

Base class for all form field types. More...

#include <VFS_form_field.h>

Inheritance diagram for VFS_form_field:
boolField breakField buttonField colorField dateTimeField fileSelectField groupField headerField labelField metadataField numberField progressField selectField textField textareaField

Public Member Functions

 VFS_form_field (QJsonValue val, QString type, QString label="", QString tip="")
 
 VFS_form_field (QString type)
 
void clearOption (QString o)
 Clear/remove a widget option. More...
 
int getIndex ()
 Get the field index. More...
 
QString getLabel ()
 Return the label. More...
 
void setAllowEmpty (bool e)
 Validate this field against empty-ness. More...
 
void setEnabled (bool e)
 Enable or disable this field. More...
 
void setHidden (bool e)
 Keep the field, but hide it when rendering. More...
 
void setHideLabel (bool l)
 Hide the label for this field. More...
 
void setIndex (int i)
 Set the field index for this widget. More...
 
void setLabel (QString l, bool replace=true)
 Set the label. More...
 
void setOption (QString o, QJsonValue v)
 Set a widget option. More...
 
void setSpellcheck (bool s)
 Enable or disable spellchecking on this text field. More...
 
void setTip (QString t)
 Set the tooltip. More...
 
void setValue (QJsonValue val)
 Set the value. More...
 

Protected Attributes

QJsonObject options
 Options for any widget type... this is an arbitrary list. More...
 

Detailed Description

Base class for all form field types.

As this is a subclass of a QJsonObject, it's basically a series of convenience functions for constructing an object in the correct form.

A field should have:

  • label - text visible to user
  • value - the field value (which must be JSON friendly)
  • tip - tooltip that becomes visible on mouseover
  • index - the order that fields will appear in the GUI (JSON objects do not inherently maintain item order)

and possibly an options entry:

  • allowEmpty - will not validate if empty
  • enabled - field will be created but interaction may be disallowed

Different field types will add their own options as needed.

See also
VFS_form
widget
form

Definition at line 6 of file VFS_form_field.h.

Constructor & Destructor Documentation

◆ VFS_form_field() [1/2]

VFS_form_field::VFS_form_field ( QString  type)
explicit
Parameters
typeThe type of this widget

All subclasses should specify a type, as that will determine the validation and rendering rules for this object.

Definition at line 34 of file VFS_form_field.cpp.

◆ VFS_form_field() [2/2]

VFS_form_field::VFS_form_field ( QJsonValue  val,
QString  type,
QString  label = "",
QString  tip = "" 
)
explicit
Parameters
valinitial value for this field
typeThe type of this widget
labellabel to display
tiptooltip for mouseover

Definition at line 48 of file VFS_form_field.cpp.

Member Function Documentation

◆ clearOption()

void VFS_form_field::clearOption ( QString  o)

Clear/remove a widget option.

Parameters
oOption name

Remove an option from the options object, whether it exists or not.

Definition at line 117 of file VFS_form_field.cpp.

◆ getIndex()

int VFS_form_field::getIndex ( )

Get the field index.

Get the field index for this widget.

Returns
i index value

Return the index used for display sorting.

Definition at line 154 of file VFS_form_field.cpp.

◆ getLabel()

QString VFS_form_field::getLabel ( )

Return the label.

Get the label for this widget.

Returns
val The label for this field

Definition at line 89 of file VFS_form_field.cpp.

◆ setAllowEmpty()

void VFS_form_field::setAllowEmpty ( bool  e)

Validate this field against empty-ness.

Set the validator to allow empty values for this widget.

Parameters
eAllow empty or not

Definition at line 164 of file VFS_form_field.cpp.

◆ setEnabled()

void VFS_form_field::setEnabled ( bool  e)

Enable or disable this field.

Set enabled on this widget.

Parameters
eThe enabled state

A widget that is not enabled will be visible but not editable.

Definition at line 176 of file VFS_form_field.cpp.

◆ setHidden()

void VFS_form_field::setHidden ( bool  e)

Keep the field, but hide it when rendering.

Hide or show this widget.

Parameters
eThe hide state

A widget that is hidden will not be visible, but will receive diffs and other events.

Definition at line 188 of file VFS_form_field.cpp.

◆ setHideLabel()

void VFS_form_field::setHideLabel ( bool  l)

Hide the label for this field.

Hide or show the label for this widget.

Parameters
lThe label visibility state

A widget that hides its label will still create a label div, but not show it.

Definition at line 200 of file VFS_form_field.cpp.

◆ setIndex()

void VFS_form_field::setIndex ( int  i)

Set the field index for this widget.

Parameters
iindex value

The JSON spec specifies that JsonObject order is not kept during serialization.

Field indexes are sorted based on this value before being displayed.

Definition at line 142 of file VFS_form_field.cpp.

◆ setLabel()

void VFS_form_field::setLabel ( QString  label,
bool  replace = true 
)

Set the label.

Set the label for this widget.

Parameters
labelThe label for this field
replaceIf the label has already been set, replace it.

If the label has already been set, this method will do nothing unless replace is set. This is useful for subclasses.

Definition at line 77 of file VFS_form_field.cpp.

◆ setOption()

void VFS_form_field::setOption ( QString  o,
QJsonValue  v 
)

Set a widget option.

Parameters
oOption name
vOption value

Beware that this does not do any sanitization based on type, it just sets the option in the JSON object.

Definition at line 102 of file VFS_form_field.cpp.

◆ setSpellcheck()

void VFS_form_field::setSpellcheck ( bool  s)

Enable or disable spellchecking on this text field.

For text-based widgets, set the spellcheck flag on the field.

Parameters
sThe spellcheck state

Definition at line 210 of file VFS_form_field.cpp.

◆ setTip()

void VFS_form_field::setTip ( QString  tip)

Set the tooltip.

Set the mouseover tip for a widget.

Parameters
tipThe string displayed

Definition at line 127 of file VFS_form_field.cpp.

◆ setValue()

void VFS_form_field::setValue ( QJsonValue  val)

Set the value.

Set the value for this widget.

Parameters
valThe value for this field

Definition at line 64 of file VFS_form_field.cpp.

Member Data Documentation

◆ options

QJsonObject VFS_form_field::options
protected

Options for any widget type... this is an arbitrary list.

Definition at line 34 of file VFS_form_field.h.


The documentation for this class was generated from the following files: