CuteLogger
Fast and simple logging solution for Qt based applications
mltxmlchecker.h
1/*
2 * Copyright (c) 2014-2023 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 QString shotcutVersion() const
79 {
80 return m_shotcutVersion;
81 }
82
83private:
84 typedef QPair<QString, QString> MltProperty;
85
86 void readMlt();
87 void processProperties();
88 void checkInAndOutPoints();
89 bool checkNumericString(QString &value);
90 bool fixWebVfxPath(QString &resource);
91 bool readResourceProperty(const QString &name, QString &value);
92 void checkGpuEffects(const QString &mlt_service);
93 void checkCpuEffects(const QString &mlt_service);
94 void checkUnlinkedFile(const QString &mlt_service);
95 bool fixUnlinkedFile(QString &value);
96 void fixStreamIndex(MltProperty &property);
97 bool fixVersion1701WindowsPathBug(QString &value);
98 void checkIncludesSelf(QVector<MltProperty> &properties);
99 void checkLumaAlphaOver(const QString &mlt_service, QVector<MltProperty> &properties);
100 void replaceWebVfxCropFilters(QString &mlt_service, QVector<MltProperty> &properties);
101 void replaceWebVfxChoppyFilter(QString &mlt_service, QVector<MltProperty> &properties);
102 void checkForProxy(const QString &mlt_service, QVector<MltProperty> &properties);
103 bool checkMltVersion();
104
105 QXmlStreamReader m_xml;
106 QXmlStreamWriter m_newXml;
107 bool m_needsGPU;
108 bool m_needsCPU;
109 bool m_hasEffects;
110 bool m_isCorrected;
111 bool m_isUpdated;
112 QChar m_decimalPoint;
113 QScopedPointer<QTemporaryFile> m_tempFile;
114 bool m_numericValueChanged;
115 QFileInfo m_fileInfo;
116 QStandardItemModel m_unlinkedFilesModel;
117 QString mlt_class;
118 QVector<MltProperty> m_properties;
119 struct MltXmlResource {
120 QFileInfo info;
121 QString hash;
122 QString newHash;
123 QString newDetail;
124 QString prefix;
125 QString suffix;
126 int audio_index, video_index;
127 bool isProxy;
128 bool notProxyMeta;
129
130 void clear()
131 {
132 info.setFile(QString());
133 hash.clear();
134 newHash.clear();
135 newDetail.clear();
136 prefix.clear();
137 suffix.clear();
138 audio_index = video_index = -1;
139 isProxy = false;
140 notProxyMeta = false;
141 }
142 } m_resource;
143 QVersionNumber m_mltVersion;
144 QString m_shotcutVersion;
145};
146
147#endif // MLTXMLCHECKER_H