CuteLogger
Fast and simple logging solution for Qt based applications
mltxmlchecker.h
1/*
2 * Copyright (c) 2014-2021 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#include <QVersionNumber>
30
31class QUIDevice;
32
33class MltXmlChecker
34{
35public:
36
37 enum {
38 ShotcutHashRole = Qt::UserRole + 1
39 };
40
41 enum {
42 MissingColumn = 0,
43 ReplacementColumn,
44 ColumnCount
45 };
46
47 MltXmlChecker();
48 QXmlStreamReader::Error check(const QString &fileName);
49 QString errorString() const;
50 bool needsGPU() const
51 {
52 return m_needsGPU;
53 }
54 bool needsCPU() const
55 {
56 return m_needsCPU;
57 }
58 bool hasEffects() const
59 {
60 return m_hasEffects;
61 }
62 bool isCorrected() const
63 {
64 return m_isCorrected;
65 }
66 bool isUpdated() const
67 {
68 return m_isUpdated;
69 }
70 QTemporaryFile &tempFile() const
71 {
72 return *m_tempFile;
73 }
74 QStandardItemModel &unlinkedFilesModel()
75 {
76 return m_unlinkedFilesModel;
77 }
78 void setLocale();
79 bool usesLocale() const
80 {
81 return m_usesLocale;
82 }
83 QString shotcutVersion() const
84 {
85 return m_shotcutVersion;
86 }
87
88private:
89 typedef QPair<QString, QString> MltProperty;
90
91 void readMlt();
92 void processProperties();
93 void checkInAndOutPoints();
94 bool checkNumericString(QString &value);
95 bool fixWebVfxPath(QString &resource);
96 bool readResourceProperty(const QString &name, QString &value);
97 void checkGpuEffects(const QString &mlt_service);
98 void checkCpuEffects(const QString &mlt_service);
99 void checkUnlinkedFile(const QString &mlt_service);
100 bool fixUnlinkedFile(QString &value);
101 void fixStreamIndex(MltProperty &property);
102 bool fixVersion1701WindowsPathBug(QString &value);
103 void checkIncludesSelf(QVector<MltProperty> &properties);
104 void checkLumaAlphaOver(const QString &mlt_service, QVector<MltProperty> &properties);
105 void replaceWebVfxCropFilters(QString &mlt_service, QVector<MltProperty> &properties);
106 void replaceWebVfxChoppyFilter(QString &mlt_service, QVector<MltProperty> &properties);
107 void checkForProxy(const QString &mlt_service, QVector<MltProperty> &properties);
108 bool checkMltVersion();
109
110 QXmlStreamReader m_xml;
111 QXmlStreamWriter m_newXml;
112 bool m_needsGPU;
113 bool m_needsCPU;
114 bool m_hasEffects;
115 bool m_isCorrected;
116 bool m_isUpdated;
117 bool m_usesLocale;
118 QChar m_decimalPoint;
119 QScopedPointer<QTemporaryFile> m_tempFile;
120 bool m_numericValueChanged;
121 QFileInfo m_fileInfo;
122 QStandardItemModel m_unlinkedFilesModel;
123 QString mlt_class;
124 QVector<MltProperty> m_properties;
125 struct MltXmlResource {
126 QFileInfo info;
127 QString hash;
128 QString newHash;
129 QString newDetail;
130 QString prefix;
131 QString suffix;
132 int audio_index, video_index;
133
134 void clear()
135 {
136 info.setFile(QString());
137 hash.clear();
138 newHash.clear();
139 newDetail.clear();
140 prefix.clear();
141 suffix.clear();
142 audio_index = video_index = -1;
143 }
144 } m_resource;
145 QVersionNumber m_mltVersion;
146 QString m_shotcutVersion;
147};
148
149#endif // MLTXMLCHECKER_H