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