Tome
A generic data editor for games supporting arbitrary input and output formats.
fieldvaluewidget.h
1 #ifndef FIELDVALUEWIDGET_H
2 #define FIELDVALUEWIDGET_H
3 
4 #include <QCheckBox>
5 #include <QColorDialog>
6 #include <QComboBox>
7 #include <QDoubleSpinBox>
8 #include <QLabel>
9 #include <QLineEdit>
10 #include <QSpinBox>
11 #include <QString>
12 #include <QVBoxLayout>
13 #include <QVector>
14 #include <QWidget>
15 
16 namespace Tome
17 {
18  class CustomType;
19  class FilePickerWidget;
20  class ListWidget;
21  class MapWidget;
22  class FacetsController;
23  class ProjectController;
24  class RecordsController;
25  class TypesController;
26  class Vector2IWidget;
27  class Vector2RWidget;
28  class Vector3IWidget;
29  class Vector3RWidget;
30  class Facet;
31 
35  class FieldValueWidget : public QWidget
36  {
37  Q_OBJECT
38 
39  public:
48  explicit FieldValueWidget(FacetsController& facetsController,
49  ProjectController& projectController,
50  RecordsController& recordsController,
51  TypesController& typesController,
52  QWidget* parent = 0);
54 
59  QString getFieldType() const;
60 
68  QVariant getFieldValue() const;
69 
77  void setFieldType(const QString& fieldType);
78 
86  void setFieldValue(const QVariant& fieldValue);
87 
92  QString validate();
93 
94  protected:
99  virtual void focusInEvent(QFocusEvent* event) Q_DECL_OVERRIDE;
100 
101  private slots:
102  void onColorDialogCurrentColorChanged(const QColor& color);
103  void onDoubleSpinBoxValueChanged(double d);
104  void onLineEditTextChanged(const QString& text);
105  void onComboBoxCurrentIndexChanged(const QString& text);
106  void onSpinBoxValueChanged(int i);
107 
108  private:
109  QWidget* currentWidget;
110  QString fieldType;
111 
112  QCheckBox* checkBox;
113  QColorDialog* colorDialog;
114  QDoubleSpinBox* doubleSpinBox;
115  FilePickerWidget* filePicker;
116  QVBoxLayout* layout;
117  QLineEdit* lineEdit;
118  ListWidget* listWidget;
119  MapWidget* mapWidget;
120  QComboBox* comboBox;
121  QSpinBox* spinBox;
122  Vector2IWidget* vector2IWidget;
123  Vector3IWidget* vector3IWidget;
124  Vector2RWidget* vector2RWidget;
125  Vector3RWidget* vector3RWidget;
126 
127  QLabel* errorLabel;
128 
129  FacetsController& facetsController;
130  ProjectController& projectController;
131  RecordsController& recordsController;
132  TypesController& typesController;
133 
134  void addWidget(QWidget* widget);
135  QVariant getFieldValueForType(const QString& typeName) const;
136  void selectWidgetForType(const QString& typeName);
137  void setCurrentWidget(QWidget* widget);
138  void setEnumeration(const QStringList& enumeration);
139  void setFieldValueForType(const QVariant& fieldValue, const QString& typeName);
140  void updateErrorLabel();
141  };
142 }
143 
144 #endif // FIELDVALUEWIDGET_H
Definition: commandlineoptions.h:6
void setFieldValue(const QVariant &fieldValue)
Sets the current value of this widget.
Definition: fieldvaluewidget.cpp:161
Controller for adding, updating and removing records.
Definition: recordscontroller.h:21
Allows editing three-dimensional vectors with integer components.
Definition: vector3iwidget.h:15
FieldValueWidget(FacetsController &facetsController, ProjectController &projectController, RecordsController &recordsController, TypesController &typesController, QWidget *parent=0)
Constructs a new widget that changes its appearance depending on the specified type.
Definition: fieldvaluewidget.cpp:27
Allows editing two-dimensional vectors with integer components.
Definition: vector2iwidget.h:15
void setFieldType(const QString &fieldType)
Sets the current type of the values changed by this widget.
Definition: fieldvaluewidget.cpp:147
Changes its appearance depending on the specified type.
Definition: fieldvaluewidget.h:35
Controller for adding, updating and removing custom types.
Definition: typescontroller.h:14
virtual void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE
Sets the focus to the current widget, if any, and pre-selects any content.
Definition: fieldvaluewidget.cpp:174
Allows adding, editing, re-ordering and removing list items.
Definition: listwidget.h:23
Allows adding, editing, and removing map items.
Definition: mapwidget.h:23
Allows editing three-dimensional vectors with real components.
Definition: vector3rwidget.h:16
Allows editing two-dimensional vectors with real components.
Definition: vector2rwidget.h:15
QVariant getFieldValue() const
Gets the current value of this widget.
Definition: fieldvaluewidget.cpp:142
Controller for validating type facets.
Definition: facetscontroller.h:16
QString getFieldType() const
Gets the current type of the values changed by this widget.
Definition: fieldvaluewidget.cpp:137
Controller for creating, loading and saving projects.
Definition: projectcontroller.h:22
QString validate()
Validates the current value against all facets of its type.
Definition: fieldvaluewidget.cpp:166
Widget that allows to browse for a file and shows the current path.
Definition: filepickerwidget.h:19