CuteLogger
Fast and simple logging solution for Qt based applications
mltxmlchecker.h
1/*
2 * Copyright (c) 2014-2025 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 isCorrected() const { return m_isCorrected; }
47 bool isUpdated() const { return m_isUpdated; }
48 QTemporaryFile &tempFile() const { return *m_tempFile; }
49 QStandardItemModel &unlinkedFilesModel() { return m_unlinkedFilesModel; }
50 QString shotcutVersion() const { return m_shotcutVersion; }
51
52private:
53 typedef QPair<QString, QString> MltProperty;
54
55 void readMlt();
56 void processProperties();
57 void checkInAndOutPoints();
58 bool checkNumericString(QString &value);
59 bool fixWebVfxPath(QString &resource);
60 bool readResourceProperty(const QString &name, QString &value);
61 void checkGpuEffects(const QString &mlt_service);
62 void checkCpuEffects(const QString &mlt_service);
63 void checkUnlinkedFile(const QString &mlt_service);
64 bool fixUnlinkedFile(QString &value);
65 void fixStreamIndex(MltProperty &property);
66 bool fixVersion1701WindowsPathBug(QString &value);
67 void checkIncludesSelf(QVector<MltProperty> &properties);
68 void checkLumaAlphaOver(const QString &mlt_service, QVector<MltProperty> &properties);
69 void checkAudioGain(const QString &mlt_service, QVector<MltProperty> &properties);
70 void replaceWebVfxCropFilters(QString &mlt_service, QVector<MltProperty> &properties);
71 void replaceWebVfxChoppyFilter(QString &mlt_service, QVector<MltProperty> &properties);
72 void checkForProxy(const QString &mlt_service, QVector<MltProperty> &properties);
73 bool checkMltVersion();
74
75 QXmlStreamReader m_xml;
76 QXmlStreamWriter m_newXml;
77 bool m_needsGPU;
78 bool m_needsCPU;
79 bool m_hasEffects;
80 bool m_isCorrected;
81 bool m_isUpdated;
82 QChar m_decimalPoint;
83 QScopedPointer<QTemporaryFile> m_tempFile;
84 bool m_numericValueChanged;
85 QFileInfo m_fileInfo;
86 QStandardItemModel m_unlinkedFilesModel;
87 QString mlt_class;
88 QVector<MltProperty> m_properties;
89 struct MltXmlResource
90 {
91 QFileInfo info;
92 QString hash;
93 QString newHash;
94 QString newDetail;
95 QString prefix;
96 QString suffix;
97 int audio_index, video_index;
98 bool isProxy;
99 bool notProxyMeta;
100
101 void clear()
102 {
103 info.setFile(QString());
104 hash.clear();
105 newHash.clear();
106 newDetail.clear();
107 prefix.clear();
108 suffix.clear();
109 audio_index = video_index = -1;
110 isProxy = false;
111 notProxyMeta = false;
112 }
113 } m_resource;
114 QVersionNumber m_mltVersion;
115 QString m_shotcutVersion;
116};
117
118#endif // MLTXMLCHECKER_H