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