Remoto - VFS: VFS_form.h Source File
Remoto - VFS
VFS_form.h
Go to the documentation of this file.
1 #ifndef VFS_FORM_H
2 #define VFS_FORM_H
3 
4 #include <QJsonDocument>
5 #include <QJsonObject>
6 
7 #include "VFS_form_field.h"
8 
9 class VFS_form
10 {
11  public:
12  explicit VFS_form(QString base="");
13  virtual ~VFS_form();
14 
15  void setBase(QString baseForm);
16  void setHelp(QString helpText);
17  QJsonDocument toJsonDocument(bool useAttributes=false);
18  QJsonDocument toSubclassDocument();
19 
20  void append(QString name, VFS_form_field field, int index=-1);
21  void remove(QString name);
22  void replace(QString name, VFS_form_field field);
23  void removeIndexRange(int s, int e);
24 
25  bool contains(QString field);
26 
27  bool setValue(QString var, QJsonValue val);
28  QJsonValue getValue(QString var);
29 
30  bool setOption(QString var, QString option, QJsonValue o);
31  QJsonValue getOption(QString var, QString option);
32 
33  void addBreak(int index=-1);
34 
35  void applyDiff(QJsonObject diff, bool useAttributes=false);
36  // void submit(QJsonObject values);
37 
38  //static QJsonObject _noDiffTypes; //!<
39 
40  private:
41  int _index;
43 
44  QString _baseForm;
45  QString _helpText;
46  QJsonObject _form;
47 
48  QJsonValue cleanValue(QJsonValue o, bool isValue=false);
49 };
50 
51 #endif // VFS_FORM_H
Base class for all form field types.
Definition: VFS_form_field.h:7
A form is an aggregate of named typed fields.
Definition: VFS_form.h:10
QJsonDocument toJsonDocument(bool useAttributes=false)
Return a form document as a QJsonDocument.
Definition: VFS_form.cpp:147
QString _baseForm
The base json 'class' that this form will augment. Leave blank for no base.
Definition: VFS_form.h:44
QString _helpText
The help text that will appear in a menu or modal for this form.
Definition: VFS_form.h:45
void setHelp(QString helpText)
Set the helptext for this form.
Definition: VFS_form.cpp:61
void removeIndexRange(int s, int e)
Remove fields whose index is within a range.
Definition: VFS_form.cpp:281
QJsonDocument toSubclassDocument()
Return the form as a QJsonDocument, and include reference to its base.
Definition: VFS_form.cpp:178
QJsonValue cleanValue(QJsonValue o, bool isValue=false)
Normalize a form value recursively.
Definition: VFS_form.cpp:78
int _breakCount
The break count, because all fields must have unique names, and addBreak will use this.
Definition: VFS_form.h:42
bool contains(QString field)
Check if a field is part of a form.
Definition: VFS_form.cpp:299
void remove(QString name)
Remove a field from the form.
Definition: VFS_form.cpp:244
void append(QString name, VFS_form_field field, int index=-1)
Append a field to the form.
Definition: VFS_form.cpp:222
QJsonObject _form
The form itself, which is just a json object.
Definition: VFS_form.h:46
bool setOption(QString var, QString option, QJsonValue o)
Set an option on a form field if it exists.
Definition: VFS_form.cpp:385
QJsonValue getOption(QString var, QString option)
Fetch an option value from a form field if it exists.
Definition: VFS_form.cpp:408
virtual ~VFS_form()
Definition: VFS_form.cpp:41
int _index
The index count used for autoindexing.
Definition: VFS_form.h:41
void addBreak(int index=-1)
Add a break field to a form.
Definition: VFS_form.cpp:426
QJsonValue getValue(QString var)
Fetch the value of a form field.
Definition: VFS_form.cpp:361
VFS_form(QString base="")
Definition: VFS_form.cpp:33
bool setValue(QString var, QJsonValue val)
Set the value of a form field if it exists.
Definition: VFS_form.cpp:313
void replace(QString name, VFS_form_field field)
Replace or append a field to the form.
Definition: VFS_form.cpp:260
void applyDiff(QJsonObject diff, bool useAttributes=false)
Apply a diff to this form.
Definition: VFS_form.cpp:448
void setBase(QString baseForm)
Set the 'class' that this form inherits from.
Definition: VFS_form.cpp:51