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 hasEffects() const { return m_hasEffects; }
52  bool isCorrected() const { return m_isCorrected; }
53  QString tempFileName() const { return m_tempFile.fileName(); }
54  QStandardItemModel& unlinkedFilesModel() { return m_unlinkedFilesModel; }
55 
56 private:
57  void readMlt();
58  void processProperties();
59  void checkInAndOutPoints();
60  bool checkNumericString(QString& value);
61  bool fixWebVfxPath(QString& resource);
62  bool readResourceProperty(const QString& name, QString& value);
63  void checkGpuEffects(const QString& mlt_service);
64  void checkUnlinkedFile(const QString& mlt_service);
65  bool fixUnlinkedFile(QString& value);
66  void fixStreamIndex(QString& value);
67  bool fixVersion1701WindowsPathBug(QString& value);
68 
69  QXmlStreamReader m_xml;
70  QXmlStreamWriter m_newXml;
71  bool m_needsGPU;
72  bool m_hasEffects;
73  bool m_isCorrected;
74  QChar m_decimalPoint;
75  QTemporaryFile m_tempFile;
76  bool m_numericValueChanged;
77  QString m_basePath;
78  QStandardItemModel m_unlinkedFilesModel;
79  typedef QPair<QString, QString> MltProperty;
80  QString mlt_class;
81  QVector<MltProperty> m_properties;
82  struct MltXmlResource {
83  QFileInfo info;
84  QString hash;
85  QString newHash;
86  QString newDetail;
87  QString prefix;
88 
89  void clear() {
90  info.setFile(QString());
91  hash.clear();
92  newHash.clear();
93  newDetail.clear();
94  prefix.clear();
95  }
96  } m_resource;
97 };
98 
99 #endif // MLTXMLCHECKER_H