Tome
A generic data editor for games supporting arbitrary input and output formats.
facet.h
1 #ifndef FACET_H
2 #define FACET_H
3 
4 #include <QString>
5 #include <QWidget>
6 
7 namespace Tome
8 {
9  class FacetContext;
10 
14  class Facet
15  {
16  public:
20  Facet();
21  virtual ~Facet();
22 
28  virtual QWidget* createWidget(const FacetContext& context) const = 0;
29 
34  virtual const QVariant getDefaultValue() const = 0;
35 
41  virtual const QString getDescriptionForValue(const QVariant facetValue) const = 0;
42 
47  virtual const QString getDisplayName() const = 0;
48 
53  virtual const QString getKey() const = 0;
54 
59  virtual const QString getTargetType() const = 0;
60 
66  virtual const QVariant getWidgetValue(QWidget* widget) const = 0;
67 
73  virtual void setWidgetValue(QWidget* widget, const QVariant value) const = 0;
74 
82  virtual QString validateValue(const FacetContext& context, const QVariant value, const QVariant facetValue) const = 0;
83  };
84 }
85 
86 #endif // FACET_H
Definition: commandlineoptions.h:6
virtual const QString getDescriptionForValue(const QVariant facetValue) const =0
Gets the text to add to the description of a field, explaining the restriction of the domain of the c...
virtual const QString getKey() const =0
Gets the key of the restriction of the domain of the custom type used for serialization.
Facet()
Constructs a new facet for restricting the domain of a custom type.
Definition: facet.cpp:5
virtual void setWidgetValue(QWidget *widget, const QVariant value) const =0
Sets the current value of the widget for specifying the restriction of the domain of the custom type ...
virtual const QVariant getDefaultValue() const =0
Gets the default restriction of the domain of the custom type (e.g. default minimum value)...
virtual QString validateValue(const FacetContext &context, const QVariant value, const QVariant facetValue) const =0
Validates the specified field value against the domain restrictions imposed by this facet...
Context to apply facets in.
Definition: facetcontext.h:11
virtual const QString getDisplayName() const =0
Gets the name of the restriction of the domain of the custom type (e.g. "Minimum Value").
virtual QWidget * createWidget(const FacetContext &context) const =0
Creates a widget for specifying the restriction of the domain of the custom type (e.g. QSpinBox).
Restricts the domain of a custom type.
Definition: facet.h:14
virtual const QString getTargetType() const =0
Gets the custom type whose domain can be restricted by this facet.
virtual const QVariant getWidgetValue(QWidget *widget) const =0
Gets the current value of the widget for specifying the restriction of the domain of the custom type ...