Tome
A generic data editor for games supporting arbitrary input and output formats.
fielddefinitionscontroller.h
1 #ifndef FIELDDEFINITIONSCONTROLLER_H
2 #define FIELDDEFINITIONSCONTROLLER_H
3 
4 #include "../Model/fielddefinitionsetlist.h"
5 #include "../../Components/Model/component.h"
6 
7 namespace Tome
8 {
9  class ComponentsController;
10  class TypesController;
11 
15  class FieldDefinitionsController : public QObject
16  {
17  Q_OBJECT
18 
19  public:
25  FieldDefinitionsController(const ComponentsController& componentsController, const TypesController& typesController);
26 
43  void addFieldDefinition(
44  const QString& id,
45  const QString& displayName,
46  const QString& fieldType,
47  const QVariant& defaultValue,
48  const QString& component,
49  const QString& description,
50  const QString& fieldDefinitionSetName);
51 
56  void addFieldDefinitionSet(const FieldDefinitionSet& fieldDefinitionSet);
57 
68  const FieldDefinition& getFieldDefinition(const QString& id) const;
69 
74  const FieldDefinitionList getFieldDefinitions() const;
75 
81  const FieldDefinitionList getFieldDefinitionsOfComponent(const QString& component) const;
82 
87  const FieldDefinitionSetList& getFieldDefinitionSets() const;
88 
93  const QStringList getFieldDefinitionSetNames() const;
94 
100  bool hasFieldDefinition(const QString& id) const;
101 
106  void removeFieldDefinition(const QString& fieldId);
107 
112  void removeFieldDefinitionSet(const QString& name);
113 
118  void setFieldDefinitionSets(FieldDefinitionSetList& model);
119 
137  void updateFieldDefinition(const QString oldId,
138  const QString newId,
139  const QString& displayName,
140  const QString& fieldType,
141  const QVariant& defaultValue,
142  const QString& component,
143  const QString& description,
144  const QString& fieldDefinitionSetName);
145 
146  signals:
151  void fieldDefinitionAdded(const Tome::FieldDefinition& fieldDefinition);
152 
157  void fieldDefinitionRemoved(const Tome::FieldDefinition& fieldDefinition);
158 
164  void fieldDefinitionUpdated(const Tome::FieldDefinition& oldFieldDefinition, const Tome::FieldDefinition& newFieldDefinition);
165 
166  private slots:
167  void onComponentRemoved(const Tome::Component& component);
168  void onTypeRenamed(const QString& oldName, const QString& newName);
169 
170  private:
171  const ComponentsController& componentsController;
172  const TypesController& typesController;
173 
174  FieldDefinitionSetList* model;
175 
176  FieldDefinition* getFieldDefinitionById(const QString& id) const;
177  void moveFieldDefinitionToSet(const QString& fieldDefinitionId, const QString& fieldDefinitionSetName);
178  };
179 }
180 
181 #endif // FIELDDEFINITIONSCONTROLLER_H
Definition: commandlineoptions.h:6
Controller for adding, updating and removing field definitions.
Definition: fielddefinitionscontroller.h:15
bool hasFieldDefinition(const QString &id) const
Checks whether the project has a field definition with the specified id.
Definition: fielddefinitionscontroller.cpp:146
void removeFieldDefinition(const QString &fieldId)
Removes the field definition with the specified id from the project.
Definition: fielddefinitionscontroller.cpp:166
void fieldDefinitionRemoved(const Tome::FieldDefinition &fieldDefinition)
A field definition has been removed from the project.
void fieldDefinitionUpdated(const Tome::FieldDefinition &oldFieldDefinition, const Tome::FieldDefinition &newFieldDefinition)
The properties of a field definition have been updated.
void fieldDefinitionAdded(const Tome::FieldDefinition &fieldDefinition)
A new field definition has been added to the project.
void setFieldDefinitionSets(FieldDefinitionSetList &model)
Uses the specified list of field definition sets as model for this controller.
Definition: fielddefinitionscontroller.cpp:203
void addFieldDefinition(const QString &id, const QString &displayName, const QString &fieldType, const QVariant &defaultValue, const QString &component, const QString &description, const QString &fieldDefinitionSetName)
Adds a new field definition to the specified set.
Definition: fielddefinitionscontroller.cpp:28
void removeFieldDefinitionSet(const QString &name)
Removes the field definition set with the specified name from the project, including all fields...
Definition: fielddefinitionscontroller.cpp:188
Controller for adding and removing components.
Definition: componentscontroller.h:15
const FieldDefinitionSetList & getFieldDefinitionSets() const
Gets a list of all field definition sets in the project.
Definition: fielddefinitionscontroller.cpp:128
Field that can be added to a record to hold data.
Definition: fielddefinition.h:15
const QStringList getFieldDefinitionSetNames() const
Gets a list of the names of all field definition sets in the project.
Definition: fielddefinitionscontroller.cpp:133
Controller for adding, updating and removing custom types.
Definition: typescontroller.h:14
void updateFieldDefinition(const QString oldId, const QString newId, const QString &displayName, const QString &fieldType, const QVariant &defaultValue, const QString &component, const QString &description, const QString &fieldDefinitionSetName)
Updates the properties of the specified field definition.
Definition: fielddefinitionscontroller.cpp:208
Named set of Tome field definitions.
Definition: fielddefinitionset.h:13
const FieldDefinition & getFieldDefinition(const QString &id) const
Gets the field definition with the specified id.
Definition: fielddefinitionscontroller.cpp:84
FieldDefinitionsController(const ComponentsController &componentsController, const TypesController &typesController)
Constructs a new controller for adding, updating and removing field definitions.
Definition: fielddefinitionscontroller.cpp:13
void addFieldDefinitionSet(const FieldDefinitionSet &fieldDefinitionSet)
Adds the passed field definition set to the project.
Definition: fielddefinitionscontroller.cpp:78
const FieldDefinitionList getFieldDefinitionsOfComponent(const QString &component) const
Gets a list of all field definitions belonging to the specified component.
Definition: fielddefinitionscontroller.cpp:106
const FieldDefinitionList getFieldDefinitions() const
Gets a list of all field definitions in the project.
Definition: fielddefinitionscontroller.cpp:89