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

Controller for exporting records using templates. More...

#include <exportcontroller.h>

Inheritance diagram for Tome::ExportController:

Signals

void exportTemplatesChanged ()
 Available record export templates have changed.
 
void progressChanged (const QString title, const QString text, const int currentValue, const int maximumValue) const
 Progress of the current record export operation has changed. More...
 

Public Member Functions

 ExportController (const FacetsController &facetsController, const FieldDefinitionsController &fieldDefinitionsController, const RecordsController &recordsController, const TypesController &typesController)
 Constructs a new controller for exporting records using templates. More...
 
void addRecordExportTemplate (const RecordExportTemplate &exportTemplate)
 Adds a new template for exporting records to the project. More...
 
const RecordExportTemplate getRecordExportTemplate (const QString &name) const
 Gets the record export template with the specified name. More...
 
const RecordExportTemplateList getRecordExportTemplates () const
 Gets a list of all available record export templates of the project. More...
 
bool hasRecordExportTemplate (const QString &name) const
 Checks whether the project has a record export template with the specified name. More...
 
void exportRecords (const RecordExportTemplate &exportTemplate, const QString &filePath) const
 Exports all records using the passed export template to a file at the specified path. More...
 
void exportRecords (const RecordExportTemplate &exportTemplate, QIODevice &device) const
 Exports all records using the passed export template to the specified device. More...
 
bool removeExportTemplate (const QString &name)
 Removes the record export template with the specified name from the project. More...
 
void setRecordExportTemplates (RecordExportTemplateList &exportTemplates)
 Uses the specified list of record export templates as model for this controller. More...
 

Detailed Description

Controller for exporting records using templates.

Constructor & Destructor Documentation

◆ ExportController()

ExportController::ExportController ( const FacetsController facetsController,
const FieldDefinitionsController fieldDefinitionsController,
const RecordsController recordsController,
const TypesController typesController 
)

Constructs a new controller for exporting records using templates.

Parameters
facetsControllerController for validating type facets.
fieldDefinitionsControllerController for adding, updating and removing field definitions.
recordsControllerController for adding, updating and removing records.
typesControllerController for adding, updating and removing custom types.

Member Function Documentation

◆ addRecordExportTemplate()

void ExportController::addRecordExportTemplate ( const RecordExportTemplate exportTemplate)

Adds a new template for exporting records to the project.

Parameters
exportTemplateRecord export template to add.

◆ exportRecords() [1/2]

void ExportController::exportRecords ( const RecordExportTemplate exportTemplate,
const QString &  filePath 
) const

Exports all records using the passed export template to a file at the specified path.

Exceptions
std::runtime_errorif the file at the specified path could not be written.
Parameters
exportTemplateTemplate to apply when exporting the records.
filePathPath of the file to write the exported data to.

◆ exportRecords() [2/2]

void ExportController::exportRecords ( const RecordExportTemplate exportTemplate,
QIODevice &  device 
) const

Exports all records using the passed export template to the specified device.

Parameters
exportTemplateTemplate to apply when exporting the records.
deviceDevice to write the exported data to.

◆ getRecordExportTemplate()

const RecordExportTemplate ExportController::getRecordExportTemplate ( const QString &  name) const

Gets the record export template with the specified name.

Exceptions
std::out_of_rangeif the export template could not be found.
See also
hasRecordExportTemplate for checking whether a record export template exists.
Parameters
nameName of the record export template to get.
Returns
Record export template with the specified name.

◆ getRecordExportTemplates()

const RecordExportTemplateList ExportController::getRecordExportTemplates ( ) const

Gets a list of all available record export templates of the project.

Returns
List of all available record export templates of the project.

◆ hasRecordExportTemplate()

bool ExportController::hasRecordExportTemplate ( const QString &  name) const

Checks whether the project has a record export template with the specified name.

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

◆ progressChanged

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

Progress of the current record export operation has changed.

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

◆ removeExportTemplate()

bool ExportController::removeExportTemplate ( const QString &  name)

Removes the record export template with the specified name from the project.

Parameters
nameName of the record export template to remove.
Returns
true, if the export template has been removed, and false otherwise.

◆ setRecordExportTemplates()

void ExportController::setRecordExportTemplates ( RecordExportTemplateList &  exportTemplates)

Uses the specified list of record export templates as model for this controller.

Parameters
exportTemplatesNew list of record export templates to use as model for this controller.

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