Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • structure
filemanager.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#ifndef OBJECTSAVELOADER_H
19#define OBJECTSAVELOADER_H
20
21
22#include <QObject>
23#include <QString>
24#include <QDomElement>
25#include "log.h"
26#include "pencildef.h"
27#include "pencilerror.h"
28#include "colorref.h"
29#include "layer.h"
30
31class Object;
32class ObjectData;
33class QDir;
34
35
36class FileManager : public QObject
37{
38 Q_OBJECT
39
40public:
41 FileManager(QObject* parent = 0);
42
43 Object* load(const QString& sFilenNme);
44 Status save(const Object*, const QString& sFileName);
45 Status writeToWorkingFolder(const Object*);
46
47 QList<ColorRef> loadPaletteFile(QString strFilename);
48 Status error() const { return mError; }
49 Status verifyObject(Object* obj);
50
51 QStringList searchForUnsavedProjects();
52 Object* recoverUnsavedProject(QString projectIntermediatePath);
53
54signals:
55 void progressChanged(int progress);
56 void progressRangeChanged(int maxValue);
57
58private:
59 Status copyDir(const QDir src, const QDir dst);
60 Status unzip(const QString& strZipFile, const QString& strUnzipTarget);
61
62 bool loadObject(Object*, const QDomElement& root);
63 bool loadObjectOldWay(Object*, const QDomElement& root);
64 bool isArchiveFormat(const QString& fileName) const;
65 bool loadPalette(Object*);
66 Status writeKeyFrameFiles(const Object* obj, const QString& dataFolder, QStringList& filesWritten);
67 Status writeMainXml(const Object* obj, const QString& mainXmlPath, QStringList& filesWritten);
68 Status writePalette(const Object* obj, const QString& dataFolder, QStringList& filesWritten);
69
70 ObjectData loadProjectData(const QDomElement& element);
71 QDomElement saveProjectData(const ObjectData*, QDomDocument& xmlDoc);
72
73 void extractProjectData(const QDomElement& element, ObjectData& data);
74 void handleOpenProjectError(Status::ErrorCode, const DebugDetails&);
75
76 QString backupPreviousFile(const QString& fileName);
77 void deleteBackupFile(const QString& fileName);
78 int countExistingBackups(const QString& fileName) const;
79
80 void progressForward();
81
82private: // Project recovery
83 bool isProjectRecoverable(const QString& projectFolder);
84 Status recoverObject(Object* object);
85 Status rebuildMainXML(Object* object);
86 Status rebuildLayerXmlTag(QDomDocument& doc, QDomElement& elemObject,
87 const int layerIndex, const QStringList& frames);
88 QString recoverLayerName(Layer::LAYER_TYPE, int index);
89 int layerIndexFromFilename(const QString& filename);
90 int framePosFromFilename(const QString& filename);
91
92private:
93 Status mError = Status::OK;
94 QString mstrLastTempFolder;
95
96 int mCurrentProgress = 0;
97 int mMaxProgressValue = 100;
98};
99
100#endif // OBJECTSAVELOADER_H
DebugDetails
Definition: pencilerror.h:25
FileManager
Definition: filemanager.h:37
FileManager::rebuildMainXML
Status rebuildMainXML(Object *object)
Create a new main.xml based on the png/vec filenames left in the data folder.
Definition: filemanager.cpp:971
FileManager::copyDir
Status copyDir(const QDir src, const QDir dst)
Copy a directory to another directory recursively (depth-first).
Definition: filemanager.cpp:775
FileManager::rebuildLayerXmlTag
Status rebuildLayerXmlTag(QDomDocument &doc, QDomElement &elemObject, const int layerIndex, const QStringList &frames)
Rebuild a layer xml tag.
Definition: filemanager.cpp:1033
ObjectData
Definition: objectdata.h:27
Object
Definition: object.h:42
Status
Definition: pencilerror.h:40
QDir
QDomDocument
QDomElement
QList
QObject
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::parent
QObject * parent() const const
QString
QStringList
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39