Tome
A generic data editor for games supporting arbitrary input and output formats.
Signals | Public Member Functions | List of all members
Tome::TypesController Class Reference

Controller for adding, updating and removing custom types. More...

#include <typescontroller.h>

Inheritance diagram for Tome::TypesController:

Signals

void typeAdded (const Tome::CustomType &type)
 A new custom type has been added to the project. More...
 
void typeRenamed (const QString &oldName, const QString &newName)
 A custom type has ben renamed. More...
 
void typeRemoved (const Tome::CustomType &type)
 A custom type has been removed from the project. More...
 
void typeUpdated (const Tome::CustomType &type)
 The properties of a custom type have been updated. More...
 

Public Member Functions

void addCustomTypeSet (const CustomTypeSet &customTypeSet)
 Adds the passed custom type set to the project. More...
 
const CustomType addDerivedType (const QString &name, const QString &baseType, const QVariantMap &facets, const QString &customTypeSetName)
 Adds a new derived type to the specified set. More...
 
const CustomType addEnumeration (const QString &name, const QStringList &enumeration, const QString &customTypeSetName)
 Adds a new enumeration type to the specified set. More...
 
const CustomType addList (const QString &name, const QString &itemType, const QString &customTypeSetName)
 Adds a new list type to the specified set. More...
 
const CustomType addMap (const QString &name, const QString &keyType, const QString &valueType, const QString &customTypeSetName)
 Adds a new map type to the specified set. More...
 
const QStringList getBuiltInTypes () const
 Gets a list of built-in (i.e. non-custom) types of Tome. More...
 
const CustomTypegetCustomType (const QString &name) const
 Gets the custom type with the specified name. More...
 
const CustomTypeList getCustomTypes () const
 Gets a list of all custom types in the project. More...
 
const CustomTypeSetList & getCustomTypeSets () const
 Gets a list of all custom type sets in the project. More...
 
const QStringList getCustomTypeSetNames () const
 Gets a list of the names of all custom type sets in the project. More...
 
const QStringList getTypeNames () const
 Gets a list of all type names of this project, including built-in types. More...
 
bool isBuiltInType (const QString &name) const
 Checks whether the specified name denotes a built-in type of Tome. More...
 
bool isCustomType (const QString &name) const
 Checks whether the project has a custom type with the specified name. More...
 
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. More...
 
void removeCustomType (const QString &typeName)
 Removes the custom type with the specified name from the project. More...
 
void removeCustomTypeSet (const QString &name)
 Removes the custom type set with the specified name from the project, including all custom types. More...
 
void setCustomTypes (CustomTypeSetList &model)
 Uses the specified list of custom type sets as model for this controller. More...
 
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. More...
 
void updateEnumeration (const QString &oldName, const QString &newName, const QStringList &enumeration, const QString &typeSetName)
 Updates the properties of the specified enumeration. More...
 
void updateList (const QString &oldName, const QString &newName, const QString &itemType, const QString &typeSetName)
 Updates the properties of the specified list type. More...
 
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. More...
 
QString valueToString (const QVariant &value, const QString &typeName) const
 Converts the specified value to a human-readable string. More...
 

Detailed Description

Controller for adding, updating and removing custom types.

Member Function Documentation

◆ addCustomTypeSet()

void TypesController::addCustomTypeSet ( const CustomTypeSet customTypeSet)

Adds the passed custom type set to the project.

Parameters
customTypeSetCustom type set to add.

◆ addDerivedType()

const CustomType TypesController::addDerivedType ( const QString &  name,
const QString &  baseType,
const QVariantMap &  facets,
const QString &  customTypeSetName 
)

Adds a new derived type to the specified set.

Exceptions
std::out_of_rangeif the custom type set could not be found.
Parameters
nameName of the type to add.
baseTypeName of the base type of the type to add.
facetsFacet values of the type to add.
customTypeSetNameName of the type set to add the new type to.
Returns
Copy of the added custom type.

◆ addEnumeration()

const CustomType TypesController::addEnumeration ( const QString &  name,
const QStringList &  enumeration,
const QString &  customTypeSetName 
)

Adds a new enumeration type to the specified set.

Exceptions
std::out_of_rangeif the custom type set could not be found.
Parameters
nameName of the enumeration to add.
enumerationItems of the enumeration to add.
customTypeSetNameName of the type set to add the new enumeration to.
Returns
Copy of the added enumeration.

◆ addList()

const CustomType TypesController::addList ( const QString &  name,
const QString &  itemType,
const QString &  customTypeSetName 
)

Adds a new list type to the specified set.

Exceptions
std::out_of_rangeif the custom type set could not be found.
Parameters
nameName of the list type to add.
itemTypeType of the items of the list type to add.
customTypeSetNameName of the type set to add the new list type to.
Returns
Copy of the added list type.

◆ addMap()

const CustomType TypesController::addMap ( const QString &  name,
const QString &  keyType,
const QString &  valueType,
const QString &  customTypeSetName 
)

Adds a new map type to the specified set.

Exceptions
std::out_of_rangeif the custom type set could not be found.
Parameters
nameName of the map type to add.
keyTypeType of the keys of the map type to add.
valueTypeType of the values of the map type to add.
customTypeSetNameName of the type set to add the new map type to.
Returns
Copy of the added map type.

◆ getBuiltInTypes()

const QStringList TypesController::getBuiltInTypes ( ) const

Gets a list of built-in (i.e. non-custom) types of Tome.

Returns
List of all built-in types of Tome.

◆ getCustomType()

const CustomType & TypesController::getCustomType ( const QString &  name) const

Gets the custom type with the specified name.

Exceptions
std::out_of_rangeif the custom type with the specified name could not be found.
See also
isCustomType for checking whether a custom type with the specified name exists.
Parameters
nameName of the type to get.
Returns
Custom type with the specified name.

◆ getCustomTypes()

const CustomTypeList TypesController::getCustomTypes ( ) const

Gets a list of all custom types in the project.

Returns
List of all custom types in the project.

◆ getCustomTypeSetNames()

const QStringList TypesController::getCustomTypeSetNames ( ) const

Gets a list of the names of all custom type sets in the project.

Returns
List of the names of all custom type sets in the project.

◆ getCustomTypeSets()

const CustomTypeSetList & TypesController::getCustomTypeSets ( ) const

Gets a list of all custom type sets in the project.

Returns
List of all custom type sets in the project.

◆ getTypeNames()

const QStringList TypesController::getTypeNames ( ) const

Gets a list of all type names of this project, including built-in types.

Returns
List containing the names of all types avaialable in this project.

◆ isBuiltInType()

bool TypesController::isBuiltInType ( const QString &  name) const

Checks whether the specified name denotes a built-in type of Tome.

Parameters
nameName of the type to check.
Returns
true, if the specified name denotes a built-in type of Tome, and false otherwise.

◆ isCustomType()

bool TypesController::isCustomType ( const QString &  name) const

Checks whether the project has a custom type with the specified name.

Parameters
nameName of the custom type to look for.
Returns
true, if a custom type with the specified name exists, and false otherwise.

◆ isTypeOrDerivedFromType()

bool TypesController::isTypeOrDerivedFromType ( const QString &  lhs,
const QString &  rhs 
) const

Checks whether the first specified type is equal to or derived from the second specified type.

Parameters
lhsName of the type to check.
rhsPossible equal or base type.
Returns
true, if the first specified type is equal to or derived from the second specified type, and false otherwise.

◆ removeCustomType()

void TypesController::removeCustomType ( const QString &  typeName)

Removes the custom type with the specified name from the project.

Parameters
typeNameName of the custom type to remove.

◆ removeCustomTypeSet()

void TypesController::removeCustomTypeSet ( const QString &  name)

Removes the custom type set with the specified name from the project, including all custom types.

Parameters
nameName of the custom type set to remove.

◆ setCustomTypes()

void TypesController::setCustomTypes ( CustomTypeSetList &  model)

Uses the specified list of custom type sets as model for this controller.

Parameters
modelNew list of custom type sets to use as model for this controller.

◆ typeAdded

void Tome::TypesController::typeAdded ( const Tome::CustomType type)
signal

A new custom type has been added to the project.

Parameters
typeNew custom type.

◆ typeRemoved

void Tome::TypesController::typeRemoved ( const Tome::CustomType type)
signal

A custom type has been removed from the project.

Parameters
typeCustom type that has been removed from the project.

◆ typeRenamed

void Tome::TypesController::typeRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

A custom type has ben renamed.

Parameters
oldNamePrevious name of the custom type.
newNameNew name of the custom type.

◆ typeUpdated

void Tome::TypesController::typeUpdated ( const Tome::CustomType type)
signal

The properties of a custom type have been updated.

Parameters
typeCustom type that has been updated.

◆ updateDerivedType()

void TypesController::updateDerivedType ( const QString &  oldName,
const QString &  newName,
const QString &  baseType,
const QVariantMap  facets,
const QString &  typeSetName 
)

Updates the properties of the specified derived type.

Exceptions
std::out_of_rangeif the custom type with the specified name could not be found.
See also
isCustomType for checking whether a custom type with the specified name exists.
Parameters
oldNameCurrent name of the derived type to update.
newNameNew name of the derived type to update.
baseTypeName of the new base type of the type to update.
facetsNew facet values of the type to update.
typeSetNameName of the new type set the derived type should belong to.

◆ updateEnumeration()

void TypesController::updateEnumeration ( const QString &  oldName,
const QString &  newName,
const QStringList &  enumeration,
const QString &  typeSetName 
)

Updates the properties of the specified enumeration.

Exceptions
std::out_of_rangeif the custom type with the specified name could not be found.
See also
isCustomType for checking whether a custom type with the specified name exists.
Parameters
oldNameCurrent name of the enumeration to update.
newNameNew name of the enumeration to update.
enumerationNew items of the enumeration to update.
typeSetNameName of the new type set the enumeration should belong to.

◆ updateList()

void TypesController::updateList ( const QString &  oldName,
const QString &  newName,
const QString &  itemType,
const QString &  typeSetName 
)

Updates the properties of the specified list type.

Exceptions
std::out_of_rangeif the custom type with the specified name could not be found.
See also
isCustomType for checking whether a custom type with the specified name exists.
Parameters
oldNameCurrent name of the list type to update.
newNameNew name of the list type to update.
itemTypeNew type of the items of the list type to update.
typeSetNameName of the new type set the list type should belong to.

◆ updateMap()

void TypesController::updateMap ( const QString &  oldName,
const QString &  newName,
const QString &  keyType,
const QString &  valueType,
const QString &  typeSetName 
)

Updates the properties of the specified map type.

Exceptions
std::out_of_rangeif the custom type with the specified name could not be found.
See also
isCustomType for checking whether a custom type with the specified name exists.
Parameters
oldNameCurrent name of the map type to update.
newNameNew name of the map type to update.
keyTypeNew type of the keys of the map type to update.
valueTypeNew type of the values of the map type to update.
typeSetNameName of the new type set the map type should belong to.

◆ valueToString()

QString TypesController::valueToString ( const QVariant &  value,
const QString &  typeName 
) const

Converts the specified value to a human-readable string.

Parameters
valueValue to convert.
typeNameName of the type of the value.
Returns
Human-readable string representation of the specified value.

The documentation for this class was generated from the following files: