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

Controller for creating, loading and saving projects. More...

#include <projectcontroller.h>

Inheritance diagram for Tome::ProjectController:

Signals

void progressChanged (const QString title, const QString text, const int currentValue, const int maximumValue)
 Progress of the current project operation has changed. More...
 
void projectChanged (QSharedPointer< Tome::Project > project)
 Current project has changed (e.g. newly created or loaded from disk). More...
 

Public Member Functions

 ProjectController ()
 Constructs a new controller for creating, loading and saving projects.
 
QString buildFullFilePath (QString filePath, QString projectPath, QString desiredExtension) const
 Ensures the specified file path is an absolute file path with the passed extension. More...
 
void createProject (const QString &projectName, const QString &projectPath, const Tome::RecordIdType::RecordIdType recordIdType)
 Creates a new project with the specified name and path and saves it to disk. More...
 
const QString getFullProjectPath () const
 Gets the absolute path of the current project, including project file name and extension. More...
 
const QString getProjectName () const
 Gets the name of the current project. More...
 
const QString getProjectPath () const
 Gets the absolute path of the current project, without project file name. More...
 
RecordIdType::RecordIdType getProjectRecordIdType () const
 Gets the type of the ids of the records of the current project. More...
 
bool getProjectIgnoreReadOnly () const
 Checks whether the current project allows to modify read-only data. More...
 
bool hasComponentSet (const QString &componentSetName) const
 Checks whether a component set with the specified name has already been added to the project. More...
 
bool hasCustomTypeSet (const QString &customTypeSetName) const
 Checks whether a custom type set with the specified name has already been added to the project. More...
 
bool hasExportTemplate (const QString &exportTemplatePath) const
 Checks whether an export template with the specified path has already been added to the project. More...
 
bool hasFieldDefinitionSet (const QString &fieldDefinitionSetName) const
 Checks whether a field definition set with the specified name has already been added to the project. More...
 
bool hasImportTemplate (const QString &importTemplatePath) const
 Checks whether an import template with the specified path has already been added to the project. More...
 
bool hasRecordSet (const QString &recordSetName) const
 Checks whether a record set with the specified name has already been added to the project. More...
 
bool isProjectLoaded () const
 Checks whether any project is loaded. More...
 
void loadComponentSet (const QString &projectPath, ComponentSet &componentSet) const
 Loads the specified component set from disk. More...
 
void loadCustomTypeSet (const QString &projectPath, CustomTypeSet &customTypeSet) const
 Loads the specified custom type set from disk. More...
 
void loadExportTemplate (const QString &projectPath, RecordExportTemplate &exportTemplate) const
 Loads the specified export template from disk. More...
 
void loadFieldDefinitionSet (const QString &projectPath, FieldDefinitionSet &fieldDefinitionSet) const
 Loads the specified field definition set from disk. More...
 
void loadImportTemplate (const QString &projectPath, RecordTableImportTemplate &importTemplate) const
 Loads the specified import template set from disk. More...
 
void loadRecordSet (const QString &projectPath, RecordSet &recordSet) const
 Loads the specified record set set from disk. More...
 
void openProject (const QString &projectFileName)
 Opens the specified project file. More...
 
void saveProject () const
 Saves the current project to disk, including all data and templates. More...
 

Static Public Attributes

static const QString ComponentFileExtension = ".tcomp"
 File extension of Tome component files, including the dot.
 
static const QString FieldDefinitionFileExtension = ".tfields"
 File extension of Tome field definition files, including the dot.
 
static const QString ProjectFileExtension = ".tproj"
 File extension of Tome project files, including the dot.
 
static const QString RecordExportComponentDelimiterExtension = ".texportcd"
 File extension of Tome record export component delimiter files, including the dot.
 
static const QString RecordExportComponentTemplateExtension = ".texportc"
 File extension of Tome record export component template files, including the dot.
 
static const QString RecordExportFieldValueTemplateExtension = ".texportv"
 File extension of Tome record export field value template files, including the dot.
 
static const QString RecordExportFieldValueDelimiterExtension = ".texportvd"
 File extension of Tome record export field value delimiter files, including the dot.
 
static const QString RecordExportListTemplateExtension = ".texportl"
 File extension of Tome record export list template files, including the dot.
 
static const QString RecordExportListItemTemplateExtension = ".texportli"
 File extension of Tome record export list item template files, including the dot.
 
static const QString RecordExportListItemDelimiterExtension = ".texportld"
 File extension of Tome record export list item delimiter files, including the dot.
 
static const QString RecordExportLocalizedFieldValueTemplateExtension = ".texportvloc"
 File extension of Tome record export localized field value template files, including the dot.
 
static const QString RecordExportMapTemplateExtension = ".texportm"
 File extension of Tome record export map template files, including the dot.
 
static const QString RecordExportMapItemTemplateExtension = ".texportmi"
 File extension of Tome record export map item template files, including the dot.
 
static const QString RecordExportMapItemDelimiterExtension = ".texportmd"
 File extension of Tome record export map item delimiter files, including the dot.
 
static const QString RecordExportRecordFileTemplateExtension = ".texportf"
 File extension of Tome record export record file template files, including the dot.
 
static const QString RecordExportRecordTemplateExtension = ".texportr"
 File extension of Tome record export record template files, including the dot.
 
static const QString RecordExportRecordDelimiterExtension = ".texportrd"
 File extension of Tome record export record delimiter files, including the dot.
 
static const QString RecordExportTemplateFileExtension = ".texport"
 File extension of Tome record export template files, including the dot.
 
static const QString RecordFileExtension = ".tdata"
 File extension of Tome record files, including the dot.
 
static const QString RecordImportTemplateFileExtension = ".timport"
 File extension of Tome import template files, including the dot.
 
static const QString TypeFileExtension = ".ttypes"
 File extension of Tome type files, including the dot.
 

Detailed Description

Controller for creating, loading and saving projects.

Member Function Documentation

◆ buildFullFilePath()

QString ProjectController::buildFullFilePath ( QString  filePath,
QString  projectPath,
QString  desiredExtension 
) const

Ensures the specified file path is an absolute file path with the passed extension.

Parameters
filePathFile path to convert.
projectPathAbsolute path to the current project, without file name.
desiredExtensionFile extension to add, if missing.
Returns
Specified file path as absolute file path with the passed extension.

◆ createProject()

void ProjectController::createProject ( const QString &  projectName,
const QString &  projectPath,
const Tome::RecordIdType::RecordIdType  recordIdType 
)

Creates a new project with the specified name and path and saves it to disk.

Parameters
projectNameName of the project to create.
projectPathPath to write the project files to.
recordIdTypeType of the ids of the records of the new project.

◆ getFullProjectPath()

const QString ProjectController::getFullProjectPath ( ) const

Gets the absolute path of the current project, including project file name and extension.

Returns
Absolute full path of the current project file.

◆ getProjectIgnoreReadOnly()

bool ProjectController::getProjectIgnoreReadOnly ( ) const

Checks whether the current project allows to modify read-only data.

Returns
true, if the current project allows to modify read-only data, and false otherwise.

◆ getProjectName()

const QString ProjectController::getProjectName ( ) const

Gets the name of the current project.

Returns
Name of the current project.

◆ getProjectPath()

const QString ProjectController::getProjectPath ( ) const

Gets the absolute path of the current project, without project file name.

Returns
Absolute path of the current project, without project file name.

◆ getProjectRecordIdType()

RecordIdType::RecordIdType ProjectController::getProjectRecordIdType ( ) const

Gets the type of the ids of the records of the current project.

Returns
Type of the ids of the records of the current project.

◆ hasComponentSet()

bool ProjectController::hasComponentSet ( const QString &  componentSetName) const

Checks whether a component set with the specified name has already been added to the project.

Parameters
componentSetNameName of the component set to check.
Returns
true, if a component set with the specified name has already been added to the project, and false otherwise.

◆ hasCustomTypeSet()

bool ProjectController::hasCustomTypeSet ( const QString &  customTypeSetName) const

Checks whether a custom type set with the specified name has already been added to the project.

Parameters
customTypeSetNameName of the custom type set to check.
Returns
true, if a custom type set with the specified name has already been added to the project, and false otherwise.

◆ hasExportTemplate()

bool ProjectController::hasExportTemplate ( const QString &  exportTemplatePath) const

Checks whether an export template with the specified path has already been added to the project.

Parameters
exportTemplatePathPath of the export template to check.
Returns
true, if an export template with the specified path has already been added to the project, and false otherwise.

◆ hasFieldDefinitionSet()

bool ProjectController::hasFieldDefinitionSet ( const QString &  fieldDefinitionSetName) const

Checks whether a field definition set with the specified name has already been added to the project.

Parameters
fieldDefinitionSetNameName of the field definition set to check.
Returns
true, if a field definition set with the specified name has already been added to the project, and false otherwise.

◆ hasImportTemplate()

bool ProjectController::hasImportTemplate ( const QString &  importTemplatePath) const

Checks whether an import template with the specified path has already been added to the project.

Parameters
importTemplatePathPath of the import template to check.
Returns
true, if an import template with the specified path has already been added to the project, and false otherwise.

◆ hasRecordSet()

bool ProjectController::hasRecordSet ( const QString &  recordSetName) const

Checks whether a record set with the specified name has already been added to the project.

Parameters
recordSetNameName of the record set to check.
Returns
true, if a record set with the specified name has already been added to the project, and false otherwise.

◆ isProjectLoaded()

bool ProjectController::isProjectLoaded ( ) const

Checks whether any project is loaded.

Returns
true, if any project is currently loaded, and false otherwise.

◆ loadComponentSet()

void ProjectController::loadComponentSet ( const QString &  projectPath,
ComponentSet componentSet 
) const

Loads the specified component set from disk.

Exceptions
std::runtime_errorif the component set file could not be read.
Parameters
projectPathAbsolute path to the project, without file name.
componentSetComponent set to load from disk.

◆ loadCustomTypeSet()

void ProjectController::loadCustomTypeSet ( const QString &  projectPath,
CustomTypeSet customTypeSet 
) const

Loads the specified custom type set from disk.

Exceptions
std::runtime_errorif the custom type set file could not be read.
Parameters
projectPathAbsolute path to the project, without file name.
customTypeSetCustom type set to load from disk.

◆ loadExportTemplate()

void ProjectController::loadExportTemplate ( const QString &  projectPath,
RecordExportTemplate exportTemplate 
) const

Loads the specified export template from disk.

Exceptions
std::runtime_errorif any of the export template files could not be read.
Parameters
projectPathAbsolute path to the project, without file name.
exportTemplateExport template to load from disk.

◆ loadFieldDefinitionSet()

void ProjectController::loadFieldDefinitionSet ( const QString &  projectPath,
FieldDefinitionSet fieldDefinitionSet 
) const

Loads the specified field definition set from disk.

Exceptions
std::runtime_errorif the field definition set file could not be read.
Parameters
projectPathAbsolute path to the project, without file name.
fieldDefinitionSetField definition set to load from disk.

◆ loadImportTemplate()

void ProjectController::loadImportTemplate ( const QString &  projectPath,
RecordTableImportTemplate importTemplate 
) const

Loads the specified import template set from disk.

Exceptions
std::runtime_errorif the import template file could not be read.
Parameters
projectPathAbsolute path to the project, without file name.
importTemplateImport template to load from disk.

◆ loadRecordSet()

void ProjectController::loadRecordSet ( const QString &  projectPath,
RecordSet recordSet 
) const

Loads the specified record set set from disk.

Exceptions
std::runtime_errorif the record set file could not be read.
Parameters
projectPathAbsolute path to the project, without file name.
recordSetRecord set to load from disk.

◆ openProject()

void ProjectController::openProject ( const QString &  projectFileName)

Opens the specified project file.

Exceptions
std::runtime_errorif the project file could not be read.
Parameters
projectFileNameName of the project file to open.

◆ progressChanged

void Tome::ProjectController::progressChanged ( const QString  title,
const QString  text,
const int  currentValue,
const int  maximumValue 
)
signal

Progress of the current project operation has changed.

Parameters
titleTitle of the current project operation step.
textDetails of the current project operation step.
currentValueCurrent progress value of the current project operation step.
maximumValueMaximum progress value of the current project operation step.

◆ projectChanged

void Tome::ProjectController::projectChanged ( QSharedPointer< Tome::Project project)
signal

Current project has changed (e.g. newly created or loaded from disk).

Parameters
projectCurrent project.

◆ saveProject()

void ProjectController::saveProject ( ) const

Saves the current project to disk, including all data and templates.

Exceptions
std::runtime_errorif any of the project files could not be written.

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