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 <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 replaceWebVfxCropFilters(QString &mlt_service, QVector<MltProperty> &properties);
70 void replaceWebVfxChoppyFilter(QString &mlt_service, QVector<MltProperty> &properties);
71 void checkForProxy(const QString &mlt_service, QVector<MltProperty> &properties);
72 bool checkMltVersion();
73
74 QXmlStreamReader m_xml;
75 QXmlStreamWriter m_newXml;
76 bool m_needsGPU;
77 bool m_needsCPU;
78 bool m_hasEffects;
79 bool m_isCorrected;
80 bool m_isUpdated;
81 QChar m_decimalPoint;
82 QScopedPointer<QTemporaryFile> m_tempFile;
83 bool m_numericValueChanged;
84 QFileInfo m_fileInfo;
85 QStandardItemModel m_unlinkedFilesModel;
86 QString mlt_class;
87 QVector<MltProperty> m_properties;
88 struct MltXmlResource
89 {
90 QFileInfo info;
91 QString hash;
92 QString newHash;
93 QString newDetail;
94 QString prefix;
95 QString suffix;
96 int audio_index, video_index;
97 bool isProxy;
98 bool notProxyMeta;
99
100 void clear()
101 {
102 info.setFile(QString());
103 hash.clear();
104 newHash.clear();
105 newDetail.clear();
106 prefix.clear();
107 suffix.clear();
108 audio_index = video_index = -1;
109 isProxy = false;
110 notProxyMeta = false;
111 }
112 } m_resource;
113 QVersionNumber m_mltVersion;
114 QString m_shotcutVersion;
115};
116
117#endif // MLTXMLCHECKER_H