+ m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status);
+}
+
+
+void DocumentChecker::slotDeleteSelected()
+{
+ 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)
+ return;
+ QStringList deletedIds;
+ QStringList deletedLumas;
+ QDomNodeList playlists = m_doc.elementsByTagName("playlist");
+
+ foreach(QTreeWidgetItem *child, m_ui.treeWidget->selectedItems()) {
+ int id = child->data(0, statusRole).toInt();
+ if (id == CLIPMISSING) {
+ deletedIds.append(child->data(0, idRole).toString());
+ delete child;
+ }
+ else if (id == LUMAMISSING) {
+ deletedLumas.append(child->data(0, idRole).toString());
+ delete child;
+ }
+ }
+
+ if (!deletedLumas.isEmpty()) {
+ QDomElement e;
+ QDomNodeList transitions = m_doc.elementsByTagName("transition");
+ foreach (const QString &lumaPath, deletedLumas) {
+ for (int i = 0; i < transitions.count(); ++i) {
+ e = transitions.item(i).toElement();
+ QString resource = EffectsList::property(e, "luma");
+ if (resource == lumaPath) EffectsList::removeProperty(e, "luma");
+ }
+ }
+ }
+
+ if (!deletedIds.isEmpty()) {
+ QDomElement e;
+ QDomNodeList producers = m_doc.elementsByTagName("producer");
+ QDomNodeList infoproducers = m_doc.elementsByTagName("kdenlive_producer");
+
+ QDomNode mlt = m_doc.elementsByTagName("mlt").at(0);
+ QDomNode kdenlivedoc = m_doc.elementsByTagName("kdenlivedoc").at(0);
+
+ for (int i = 0, j = 0; i < infoproducers.count() && j < deletedIds.count(); ++i) {
+ e = infoproducers.item(i).toElement();
+ if (deletedIds.contains(e.attribute("id"))) {
+ // Remove clip
+ kdenlivedoc.removeChild(e);
+ --i;
+ j++;
+ }
+ }
+
+ for (int i = 0; i < producers.count(); ++i) {
+ e = producers.item(i).toElement();
+ if (deletedIds.contains(e.attribute("id").section('_', 0, 0)) || deletedIds.contains(e.attribute("id").section(':', 1, 1).section('_', 0, 0))) {
+ // Remove clip
+ mlt.removeChild(e);
+ --i;
+ }
+ }
+
+ for (int i = 0; i < playlists.count(); ++i) {
+ QDomNodeList entries = playlists.at(i).toElement().elementsByTagName("entry");
+ for (int j = 0; j < entries.count(); j++) {
+ e = entries.item(j).toElement();
+ if (deletedIds.contains(e.attribute("producer").section('_', 0, 0)) || deletedIds.contains(e.attribute("producer").section(':', 1, 1).section('_', 0, 0))) {
+ // Replace clip with blank
+ while (e.childNodes().count() > 0)
+ e.removeChild(e.firstChild());
+ e.setTagName("blank");
+ e.removeAttribute("producer");
+ int length = e.attribute("out").toInt() - e.attribute("in").toInt();
+ e.setAttribute("length", length);
+ j--;
+ }
+ }
+ }
+ QDomElement infoXml = m_doc.elementsByTagName("kdenlivedoc").at(0).toElement();
+ infoXml.setAttribute("modified", "1");
+ checkStatus();
+ }
+}
+
+void DocumentChecker::checkMissingImagesAndFonts(const QStringList &images, const QStringList &fonts, const QString &id, const QString &baseClip)
+{
+ QDomDocument doc;
+ foreach(const QString &img, images) {
+ if (m_safeImages.contains(img)) continue;
+ if (!KIO::NetAccess::exists(KUrl(img), KIO::NetAccess::SourceSide, 0)) {
+ QDomElement e = doc.createElement("missingclip");
+ e.setAttribute("type", TITLE_IMAGE_ELEMENT);
+ e.setAttribute("resource", img);
+ e.setAttribute("id", id);
+ e.setAttribute("name", baseClip);
+ m_missingClips.append(e);
+ }
+ else m_safeImages.append(img);
+ }
+ foreach(const QString &fontelement, fonts) {
+ if (m_safeFonts.contains(fontelement)) continue;
+ QFont f(fontelement);
+ //kDebug() << "/ / / CHK FONTS: " << fontelement << " = " << QFontInfo(f).family();
+ if (fontelement != QFontInfo(f).family()) {
+ QDomElement e = doc.createElement("missingclip");
+ e.setAttribute("type", TITLE_FONT_ELEMENT);
+ e.setAttribute("resource", fontelement);
+ e.setAttribute("id", id);
+ e.setAttribute("name", baseClip);
+ m_missingClips.append(e);
+ }
+ else m_safeFonts.append(fontelement);
+ }
+}
+
+
+void DocumentChecker::slotCheckButtons()
+{
+ if (m_ui.treeWidget->currentItem()) {
+ QTreeWidgetItem *item = m_ui.treeWidget->currentItem();
+ int t = item->data(0, typeRole).toInt();
+ int s = item->data(0, statusRole).toInt();
+ if (t == TITLE_FONT_ELEMENT || t == TITLE_IMAGE_ELEMENT || s == PROXYMISSING) {
+ m_ui.removeSelected->setEnabled(false);
+ } else m_ui.removeSelected->setEnabled(true);
+ }
+