1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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 2 of the License, or *
7 * (at your option) any later version. *
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. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "documentchecker.h"
23 #include "docclipbase.h"
24 #include "titlewidget.h"
25 #include "definitions.h"
26 #include "kdenlivesettings.h"
29 #include <KGlobalSettings>
31 #include <KIO/NetAccess>
32 #include <KFileDialog>
33 #include <KApplication>
34 #include <KUrlRequesterDialog>
35 #include <KMessageBox>
37 #include <QTreeWidgetItem>
39 #include <QHeaderView>
43 #include <QCryptographicHash>
45 const int hashRole = Qt::UserRole;
46 const int sizeRole = Qt::UserRole + 1;
47 const int idRole = Qt::UserRole + 2;
48 const int statusRole = Qt::UserRole + 3;
49 const int typeRole = Qt::UserRole + 4;
50 const int typeOriginalResource = Qt::UserRole + 5;
52 const int CLIPMISSING = 0;
54 const int CLIPPLACEHOLDER = 2;
55 const int CLIPWRONGDURATION = 3;
56 const int PROXYMISSING = 4;
58 const int LUMAMISSING = 10;
59 const int LUMAOK = 11;
60 const int LUMAPLACEHOLDER = 12;
62 enum TITLECLIPTYPE { TITLE_IMAGE_ELEMENT = 20, TITLE_FONT_ELEMENT = 21 };
64 DocumentChecker::DocumentChecker(QDomNodeList infoproducers, QDomDocument doc):
65 m_info(infoproducers), m_doc(doc), m_dialog(NULL)
71 bool DocumentChecker::hasErrorInClips()
76 QDomNodeList documentProducers = m_doc.elementsByTagName("producer");
77 QList <QDomElement> wrongDurationClips;
78 QList <QDomElement> missingClips;
79 QList <QDomElement> missingProxies;
80 for (int i = 0; i < m_info.count(); i++) {
81 e = m_info.item(i).toElement();
82 clipType = e.attribute("type").toInt();
83 if (clipType == COLOR) continue;
84 if (clipType != TEXT && clipType != IMAGE) {
85 QString id = e.attribute("id");
86 int duration = e.attribute("duration").toInt();
87 // Check that the duration is in sync between Kdenlive's info and MLT's playlist
88 for (int j = 0; j < documentProducers.count(); j++) {
89 QDomElement mltProd = documentProducers.at(j).toElement();
90 QString prodId = mltProd.attribute("id");
91 // Don't check slowmotion clips for now... (TODO?)
92 if (prodId.startsWith("slowmotion")) continue;
93 if (prodId.contains("_")) prodId = prodId.section("_", 0, 0);
94 if (prodId != id) continue;
95 int mltDuration = mltProd.attribute("out").toInt() + 1;
96 if (mltDuration != duration && !e.hasAttribute("_mismatch")) {
98 e.setAttribute("_mismatch", mltDuration);
99 if (!wrongDurationClips.contains(e)) wrongDurationClips.append(e);
100 kDebug() << "WRONG DURTAION: "<<id<<", TYPE: "<<clipType;
105 if (clipType == TEXT) {
106 //TODO: Check is clip template is missing (xmltemplate) or hash changed
107 QStringList images = TitleWidget::extractImageList(e.attribute("xmldata"));
108 QStringList fonts = TitleWidget::extractFontList(e.attribute("xmldata"));
109 checkMissingImages(missingClips, images, fonts, e.attribute("id"), e.attribute("name"));
112 resource = e.attribute("resource");
113 if (e.hasAttribute("proxy")) {
114 QString proxyresource = e.attribute("proxy");
115 if (!KIO::NetAccess::exists(KUrl(proxyresource), KIO::NetAccess::SourceSide, 0)) {
116 // Missing clip found
117 missingProxies.append(e);
120 if (clipType == SLIDESHOW) resource = KUrl(resource).directory();
121 if (!KIO::NetAccess::exists(KUrl(resource), KIO::NetAccess::SourceSide, 0)) {
122 // Missing clip found
123 missingClips.append(e);
125 // Check if the clip has changed
126 if (clipType != SLIDESHOW && e.hasAttribute("file_hash")) {
127 if (e.attribute("file_hash") != DocClipBase::getHash(e.attribute("resource")))
128 e.removeAttribute("file_hash");
133 QStringList missingLumas;
134 QString root = m_doc.documentElement().attribute("root");
135 if (!root.isEmpty()) root = KUrl(root).path(KUrl::AddTrailingSlash);
136 QDomNodeList trans = m_doc.elementsByTagName("transition");
137 for (int i = 0; i < trans.count(); i++) {
138 QString luma = getProperty(trans.at(i).toElement(), "luma");
139 if (!luma.isEmpty()) {
140 if (!luma.startsWith('/')) luma.prepend(root);
141 if (!QFile::exists(luma) && !missingLumas.contains(luma)) {
142 missingLumas.append(luma);
147 if (missingClips.isEmpty() && missingLumas.isEmpty() && wrongDurationClips.isEmpty() && missingProxies.isEmpty())
150 m_dialog = new QDialog();
151 m_dialog->setFont(KGlobalSettings::toolBarFont());
152 m_ui.setupUi(m_dialog);
154 foreach(const QString l, missingLumas) {
155 QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << i18n("Luma file") << l);
156 item->setIcon(0, KIcon("dialog-close"));
157 item->setData(0, idRole, l);
158 item->setData(0, statusRole, LUMAMISSING);
161 m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
162 for (int i = 0; i < missingClips.count(); i++) {
163 e = missingClips.at(i).toElement();
165 int t = e.attribute("type").toInt();
168 clipType = i18n("Video clip");
171 clipType = i18n("Mute video clip");
174 clipType = i18n("Audio clip");
177 clipType = i18n("Playlist clip");
180 clipType = i18n("Image clip");
183 clipType = i18n("Slideshow clip");
185 case TITLE_IMAGE_ELEMENT:
186 clipType = i18n("Title Image");
188 case TITLE_FONT_ELEMENT:
189 clipType = i18n("Title Font");
192 clipType = i18n("Video clip");
194 QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << clipType);
195 if (t == TITLE_IMAGE_ELEMENT) {
196 item->setIcon(0, KIcon("dialog-warning"));
197 item->setToolTip(1, e.attribute("name"));
198 item->setText(1, e.attribute("resource"));
199 item->setData(0, statusRole, CLIPPLACEHOLDER);
200 item->setData(0, typeOriginalResource, e.attribute("resource"));
201 } else if (t == TITLE_FONT_ELEMENT) {
202 item->setIcon(0, KIcon("dialog-warning"));
203 item->setToolTip(1, e.attribute("name"));
204 QString ft = e.attribute("resource");
205 QString newft = QFontInfo(QFont(ft)).family();
206 item->setText(1, i18n("%1 will be replaced by %2", ft, newft));
207 item->setData(0, statusRole, CLIPPLACEHOLDER);
209 item->setIcon(0, KIcon("dialog-close"));
210 item->setText(1, e.attribute("resource"));
211 item->setData(0, hashRole, e.attribute("file_hash"));
212 item->setData(0, sizeRole, e.attribute("file_size"));
213 item->setData(0, statusRole, CLIPMISSING);
215 item->setData(0, typeRole, t);
216 item->setData(0, idRole, e.attribute("id"));
217 item->setToolTip(0, i18n("Missing item"));
220 if (missingClips.count() > 0) {
221 if (wrongDurationClips.count() > 0) {
222 m_ui.infoLabel->setText(i18n("The project file contains missing clips or files and clip duration mismatch"));
225 m_ui.infoLabel->setText(i18n("The project file contains missing clips or files"));
228 else if (wrongDurationClips.count() > 0) {
229 m_ui.infoLabel->setText(i18n("The project file contains clips with duration mismatch"));
231 if (missingProxies.count() > 0) {
232 if (!m_ui.infoLabel->text().isEmpty()) m_ui.infoLabel->setText(m_ui.infoLabel->text() + ". ");
233 m_ui.infoLabel->setText(m_ui.infoLabel->text() + i18n("Missing proxies will be recreated after opening."));
236 m_ui.removeSelected->setEnabled(!missingClips.isEmpty());
237 m_ui.recursiveSearch->setEnabled(!missingClips.isEmpty());
238 m_ui.usePlaceholders->setEnabled(!missingClips.isEmpty());
239 m_ui.fixDuration->setEnabled(!wrongDurationClips.isEmpty());
241 for (int i = 0; i < wrongDurationClips.count(); i++) {
242 e = wrongDurationClips.at(i).toElement();
244 int t = e.attribute("type").toInt();
247 clipType = i18n("Video clip");
250 clipType = i18n("Mute video clip");
253 clipType = i18n("Audio clip");
256 clipType = i18n("Playlist clip");
259 clipType = i18n("Image clip");
262 clipType = i18n("Slideshow clip");
265 clipType = i18n("Video clip");
267 QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << clipType);
268 item->setIcon(0, KIcon("timeadjust"));
269 item->setText(1, e.attribute("resource"));
270 item->setData(0, hashRole, e.attribute("file_hash"));
271 item->setData(0, sizeRole, e.attribute("_mismatch"));
272 e.removeAttribute("_mismatch");
273 item->setData(0, statusRole, CLIPWRONGDURATION);
274 item->setData(0, typeRole, t);
275 item->setData(0, idRole, e.attribute("id"));
276 item->setToolTip(0, i18n("Duration mismatch"));
280 for (int i = 0; i < missingProxies.count(); i++) {
281 e = missingProxies.at(i).toElement();
283 int t = e.attribute("type").toInt();
284 QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << i18n("Proxy clip"));
285 item->setIcon(0, KIcon("dialog-close"));
286 item->setText(1, e.attribute("proxy"));
287 item->setData(0, hashRole, e.attribute("file_hash"));
288 item->setData(0, statusRole, PROXYMISSING);
289 item->setData(0, typeRole, t);
290 item->setData(0, idRole, e.attribute("id"));
291 item->setToolTip(0, i18n("Missing proxy"));
294 connect(m_ui.recursiveSearch, SIGNAL(pressed()), this, SLOT(slotSearchClips()));
295 connect(m_ui.usePlaceholders, SIGNAL(pressed()), this, SLOT(slotPlaceholders()));
296 connect(m_ui.removeSelected, SIGNAL(pressed()), this, SLOT(slotDeleteSelected()));
297 connect(m_ui.fixDuration, SIGNAL(pressed()), this, SLOT(slotFixDuration()));
298 connect(m_ui.treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotEditItem(QTreeWidgetItem *, int)));
299 connect(m_ui.treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckButtons()));
301 if (m_ui.treeWidget->topLevelItem(0)) m_ui.treeWidget->setCurrentItem(m_ui.treeWidget->topLevelItem(0));
303 int acceptMissing = m_dialog->exec();
304 if (acceptMissing == QDialog::Accepted) acceptDialog();
305 return (acceptMissing != QDialog::Accepted);
308 DocumentChecker::~DocumentChecker()
310 if (m_dialog) delete m_dialog;
314 QString DocumentChecker::getProperty(QDomElement effect, const QString &name)
316 QDomNodeList params = effect.elementsByTagName("property");
317 for (int i = 0; i < params.count(); i++) {
318 QDomElement e = params.item(i).toElement();
319 if (e.attribute("name") == name) {
320 return e.firstChild().nodeValue();
326 void DocumentChecker::setProperty(QDomElement effect, const QString &name, const QString value)
328 QDomNodeList params = effect.elementsByTagName("property");
329 for (int i = 0; i < params.count(); i++) {
330 QDomElement e = params.item(i).toElement();
331 if (e.attribute("name") == name) {
332 e.firstChild().setNodeValue(value);
337 void DocumentChecker::slotSearchClips()
339 QString newpath = KFileDialog::getExistingDirectory(KUrl("kfiledialog:///clipfolder"), kapp->activeWindow(), i18n("Clips folder"));
340 if (newpath.isEmpty()) return;
343 m_ui.recursiveSearch->setEnabled(false);
344 QTreeWidgetItem *child = m_ui.treeWidget->topLevelItem(ix);
346 if (child->data(0, statusRole).toInt() == CLIPMISSING) {
347 QString clipPath = searchFileRecursively(QDir(newpath), child->data(0, sizeRole).toString(), child->data(0, hashRole).toString());
348 if (!clipPath.isEmpty()) {
350 child->setText(1, clipPath);
351 child->setIcon(0, KIcon("dialog-ok"));
352 child->setData(0, statusRole, CLIPOK);
354 } else if (child->data(0, statusRole).toInt() == LUMAMISSING) {
355 QString fileName = searchLuma(child->data(0, idRole).toString());
356 if (!fileName.isEmpty()) {
358 child->setText(1, fileName);
359 child->setIcon(0, KIcon("dialog-ok"));
360 child->setData(0, statusRole, LUMAOK);
364 child = m_ui.treeWidget->topLevelItem(ix);
366 m_ui.recursiveSearch->setEnabled(true);
368 // original doc was modified
369 QDomNode infoXmlNode = m_doc.elementsByTagName("kdenlivedoc").at(0);
370 QDomElement infoXml = infoXmlNode.toElement();
371 infoXml.setAttribute("modified", "1");
377 QString DocumentChecker::searchLuma(QString file) const
379 KUrl searchPath(KdenliveSettings::mltpath());
380 if (file.contains("PAL"))
381 searchPath.cd("../lumas/PAL");
383 searchPath.cd("../lumas/NTSC");
384 QString result = searchPath.path(KUrl::AddTrailingSlash) + KUrl(file).fileName();
385 if (QFile::exists(result))
391 QString DocumentChecker::searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const
393 QString foundFileName;
396 QStringList filesAndDirs = dir.entryList(QDir::Files | QDir::Readable);
397 for (int i = 0; i < filesAndDirs.size() && foundFileName.isEmpty(); i++) {
398 QFile file(dir.absoluteFilePath(filesAndDirs.at(i)));
399 if (QString::number(file.size()) == matchSize) {
400 if (file.open(QIODevice::ReadOnly)) {
402 * 1 MB = 1 second per 450 files (or faster)
403 * 10 MB = 9 seconds per 450 files (or faster)
405 if (file.size() > 1000000 * 2) {
406 fileData = file.read(1000000);
407 if (file.seek(file.size() - 1000000))
408 fileData.append(file.readAll());
410 fileData = file.readAll();
412 fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
413 if (QString(fileHash.toHex()) == matchHash)
414 return file.fileName();
417 //kDebug() << filesAndDirs.at(i) << file.size() << fileHash.toHex();
419 filesAndDirs = dir.entryList(QDir::Dirs | QDir::Readable | QDir::Executable | QDir::NoDotAndDotDot);
420 for (int i = 0; i < filesAndDirs.size() && foundFileName.isEmpty(); i++) {
421 foundFileName = searchFileRecursively(dir.absoluteFilePath(filesAndDirs.at(i)), matchSize, matchHash);
422 if (!foundFileName.isEmpty())
425 return foundFileName;
428 void DocumentChecker::slotEditItem(QTreeWidgetItem *item, int)
430 int t = item->data(0, typeRole).toInt();
431 if (t == TITLE_FONT_ELEMENT) return;
432 //|| t == TITLE_IMAGE_ELEMENT) {
434 KUrl url = KUrlRequesterDialog::getUrl(item->text(1), m_dialog, i18n("Enter new location for file"));
435 if (url.isEmpty()) return;
436 item->setText(1, url.path());
437 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) {
438 item->setIcon(0, KIcon("dialog-ok"));
439 int id = item->data(0, statusRole).toInt();
440 if (id < 10) item->setData(0, statusRole, CLIPOK);
441 else item->setData(0, statusRole, LUMAOK);
444 item->setIcon(0, KIcon("dialog-close"));
445 int id = item->data(0, statusRole).toInt();
446 if (id < 10) item->setData(0, statusRole, CLIPMISSING);
447 else item->setData(0, statusRole, LUMAMISSING);
453 void DocumentChecker::acceptDialog()
455 QDomElement e, property;
456 QDomNodeList producers = m_doc.elementsByTagName("producer");
457 QDomNodeList infoproducers = m_doc.elementsByTagName("kdenlive_producer");
458 QDomNodeList properties;
461 // prepare transitions
462 QDomNodeList trans = m_doc.elementsByTagName("transition");
464 // Mark document as modified
465 m_doc.documentElement().setAttribute("modified", 1);
467 QTreeWidgetItem *child = m_ui.treeWidget->topLevelItem(ix);
469 int t = child->data(0, typeRole).toInt();
470 if (child->data(0, statusRole).toInt() == CLIPOK) {
471 QString id = child->data(0, idRole).toString();
472 if (t == TITLE_IMAGE_ELEMENT) {
473 // edit images embedded in titles
474 for (int i = 0; i < infoproducers.count(); i++) {
475 e = infoproducers.item(i).toElement();
476 if (e.attribute("id") == id) {
478 QString xml = e.attribute("xmldata");
479 xml.replace(child->data(0, typeOriginalResource).toString(), child->text(1));
480 e.setAttribute("xmldata", xml);
484 for (int i = 0; i < producers.count(); i++) {
485 e = producers.item(i).toElement();
486 if (e.attribute("id").section('_', 0, 0) == id) {
488 properties = e.childNodes();
489 for (int j = 0; j < properties.count(); ++j) {
490 property = properties.item(j).toElement();
491 if (property.attribute("name") == "xmldata") {
492 QString xml = property.firstChild().nodeValue();
493 xml.replace(child->data(0, typeOriginalResource).toString(), child->text(1));
494 property.firstChild().setNodeValue(xml);
502 for (int i = 0; i < infoproducers.count(); i++) {
503 e = infoproducers.item(i).toElement();
504 if (e.attribute("id") == id) {
506 e.setAttribute("resource", child->text(1));
507 e.setAttribute("name", KUrl(child->text(1)).fileName());
511 for (int i = 0; i < producers.count(); i++) {
512 e = producers.item(i).toElement();
513 if (e.attribute("id").section('_', 0, 0) == id || e.attribute("id").section(':', 1, 1) == id) {
515 properties = e.childNodes();
516 for (int j = 0; j < properties.count(); ++j) {
517 property = properties.item(j).toElement();
518 if (property.attribute("name") == "resource") {
519 QString resource = property.firstChild().nodeValue();
520 if (resource.contains(QRegExp("\\?[0-9]+\\.[0-9]+(&strobe=[0-9]+)?$")))
521 property.firstChild().setNodeValue(child->text(1) + '?' + resource.section('?', -1));
523 property.firstChild().setNodeValue(child->text(1));
530 } else if (child->data(0, statusRole).toInt() == CLIPPLACEHOLDER && t != TITLE_FONT_ELEMENT && t != TITLE_IMAGE_ELEMENT) {
531 QString id = child->data(0, idRole).toString();
532 for (int i = 0; i < infoproducers.count(); i++) {
533 e = infoproducers.item(i).toElement();
534 if (e.attribute("id") == id) {
536 e.setAttribute("placeholder", '1');
540 } else if (child->data(0, statusRole).toInt() == LUMAOK) {
541 for (int i = 0; i < trans.count(); i++) {
542 QString luma = getProperty(trans.at(i).toElement(), "luma");
543 kDebug() << "luma: " << luma;
544 if (!luma.isEmpty() && luma == child->data(0, idRole).toString()) {
545 setProperty(trans.at(i).toElement(), "luma", child->text(1));
546 kDebug() << "replace with; " << child->text(1);
549 } else if (child->data(0, statusRole).toInt() == LUMAMISSING) {
550 for (int i = 0; i < trans.count(); i++) {
551 QString luma = getProperty(trans.at(i).toElement(), "luma");
552 if (!luma.isEmpty() && luma == child->data(0, idRole).toString()) {
553 setProperty(trans.at(i).toElement(), "luma", QString());
558 child = m_ui.treeWidget->topLevelItem(ix);
563 void DocumentChecker::slotPlaceholders()
566 QTreeWidgetItem *child = m_ui.treeWidget->topLevelItem(ix);
568 if (child->data(0, statusRole).toInt() == CLIPMISSING) {
569 child->setData(0, statusRole, CLIPPLACEHOLDER);
570 child->setIcon(0, KIcon("dialog-ok"));
571 } else if (child->data(0, statusRole).toInt() == LUMAMISSING) {
572 child->setData(0, statusRole, LUMAPLACEHOLDER);
573 child->setIcon(0, KIcon("dialog-ok"));
576 child = m_ui.treeWidget->topLevelItem(ix);
581 void DocumentChecker::slotFixDuration()
584 QTreeWidgetItem *child = m_ui.treeWidget->topLevelItem(ix);
586 if (child->data(0, statusRole).toInt() == CLIPWRONGDURATION) {
587 child->setData(0, statusRole, CLIPOK);
588 child->setIcon(0, KIcon("dialog-ok"));
589 QString id = child->data(0, idRole).toString();
590 for (int i = 0; i < m_info.count(); i++) {
591 QDomElement e = m_info.at(i).toElement();
592 if (e.attribute("id") == id) {
593 e.setAttribute("duration", child->data(0, sizeRole).toString());
599 child = m_ui.treeWidget->topLevelItem(ix);
601 QDomNode infoXmlNode = m_doc.elementsByTagName("kdenlivedoc").at(0);
602 QDomElement infoXml = infoXmlNode.toElement();
603 infoXml.setAttribute("modified", "1");
604 m_ui.fixDuration->setEnabled(false);
609 void DocumentChecker::checkStatus()
613 QTreeWidgetItem *child = m_ui.treeWidget->topLevelItem(ix);
615 int status = child->data(0, statusRole).toInt();
616 if (status == CLIPMISSING || status == LUMAMISSING || status == CLIPWRONGDURATION) {
621 child = m_ui.treeWidget->topLevelItem(ix);
623 m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status);
627 void DocumentChecker::slotDeleteSelected()
629 if (KMessageBox::warningContinueCancel(m_dialog, i18np("This will remove the selected clip from this project", "This will remove the selected clips from this project", m_ui.treeWidget->selectedItems().count()), i18n("Remove clips")) == KMessageBox::Cancel)
631 QStringList deletedIds;
632 QDomNodeList playlists = m_doc.elementsByTagName("playlist");
634 foreach(QTreeWidgetItem *child, m_ui.treeWidget->selectedItems()) {
635 if (child->data(0, statusRole).toInt() < 10) {
636 deletedIds.append(child->data(0, idRole).toString());
640 kDebug() << "// Clips to delete: " << deletedIds;
642 if (!deletedIds.isEmpty()) {
644 QDomNodeList producers = m_doc.elementsByTagName("producer");
645 QDomNodeList infoproducers = m_doc.elementsByTagName("kdenlive_producer");
647 QDomElement mlt = m_doc.firstChildElement("mlt");
648 QDomElement kdenlivedoc = mlt.firstChildElement("kdenlivedoc");
650 for (int i = 0, j = 0; i < infoproducers.count() && j < deletedIds.count(); i++) {
651 e = infoproducers.item(i).toElement();
652 if (deletedIds.contains(e.attribute("id"))) {
654 kdenlivedoc.removeChild(e);
660 for (int i = 0; i < producers.count(); i++) {
661 e = producers.item(i).toElement();
662 if (deletedIds.contains(e.attribute("id").section('_', 0, 0)) || deletedIds.contains(e.attribute("id").section(':', 1, 1).section('_', 0, 0))) {
669 for (int i = 0; i < playlists.count(); i++) {
670 QDomNodeList entries = playlists.at(i).toElement().elementsByTagName("entry");
671 for (int j = 0; j < entries.count(); j++) {
672 e = entries.item(j).toElement();
673 if (deletedIds.contains(e.attribute("producer").section('_', 0, 0)) || deletedIds.contains(e.attribute("producer").section(':', 1, 1).section('_', 0, 0))) {
674 // Replace clip with blank
675 while (e.childNodes().count() > 0)
676 e.removeChild(e.firstChild());
677 e.setTagName("blank");
678 e.removeAttribute("producer");
679 int length = e.attribute("out").toInt() - e.attribute("in").toInt();
680 e.setAttribute("length", length);
685 QDomNode infoXmlNode = m_doc.elementsByTagName("kdenlivedoc").at(0);
686 QDomElement infoXml = infoXmlNode.toElement();
687 infoXml.setAttribute("modified", "1");
692 void DocumentChecker::checkMissingImages(QList <QDomElement>&missingClips, QStringList images, QStringList fonts, QString id, QString baseClip)
695 foreach(const QString &img, images) {
696 if (!KIO::NetAccess::exists(KUrl(img), KIO::NetAccess::SourceSide, 0)) {
697 QDomElement e = doc.createElement("missingclip");
698 e.setAttribute("type", TITLE_IMAGE_ELEMENT);
699 e.setAttribute("resource", img);
700 e.setAttribute("id", id);
701 e.setAttribute("name", baseClip);
702 missingClips.append(e);
705 kDebug() << "/ / / CHK FONTS: " << fonts;
706 foreach(const QString &fontelement, fonts) {
707 QFont f(fontelement);
708 kDebug() << "/ / / CHK FONTS: " << fontelement << " = " << QFontInfo(f).family();
709 if (fontelement != QFontInfo(f).family()) {
710 QDomElement e = doc.createElement("missingclip");
711 e.setAttribute("type", TITLE_FONT_ELEMENT);
712 e.setAttribute("resource", fontelement);
713 e.setAttribute("id", id);
714 e.setAttribute("name", baseClip);
715 missingClips.append(e);
721 void DocumentChecker::slotCheckButtons()
723 if (m_ui.treeWidget->currentItem()) {
724 QTreeWidgetItem *item = m_ui.treeWidget->currentItem();
725 int t = item->data(0, typeRole).toInt();
726 if (t == TITLE_FONT_ELEMENT || t == TITLE_IMAGE_ELEMENT) {
727 m_ui.removeSelected->setEnabled(false);
728 } else m_ui.removeSelected->setEnabled(true);
733 #include "documentchecker.moc"