CuteLogger
Fast and simple logging solution for Qt based applications
mltxmlchecker.h
1 /*
2  * Copyright (c) 2014-2019 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MLTXMLCHECKER_H
19 #define MLTXMLCHECKER_H
20 
21 #include <QXmlStreamReader>
22 #include <QXmlStreamWriter>
23 #include <QTemporaryFile>
24 #include <QString>
25 #include <QFileInfo>
26 #include <QStandardItemModel>
27 #include <QVector>
28 #include <QPair>
29 
30 class QUIDevice;
31 
32 class MltXmlChecker
33 {
34 public:
35 
36  enum {
37  ShotcutHashRole = Qt::UserRole + 1
38  };
39 
40  enum {
41  MissingColumn = 0,
42  ReplacementColumn,
43  ColumnCount
44  };
45 
46  MltXmlChecker();
47  bool check(const QString& fileName);
48  QString errorString() const;
49  bool needsGPU() const { return m_needsGPU; }
50  bool needsCPU() const { return m_needsCPU; }
51  bool hasEffects() const { return m_hasEffects; }
52  bool isCorrected() const { return m_isCorrected; }
53  bool isUpdated() const { return m_isUpdated; }
54  QString tempFileName() const { return m_tempFile->fileName(); }
55  QStandardItemModel& unlinkedFilesModel() { return m_unlinkedFilesModel; }
56  void setLocale();
57  bool usesLocale() const { return m_usesLocale; }
58 
59 private:
60  typedef QPair<QString, QString> MltProperty;
61 
62  void readMlt();
63  void processProperties();
64  void checkInAndOutPoints();
65  bool checkNumericString(QString& value);
66  bool fixWebVfxPath(QString& resource);
67  bool readResourceProperty(const QString& name, QString& value);
68  void checkGpuEffects(const QString& mlt_service);
69  void checkCpuEffects(const QString& mlt_service);
70  void checkUnlinkedFile(const QString& mlt_service);
71  bool fixUnlinkedFile(QString& value);
72  void fixStreamIndex(QString& value);
73  bool fixVersion1701WindowsPathBug(QString& value);
74  void checkIncludesSelf(QVector<MltProperty>& properties);
75  void checkLumaAlphaOver(const QString& mlt_service, QVector<MltProperty>& properties);
76 
77  QXmlStreamReader m_xml;
78  QXmlStreamWriter m_newXml;
79  bool m_needsGPU;
80  bool m_needsCPU;
81  bool m_hasEffects;
82  bool m_isCorrected;
83  bool m_isUpdated;
84  bool m_usesLocale;
85  QChar m_decimalPoint;
86  QScopedPointer<QTemporaryFile> m_tempFile;
87  bool m_numericValueChanged;
88  QFileInfo m_fileInfo;
89  QStandardItemModel m_unlinkedFilesModel;
90  QString mlt_class;
91  QVector<MltProperty> m_properties;
92  struct MltXmlResource {
93  QFileInfo info;
94  QString hash;
95  QString newHash;
96  QString newDetail;
97  QString prefix;
98 
99  void clear() {
100  info.setFile(QString());
101  hash.clear();
102  newHash.clear();
103  newDetail.clear();
104  prefix.clear();
105  }
106  } m_resource;
107 };
108 
109 #endif // MLTXMLCHECKER_H