Tome
A generic data editor for games supporting arbitrary input and output formats.
typescontroller.h
1 #ifndef TYPESCONTROLLER_H
2 #define TYPESCONTROLLER_H
3 
4 #include <QVariant>
5 
6 #include "../Model/customtypelist.h"
7 #include "../Model/customtypesetlist.h"
8 
9 namespace Tome
10 {
14  class TypesController : public QObject
15  {
16  Q_OBJECT
17 
18  public:
23  void addCustomTypeSet(const CustomTypeSet& customTypeSet);
24 
36  const CustomType addDerivedType(const QString& name,
37  const QString& baseType,
38  const QVariantMap& facets,
39  const QString& customTypeSetName);
40 
51  const CustomType addEnumeration(const QString& name,
52  const QStringList& enumeration,
53  const QString& customTypeSetName);
54 
65  const CustomType addList(const QString& name,
66  const QString& itemType,
67  const QString& customTypeSetName);
68 
80  const CustomType addMap(const QString& name,
81  const QString& keyType,
82  const QString& valueType,
83  const QString& customTypeSetName);
84 
89  const QStringList getBuiltInTypes() const;
90 
101  const CustomType& getCustomType(const QString& name) const;
102 
107  const CustomTypeList getCustomTypes() const;
108 
113  const CustomTypeSetList& getCustomTypeSets() const;
114 
119  const QStringList getCustomTypeSetNames() const;
120 
125  const QStringList getTypeNames() const;
126 
132  bool isBuiltInType(const QString& name) const;
133 
139  bool isCustomType(const QString& name) const;
140 
147  bool isTypeOrDerivedFromType(const QString& lhs, const QString& rhs) const;
148 
153  void removeCustomType(const QString& typeName);
154 
159  void removeCustomTypeSet(const QString& name);
160 
165  void setCustomTypes(CustomTypeSetList& model);
166 
180  void updateDerivedType(const QString& oldName,
181  const QString& newName,
182  const QString& baseType,
183  const QVariantMap facets,
184  const QString& typeSetName);
185 
198  void updateEnumeration(const QString& oldName,
199  const QString& newName,
200  const QStringList& enumeration,
201  const QString& typeSetName);
202 
215  void updateList(const QString& oldName,
216  const QString& newName,
217  const QString& itemType,
218  const QString& typeSetName);
219 
233  void updateMap(const QString& oldName,
234  const QString& newName,
235  const QString& keyType,
236  const QString& valueType,
237  const QString& typeSetName);
238 
245  QString valueToString(const QVariant& value, const QString& typeName) const;
246 
247  signals:
252  void typeAdded(const Tome::CustomType& type);
253 
259  void typeRenamed(const QString& oldName, const QString& newName);
260 
265  void typeRemoved(const Tome::CustomType& type);
266 
271  void typeUpdated(const Tome::CustomType& type);
272 
273  private:
274  CustomTypeSetList* model;
275 
276  void addCustomType(CustomType customType, const QString& customTypeSetName);
277  CustomType* getCustomTypeByName(const QString& name) const;
278  void moveCustomTypeToSet(const QString& customTypeName, const QString& customTypeSetName);
279  void renameType(const QString oldName, const QString newName);
280  };
281 }
282 
283 #endif // TYPESCONTROLLER_H
Definition: commandlineoptions.h:6
const QStringList getCustomTypeSetNames() const
Gets a list of the names of all custom type sets in the project.
Definition: typescontroller.cpp:116
const CustomType addList(const QString &name, const QString &itemType, const QString &customTypeSetName)
Adds a new list type to the specified set.
Definition: typescontroller.cpp:45
void updateList(const QString &oldName, const QString &newName, const QString &itemType, const QString &typeSetName)
Updates the properties of the specified list type.
Definition: typescontroller.cpp:284
void updateMap(const QString &oldName, const QString &newName, const QString &keyType, const QString &valueType, const QString &typeSetName)
Updates the properties of the specified map type.
Definition: typescontroller.cpp:313
void typeUpdated(const Tome::CustomType &type)
The properties of a custom type have been updated.
void typeRenamed(const QString &oldName, const QString &newName)
A custom type has ben renamed.
void updateDerivedType(const QString &oldName, const QString &newName, const QString &baseType, const QVariantMap facets, const QString &typeSetName)
Updates the properties of the specified derived type.
Definition: typescontroller.cpp:225
const CustomType addMap(const QString &name, const QString &keyType, const QString &valueType, const QString &customTypeSetName)
Adds a new map type to the specified set.
Definition: typescontroller.cpp:58
void setCustomTypes(CustomTypeSetList &model)
Uses the specified list of custom type sets as model for this controller.
Definition: typescontroller.cpp:220
bool isCustomType(const QString &name) const
Checks whether the project has a custom type with the specified name.
Definition: typescontroller.cpp:149
const CustomType addEnumeration(const QString &name, const QStringList &enumeration, const QString &customTypeSetName)
Adds a new enumeration type to the specified set.
Definition: typescontroller.cpp:32
QString valueToString(const QVariant &value, const QString &typeName) const
Converts the specified value to a human-readable string.
Definition: typescontroller.cpp:343
void updateEnumeration(const QString &oldName, const QString &newName, const QStringList &enumeration, const QString &typeSetName)
Updates the properties of the specified enumeration.
Definition: typescontroller.cpp:255
Controller for adding, updating and removing custom types.
Definition: typescontroller.h:14
const CustomType & getCustomType(const QString &name) const
Gets the custom type with the specified name.
Definition: typescontroller.cpp:89
void typeAdded(const Tome::CustomType &type)
A new custom type has been added to the project.
bool isBuiltInType(const QString &name) const
Checks whether the specified name denotes a built-in type of Tome.
Definition: typescontroller.cpp:144
const QStringList getBuiltInTypes() const
Gets a list of built-in (i.e. non-custom) types of Tome.
Definition: typescontroller.cpp:72
const QStringList getTypeNames() const
Gets a list of all type names of this project, including built-in types.
Definition: typescontroller.cpp:129
void removeCustomType(const QString &typeName)
Removes the custom type with the specified name from the project.
Definition: typescontroller.cpp:181
const CustomTypeSetList & getCustomTypeSets() const
Gets a list of all custom type sets in the project.
Definition: typescontroller.cpp:111
User-defined type of any field.
Definition: customtype.h:14
bool isTypeOrDerivedFromType(const QString &lhs, const QString &rhs) const
Checks whether the first specified type is equal to or derived from the second specified type...
Definition: typescontroller.cpp:165
const CustomTypeList getCustomTypes() const
Gets a list of all custom types in the project.
Definition: typescontroller.cpp:94
Named set of Tome custom types.
Definition: customtypeset.h:11
void removeCustomTypeSet(const QString &name)
Removes the custom type set with the specified name from the project, including all custom types...
Definition: typescontroller.cpp:205
const CustomType addDerivedType(const QString &name, const QString &baseType, const QVariantMap &facets, const QString &customTypeSetName)
Adds a new derived type to the specified set.
Definition: typescontroller.cpp:18
void typeRemoved(const Tome::CustomType &type)
A custom type has been removed from the project.
void addCustomTypeSet(const CustomTypeSet &customTypeSet)
Adds the passed custom type set to the project.
Definition: typescontroller.cpp:13