Tome
A generic data editor for games supporting arbitrary input and output formats.
projectcontroller.h
1 #ifndef PROJECTCONTROLLER_H
2 #define PROJECTCONTROLLER_H
3 
4 #include <QSharedPointer>
5 
6 #include "../Model/recordidtype.h"
7 
8 namespace Tome
9 {
10  class ComponentSet;
11  class CustomTypeSet;
12  class FieldDefinitionSet;
13  class Project;
14  class RecordExportTemplate;
15  class RecordSet;
16  class RecordSetSerializer;
17  class RecordTableImportTemplate;
18 
22  class ProjectController : public QObject
23  {
24  Q_OBJECT
25 
26  public:
30  static const QString ComponentFileExtension;
31 
35  static const QString FieldDefinitionFileExtension;
36 
40  static const QString ProjectFileExtension;
41 
46 
51 
56 
61 
65  static const QString RecordExportListTemplateExtension;
66 
71 
76 
81 
85  static const QString RecordExportMapTemplateExtension;
86 
91 
96 
101 
106 
111 
115  static const QString RecordExportTemplateFileExtension;
116 
120  static const QString RecordFileExtension;
121 
125  static const QString RecordImportTemplateFileExtension;
126 
130  static const QString TypeFileExtension;
131 
137 
145  QString buildFullFilePath(QString filePath, QString projectPath, QString desiredExtension) const;
146 
153  void createProject(const QString& projectName, const QString& projectPath, const Tome::RecordIdType::RecordIdType recordIdType);
154 
159  const QString getFullProjectPath() const;
160 
165  const QString getProjectName() const;
166 
171  const QString getProjectPath() const;
172 
177  RecordIdType::RecordIdType getProjectRecordIdType() const;
178 
183  bool getProjectIgnoreReadOnly() const;
184 
190  bool hasComponentSet(const QString& componentSetName) const;
191 
197  bool hasCustomTypeSet(const QString& customTypeSetName) const;
198 
204  bool hasExportTemplate(const QString& exportTemplatePath) const;
205 
211  bool hasFieldDefinitionSet(const QString& fieldDefinitionSetName) const;
212 
218  bool hasImportTemplate(const QString& importTemplatePath) const;
219 
225  bool hasRecordSet(const QString& recordSetName) const;
226 
231  bool isProjectLoaded() const;
232 
241  void loadComponentSet(const QString& projectPath, ComponentSet& componentSet) const;
242 
251  void loadCustomTypeSet(const QString& projectPath, CustomTypeSet& customTypeSet) const;
252 
261  void loadExportTemplate(const QString& projectPath, RecordExportTemplate& exportTemplate) const;
262 
271  void loadFieldDefinitionSet(const QString& projectPath, FieldDefinitionSet& fieldDefinitionSet) const;
272 
281  void loadImportTemplate(const QString& projectPath, RecordTableImportTemplate& importTemplate) const;
282 
291  void loadRecordSet(const QString& projectPath, RecordSet& recordSet) const;
292 
300  void openProject(const QString& projectFileName);
301 
307  void saveProject() const;
308 
309  signals:
317  void progressChanged(const QString title, const QString text, const int currentValue, const int maximumValue);
318 
323  void projectChanged(QSharedPointer<Tome::Project> project);
324 
325  private slots:
326  void onProgressChanged(const QString title, const QString text, const int currentValue, const int maximumValue);
327 
328  private:
329  QSharedPointer<Project> project;
330 
331  RecordSetSerializer* recordSetSerializer;
332 
333  const QString getFullProjectPath(QSharedPointer<Project> project) const;
334  QString readFile(const QString& fullPath) const;
335  void saveProject(QSharedPointer<Project> project) const;
336  void setProject(QSharedPointer<Project> project);
337  };
338 }
339 
340 #endif // PROJECTCONTROLLER_H
Definition: commandlineoptions.h:6
void loadExportTemplate(const QString &projectPath, RecordExportTemplate &exportTemplate) const
Loads the specified export template from disk.
Definition: projectcontroller.cpp:299
const QString getProjectName() const
Gets the name of the current project.
Definition: projectcontroller.cpp:116
Named set of Tome components.
Definition: componentset.h:11
void loadCustomTypeSet(const QString &projectPath, CustomTypeSet &customTypeSet) const
Loads the specified custom type set from disk.
Definition: projectcontroller.cpp:265
bool hasFieldDefinitionSet(const QString &fieldDefinitionSetName) const
Checks whether a field definition set with the specified name has already been added to the project...
Definition: projectcontroller.cpp:181
static const QString RecordExportRecordDelimiterExtension
File extension of Tome record export record delimiter files, including the dot.
Definition: projectcontroller.h:110
static const QString RecordExportComponentDelimiterExtension
File extension of Tome record export component delimiter files, including the dot.
Definition: projectcontroller.h:45
void loadImportTemplate(const QString &projectPath, RecordTableImportTemplate &importTemplate) const
Loads the specified import template set from disk.
Definition: projectcontroller.cpp:416
static const QString RecordExportTemplateFileExtension
File extension of Tome record export template files, including the dot.
Definition: projectcontroller.h:115
Template for exporting record data.
Definition: recordexporttemplate.h:12
Named set of Tome records.
Definition: recordset.h:11
RecordIdType::RecordIdType getProjectRecordIdType() const
Gets the type of the ids of the records of the current project.
Definition: projectcontroller.cpp:126
bool hasComponentSet(const QString &componentSetName) const
Checks whether a component set with the specified name has already been added to the project...
Definition: projectcontroller.cpp:136
bool hasCustomTypeSet(const QString &customTypeSetName) const
Checks whether a custom type set with the specified name has already been added to the project...
Definition: projectcontroller.cpp:151
void projectChanged(QSharedPointer< Tome::Project > project)
Current project has changed (e.g. newly created or loaded from disk).
static const QString RecordExportRecordTemplateExtension
File extension of Tome record export record template files, including the dot.
Definition: projectcontroller.h:105
QString buildFullFilePath(QString filePath, QString projectPath, QString desiredExtension) const
Ensures the specified file path is an absolute file path with the passed extension.
Definition: projectcontroller.cpp:58
static const QString RecordExportFieldValueDelimiterExtension
File extension of Tome record export field value delimiter files, including the dot.
Definition: projectcontroller.h:60
bool isProjectLoaded() const
Checks whether any project is loaded.
Definition: projectcontroller.cpp:226
static const QString RecordExportFieldValueTemplateExtension
File extension of Tome record export field value template files, including the dot.
Definition: projectcontroller.h:55
bool getProjectIgnoreReadOnly() const
Checks whether the current project allows to modify read-only data.
Definition: projectcontroller.cpp:131
static const QString RecordImportTemplateFileExtension
File extension of Tome import template files, including the dot.
Definition: projectcontroller.h:125
static const QString RecordExportMapTemplateExtension
File extension of Tome record export map template files, including the dot.
Definition: projectcontroller.h:85
static const QString RecordExportMapItemDelimiterExtension
File extension of Tome record export map item delimiter files, including the dot. ...
Definition: projectcontroller.h:95
void openProject(const QString &projectFileName)
Opens the specified project file.
Definition: projectcontroller.cpp:482
static const QString RecordExportRecordFileTemplateExtension
File extension of Tome record export record file template files, including the dot.
Definition: projectcontroller.h:100
static const QString TypeFileExtension
File extension of Tome type files, including the dot.
Definition: projectcontroller.h:130
static const QString RecordFileExtension
File extension of Tome record files, including the dot.
Definition: projectcontroller.h:120
static const QString ProjectFileExtension
File extension of Tome project files, including the dot.
Definition: projectcontroller.h:40
static const QString RecordExportLocalizedFieldValueTemplateExtension
File extension of Tome record export localized field value template files, including the dot...
Definition: projectcontroller.h:80
void loadRecordSet(const QString &projectPath, RecordSet &recordSet) const
Loads the specified record set set from disk.
Definition: projectcontroller.cpp:450
Named set of Tome field definitions.
Definition: fielddefinitionset.h:13
void loadFieldDefinitionSet(const QString &projectPath, FieldDefinitionSet &fieldDefinitionSet) const
Loads the specified field definition set from disk.
Definition: projectcontroller.cpp:382
bool hasRecordSet(const QString &recordSetName) const
Checks whether a record set with the specified name has already been added to the project...
Definition: projectcontroller.cpp:211
const QString getFullProjectPath() const
Gets the absolute path of the current project, including project file name and extension.
Definition: projectcontroller.cpp:110
static const QString RecordExportListTemplateExtension
File extension of Tome record export list template files, including the dot.
Definition: projectcontroller.h:65
void saveProject() const
Saves the current project to disk, including all data and templates.
Definition: projectcontroller.cpp:566
static const QString FieldDefinitionFileExtension
File extension of Tome field definition files, including the dot.
Definition: projectcontroller.h:35
void loadComponentSet(const QString &projectPath, ComponentSet &componentSet) const
Loads the specified component set from disk.
Definition: projectcontroller.cpp:231
Controller for creating, loading and saving projects.
Definition: projectcontroller.h:22
static const QString ComponentFileExtension
File extension of Tome component files, including the dot.
Definition: projectcontroller.h:30
Named set of Tome custom types.
Definition: customtypeset.h:11
static const QString RecordExportComponentTemplateExtension
File extension of Tome record export component template files, including the dot. ...
Definition: projectcontroller.h:50
const QString getProjectPath() const
Gets the absolute path of the current project, without project file name.
Definition: projectcontroller.cpp:121
static const QString RecordExportMapItemTemplateExtension
File extension of Tome record export map item template files, including the dot.
Definition: projectcontroller.h:90
void progressChanged(const QString title, const QString text, const int currentValue, const int maximumValue)
Progress of the current project operation has changed.
bool hasExportTemplate(const QString &exportTemplatePath) const
Checks whether an export template with the specified path has already been added to the project...
Definition: projectcontroller.cpp:166
static const QString RecordExportListItemDelimiterExtension
File extension of Tome record export list item delimiter files, including the dot.
Definition: projectcontroller.h:75
Template for importing record data.
Definition: recordtableimporttemplate.h:15
Reads and writes records from any device.
Definition: recordsetserializer.h:13
static const QString RecordExportListItemTemplateExtension
File extension of Tome record export list item template files, including the dot. ...
Definition: projectcontroller.h:70
ProjectController()
Constructs a new controller for creating, loading and saving projects.
Definition: projectcontroller.cpp:42
bool hasImportTemplate(const QString &importTemplatePath) const
Checks whether an import template with the specified path has already been added to the project...
Definition: projectcontroller.cpp:196
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.
Definition: projectcontroller.cpp:73