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 <QDomDocument>
22 #include <QItemDelegate>
23 #include <QTreeWidgetItem>
24 #include <QHeaderView>
26 #include <KStandardDirs>
28 #include <KMessageBox>
31 #include "kdenlivesettings.h"
32 #include "renderwidget.h"
33 #include "ui_saveprofile_ui.h"
35 const int GroupRole = Qt::UserRole;
36 const int ExtensionRole = GroupRole + 1;
37 const int StandardRole = GroupRole + 2;
38 const int RenderRole = GroupRole + 3;
39 const int ParamsRole = GroupRole + 4;
40 const int EditableRole = GroupRole + 5;
42 RenderWidget::RenderWidget(QWidget * parent): QDialog(parent) {
44 m_view.buttonDelete->setIcon(KIcon("trash-empty"));
45 m_view.buttonDelete->setToolTip(i18n("Delete profile"));
46 m_view.buttonDelete->setEnabled(false);
48 m_view.buttonEdit->setIcon(KIcon("document-properties"));
49 m_view.buttonEdit->setToolTip(i18n("Edit profile"));
50 m_view.buttonEdit->setEnabled(false);
52 m_view.buttonSave->setIcon(KIcon("document-new"));
53 m_view.buttonSave->setToolTip(i18n("Create new profile"));
55 m_view.buttonInfo->setIcon(KIcon("help-about"));
57 if (KdenliveSettings::showrenderparams()) {
58 m_view.buttonInfo->setDown(true);
59 } else m_view.advanced_params->hide();
61 m_view.experimentalrender->setChecked(KdenliveSettings::experimentalrender());
63 m_view.experimentalrender->setToolTip(i18n("Changing the size of video when rendering\nis not fully supported, you may have problems\nwith some effects or title clips, so the export\nprofiles that resize your video are marked as\nexperimental"));
65 connect(m_view.buttonInfo, SIGNAL(clicked()), this, SLOT(showInfoPanel()));
67 connect(m_view.buttonSave, SIGNAL(clicked()), this, SLOT(slotSaveProfile()));
68 connect(m_view.buttonEdit, SIGNAL(clicked()), this, SLOT(slotEditProfile()));
69 connect(m_view.buttonDelete, SIGNAL(clicked()), this, SLOT(slotDeleteProfile()));
70 connect(m_view.buttonStart, SIGNAL(clicked()), this, SLOT(slotExport()));
71 connect(m_view.buttonClose, SIGNAL(clicked()), this, SLOT(hide()));
72 connect(m_view.buttonClose2, SIGNAL(clicked()), this, SLOT(hide()));
73 connect(m_view.out_file, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButtons()));
74 connect(m_view.format_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshView()));
75 connect(m_view.size_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshParams()));
77 connect(m_view.render_guide, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
78 connect(m_view.render_zone, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
79 connect(m_view.render_full, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
81 connect(m_view.guide_end, SIGNAL(activated(int)), this, SLOT(slotCheckStartGuidePosition()));
82 connect(m_view.guide_start, SIGNAL(activated(int)), this, SLOT(slotCheckEndGuidePosition()));
84 connect(m_view.format_selection, SIGNAL(activated(int)), this, SLOT(refreshView()));
85 connect(m_view.experimentalrender, SIGNAL(stateChanged(int)), this, SLOT(slotUpdateExperimentalRendering()));
87 m_view.buttonStart->setEnabled(false);
88 m_view.guides_box->setVisible(false);
90 m_view.splitter->setStretchFactor(1, 5);
91 m_view.splitter->setStretchFactor(0, 2);
93 m_view.out_file->setMode(KFile::File);
95 m_view.running_jobs->setItemDelegate(new RenderViewDelegate(this));
96 QHeaderView *header = m_view.running_jobs->header();
97 QFontMetrics fm = fontMetrics();
98 //header->resizeSection(0, fm.width("typical-name-for-a-torrent.torrent"));
99 header->setResizeMode(0, QHeaderView::Interactive);
100 header->resizeSection(0, fm.width("typical-name-for-a-file.torrent"));
101 header->setResizeMode(1, QHeaderView::Fixed);
102 header->resizeSection(0, width() * 2 / 3);
103 header->setResizeMode(1, QHeaderView::Interactive);
104 //header->setResizeMode(1, QHeaderView::Fixed);
106 focusFirstVisibleItem();
109 void RenderWidget::slotUpdateExperimentalRendering() {
110 KdenliveSettings::setExperimentalrender(m_view.experimentalrender->isChecked());
115 void RenderWidget::showInfoPanel() {
116 if (m_view.advanced_params->isVisible()) {
117 m_view.advanced_params->setVisible(false);
118 m_view.buttonInfo->setDown(false);
119 KdenliveSettings::setShowrenderparams(false);
121 m_view.advanced_params->setVisible(true);
122 m_view.buttonInfo->setDown(true);
123 KdenliveSettings::setShowrenderparams(true);
127 void RenderWidget::slotUpdateGuideBox() {
128 m_view.guides_box->setVisible(m_view.render_guide->isChecked());
131 void RenderWidget::slotCheckStartGuidePosition() {
132 if (m_view.guide_start->currentIndex() > m_view.guide_end->currentIndex())
133 m_view.guide_start->setCurrentIndex(m_view.guide_end->currentIndex());
136 void RenderWidget::slotCheckEndGuidePosition() {
137 if (m_view.guide_end->currentIndex() < m_view.guide_start->currentIndex())
138 m_view.guide_end->setCurrentIndex(m_view.guide_start->currentIndex());
141 void RenderWidget::setGuides(QDomElement guidesxml, double duration) {
142 m_view.guide_start->clear();
143 m_view.guide_end->clear();
144 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
145 if (nodes.count() > 0) {
146 m_view.guide_start->addItem(i18n("Render"), "0");
147 m_view.render_guide->setEnabled(true);
148 } else m_view.render_guide->setEnabled(false);
149 for (int i = 0; i < nodes.count(); i++) {
150 QDomElement e = nodes.item(i).toElement();
152 m_view.guide_start->addItem(e.attribute("comment"), e.attribute("time").toDouble());
153 m_view.guide_end->addItem(e.attribute("comment"), e.attribute("time").toDouble());
156 if (nodes.count() > 0)
157 m_view.guide_end->addItem(i18n("End"), QString::number(duration));
160 void RenderWidget::slotUpdateButtons() {
161 if (m_view.out_file->url().isEmpty()) m_view.buttonStart->setEnabled(false);
162 else m_view.buttonStart->setEnabled(true);
165 void RenderWidget::slotSaveProfile() {
166 Ui::SaveProfile_UI ui;
167 QDialog *d = new QDialog(this);
169 QString customGroup = i18n("Custom");
170 QStringList groupNames;
171 for (int i = 0; i < m_view.format_list->count(); i++)
172 groupNames.append(m_view.format_list->item(i)->text());
173 if (!groupNames.contains(customGroup)) groupNames.prepend(customGroup);
174 ui.group_name->addItems(groupNames);
175 int pos = ui.group_name->findText(customGroup);
176 ui.group_name->setCurrentIndex(pos);
178 ui.parameters->setText(m_view.advanced_params->toPlainText());
179 ui.extension->setText(m_view.size_list->currentItem()->data(ExtensionRole).toString());
180 ui.profile_name->setFocus();
181 if (d->exec() == QDialog::Accepted && !ui.profile_name->text().simplified().isEmpty()) {
182 QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
184 QFile file(exportFile);
185 doc.setContent(&file, false);
188 QDomElement documentElement;
189 bool groupExists = false;
191 QString newProfileName = ui.profile_name->text().simplified();
192 QString newGroupName = ui.group_name->currentText();
193 QDomNodeList groups = doc.elementsByTagName("group");
195 if (groups.count() == 0) {
196 QDomElement profiles = doc.createElement("profiles");
197 doc.appendChild(profiles);
198 } else while (!groups.item(i).isNull()) {
199 documentElement = groups.item(i).toElement();
200 groupName = documentElement.attribute("name");
201 kDebug() << "// SAVE, PARSING FROUP: " << i << ", name: " << groupName << ", LOOK FR: " << newGroupName;
202 if (groupName == newGroupName) {
209 documentElement = doc.createElement("group");
210 documentElement.setAttribute("name", ui.group_name->currentText());
211 documentElement.setAttribute("renderer", "avformat");
212 doc.documentElement().appendChild(documentElement);
214 QDomElement profileElement = doc.createElement("profile");
215 profileElement.setAttribute("name", newProfileName);
216 profileElement.setAttribute("extension", ui.extension->text().simplified());
217 profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
218 documentElement.appendChild(profileElement);
220 //QCString save = doc.toString().utf8();
222 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
223 KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
227 QTextStream out(&file);
228 out << doc.toString();
230 parseProfiles(newGroupName, newProfileName);
235 void RenderWidget::slotEditProfile() {
236 QListWidgetItem *item = m_view.size_list->currentItem();
238 QString currentGroup = m_view.format_list->currentItem()->text();
240 QString params = item->data(ParamsRole).toString();
241 QString extension = item->data(ExtensionRole).toString();
242 QString currentProfile = item->text();
244 Ui::SaveProfile_UI ui;
245 QDialog *d = new QDialog(this);
247 QStringList groupNames;
248 for (int i = 0; i < m_view.format_list->count(); i++)
249 groupNames.append(m_view.format_list->item(i)->text());
250 if (!groupNames.contains(currentGroup)) groupNames.prepend(currentGroup);
251 ui.group_name->addItems(groupNames);
252 int pos = ui.group_name->findText(currentGroup);
253 ui.group_name->setCurrentIndex(pos);
254 ui.profile_name->setText(currentProfile);
255 ui.extension->setText(extension);
256 ui.parameters->setText(params);
257 ui.profile_name->setFocus();
259 if (d->exec() == QDialog::Accepted) {
261 QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
263 QFile file(exportFile);
264 doc.setContent(&file, false);
267 QDomElement documentElement;
268 bool groupExists = false;
270 QString newProfileName = ui.profile_name->text();
271 QString newGroupName = ui.group_name->currentText();
272 QDomNodeList groups = doc.elementsByTagName("group");
274 if (groups.count() == 0) {
275 QDomElement profiles = doc.createElement("profiles");
276 doc.appendChild(profiles);
277 } else while (!groups.item(i).isNull()) {
278 documentElement = groups.item(i).toElement();
279 groupName = documentElement.attribute("name");
280 kDebug() << "// SAVE, PARSING FROUP: " << i << ", name: " << groupName << ", LOOK FR: " << newGroupName;
281 if (groupName == newGroupName) {
288 documentElement = doc.createElement("group");
289 documentElement.setAttribute("name", ui.group_name->currentText());
290 documentElement.setAttribute("renderer", "avformat");
291 doc.documentElement().appendChild(documentElement);
293 QDomElement profileElement = doc.createElement("profile");
294 profileElement.setAttribute("name", newProfileName);
295 profileElement.setAttribute("extension", ui.extension->text().simplified());
296 profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
297 documentElement.appendChild(profileElement);
299 //QCString save = doc.toString().utf8();
301 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
302 KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
306 QTextStream out(&file);
307 out << doc.toString();
309 parseProfiles(newGroupName, newProfileName);
314 void RenderWidget::slotDeleteProfile() {
315 QString currentGroup = m_view.format_list->currentItem()->text();
316 QString currentProfile = m_view.size_list->currentItem()->text();
318 QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
320 QFile file(exportFile);
321 doc.setContent(&file, false);
324 QDomElement documentElement;
325 bool groupExists = false;
327 QDomNodeList groups = doc.elementsByTagName("group");
330 while (!groups.item(i).isNull()) {
331 documentElement = groups.item(i).toElement();
332 groupName = documentElement.attribute("name");
333 if (groupName == currentGroup) {
334 QDomNodeList children = documentElement.childNodes();
335 for (int j = 0; j < children.count(); j++) {
336 QDomElement pro = children.at(j).toElement();
337 if (pro.attribute("name") == currentProfile) {
338 groups.item(i).removeChild(children.at(j));
339 if (groups.item(i).childNodes().isEmpty())
340 doc.documentElement().removeChild(groups.item(i));
349 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
350 KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
353 QTextStream out(&file);
354 out << doc.toString();
356 parseProfiles(currentGroup);
357 focusFirstVisibleItem();
360 void RenderWidget::updateButtons() {
361 if (!m_view.size_list->currentItem() || m_view.size_list->currentItem()->isHidden()) {
362 m_view.buttonSave->setEnabled(false);
363 m_view.buttonDelete->setEnabled(false);
364 m_view.buttonEdit->setEnabled(false);
366 m_view.buttonSave->setEnabled(true);
367 if (m_view.size_list->currentItem()->data(EditableRole).toString().isEmpty()) {
368 m_view.buttonDelete->setEnabled(false);
369 m_view.buttonEdit->setEnabled(false);
371 m_view.buttonDelete->setEnabled(true);
372 m_view.buttonEdit->setEnabled(true);
378 void RenderWidget::focusFirstVisibleItem() {
379 if (m_view.size_list->currentItem() && !m_view.size_list->currentItem()->isHidden()) {
383 for (uint ix = 0; ix < m_view.size_list->count(); ix++) {
384 QListWidgetItem *item = m_view.size_list->item(ix);
385 if (item && !item->isHidden()) {
386 m_view.size_list->setCurrentRow(ix);
390 if (!m_view.size_list->currentItem()) m_view.size_list->setCurrentRow(0);
394 void RenderWidget::slotExport() {
395 QListWidgetItem *item = m_view.size_list->currentItem();
397 QFile f(m_view.out_file->url().path());
399 if (KMessageBox::warningYesNo(this, i18n("File already exists. Do you want to overwrite it ?")) != KMessageBox::Yes)
402 QStringList overlayargs;
403 if (m_view.tc_overlay->isChecked()) {
404 QString filterFile = KStandardDirs::locate("appdata", "metadata.properties");
405 overlayargs << "meta.attr.timecode=1" << "meta.attr.timecode.markup=#timecode";
406 overlayargs << "-attach" << "data_feed:attr_check" << "-attach";
407 overlayargs << "data_show:" + filterFile << "_fezzik=1" << "dynamic=1";
409 double startPos = -1;
411 if (m_view.render_guide->isChecked()) {
412 startPos = m_view.guide_start->itemData(m_view.guide_start->currentIndex()).toDouble();
413 endPos = m_view.guide_end->itemData(m_view.guide_end->currentIndex()).toDouble();
415 QString renderArgs = m_view.advanced_params->toPlainText();
416 renderArgs.replace("%width", QString::number(m_profile.width));
417 renderArgs.replace("%height", QString::number(m_profile.height));
418 renderArgs.replace("%dar", "@" + QString::number(m_profile.display_aspect_num) + "/" + QString::number(m_profile.display_aspect_den));
419 if (m_view.force_progressive->checkState() == Qt::Checked) renderArgs.append(" progressive=1");
420 else if (m_view.force_progressive->checkState() == Qt::Unchecked) renderArgs.append(" progressive=0");
422 // Check if the rendering profile is different from project profile,
423 // in which case we need to use the producer_comsumer from MLT
424 bool resizeProfile = false;
426 QString std = item->data(ParamsRole).toString();
427 if (resizeProfile == false && std.contains(" s=")) {
428 QString subsize = std.section(" s=", 1, 1);
429 subsize = subsize.section(' ', 0, 0).toLower();
430 if (subsize != "%widthx%height") {
431 const QString currentSize = QString::number(m_profile.width) + 'x' + QString::number(m_profile.height);
432 if (subsize != currentSize) resizeProfile = true;
436 emit doRender(m_view.out_file->url().path(), item->data(RenderRole).toString(), overlayargs, renderArgs.simplified().split(' '), m_view.render_zone->isChecked(), m_view.play_after->isChecked(), startPos, endPos, resizeProfile);
437 m_view.tabWidget->setCurrentIndex(1);
440 void RenderWidget::setProfile(MltVideoProfile profile) {
442 //WARNING: this way to tell the video standard is a bit hackish...
443 if (m_profile.description.contains("pal", Qt::CaseInsensitive) || m_profile.description.contains("25", Qt::CaseInsensitive) || m_profile.description.contains("50", Qt::CaseInsensitive)) m_view.format_selection->setCurrentIndex(0);
444 else m_view.format_selection->setCurrentIndex(1);
445 m_view.force_progressive->setCheckState(Qt::PartiallyChecked);
449 void RenderWidget::refreshView() {
450 m_view.size_list->blockSignals(true);
451 QListWidgetItem *item = m_view.format_list->currentItem();
453 m_view.format_list->setCurrentRow(0);
454 item = m_view.format_list->currentItem();
458 QString group = item->text();
459 QListWidgetItem *sizeItem;
460 bool firstSelected = false;
461 const QStringList formatsList = KdenliveSettings::supportedformats();
462 const QStringList vcodecsList = KdenliveSettings::videocodecs();
463 const QStringList acodecsList = KdenliveSettings::audiocodecs();
464 for (int i = 0; i < m_view.size_list->count(); i++) {
465 sizeItem = m_view.size_list->item(i);
466 if (sizeItem->data(GroupRole) == group) {
467 std = sizeItem->data(StandardRole).toString();
468 if (!std.isEmpty()) {
469 if (std.contains("PAL", Qt::CaseInsensitive)) sizeItem->setHidden(m_view.format_selection->currentIndex() != 0);
470 else if (std.contains("NTSC", Qt::CaseInsensitive)) sizeItem->setHidden(m_view.format_selection->currentIndex() != 1);
472 sizeItem->setHidden(false);
473 if (!firstSelected) m_view.size_list->setCurrentItem(sizeItem);
474 firstSelected = true;
476 if (!KdenliveSettings::experimentalrender() && !sizeItem->isHidden()) {
477 // hide experimental codecs (which do resize the video)
478 std = sizeItem->data(ParamsRole).toString();
479 if (std.contains(" s=")) {
480 QString subsize = std.section(" s=", 1, 1);
481 subsize = subsize.section(' ', 0, 0).toLower();
482 if (subsize != "%widthx%height") {
483 const QString currentSize = QString::number(m_profile.width) + 'x' + QString::number(m_profile.height);
484 if (subsize != currentSize) sizeItem->setHidden(true);
488 if (!sizeItem->isHidden()) {
489 // Make sure the selected profile uses an installed avformat codec / format
490 std = sizeItem->data(ParamsRole).toString();
492 if (!formatsList.isEmpty()) {
494 if (std.startsWith("f=")) format = std.section("f=", 1, 1);
495 else if (std.contains(" f=")) format = std.section(" f=", 1, 1);
496 if (!format.isEmpty()) {
497 format = format.section(' ', 0, 0).toLower();
498 if (!formatsList.contains(format)) {
499 kDebug() << "***** UNSUPPORTED F: " << format;
500 sizeItem->setHidden(true);
504 if (!acodecsList.isEmpty() && !sizeItem->isHidden()) {
506 if (std.startsWith("acodec=")) format = std.section("acodec=", 1, 1);
507 else if (std.contains(" acodec=")) format = std.section(" acodec=", 1, 1);
508 if (!format.isEmpty()) {
509 format = format.section(' ', 0, 0).toLower();
510 if (!acodecsList.contains(format)) {
511 kDebug() << "***** UNSUPPORTED ACODEC: " << format;
512 sizeItem->setHidden(true);
516 if (!vcodecsList.isEmpty() && !sizeItem->isHidden()) {
518 if (std.startsWith("vcodec=")) format = std.section("vcodec=", 1, 1);
519 else if (std.contains(" vcodec=")) format = std.section(" vcodec=", 1, 1);
520 if (!format.isEmpty()) {
521 format = format.section(' ', 0, 0).toLower();
522 if (!vcodecsList.contains(format)) {
523 kDebug() << "***** UNSUPPORTED VCODEC: " << format;
524 sizeItem->setHidden(true);
529 } else sizeItem->setHidden(true);
531 focusFirstVisibleItem();
532 m_view.size_list->blockSignals(false);
536 void RenderWidget::refreshParams() {
537 QListWidgetItem *item = m_view.size_list->currentItem();
538 if (!item || item->isHidden()) {
539 m_view.advanced_params->clear();
540 m_view.buttonStart->setEnabled(false);
543 QString params = item->data(ParamsRole).toString();
544 QString extension = item->data(ExtensionRole).toString();
545 m_view.advanced_params->setPlainText(params);
546 m_view.advanced_params->setToolTip(params);
547 KUrl url = m_view.out_file->url();
548 if (!url.isEmpty()) {
549 QString path = url.path();
550 int pos = path.lastIndexOf('.') + 1;
551 if (pos == 0) path.append('.') + extension;
552 else path = path.left(pos) + extension;
553 m_view.out_file->setUrl(KUrl(path));
555 m_view.out_file->setUrl(KUrl(QDir::homePath() + "/untitled." + extension));
557 m_view.out_file->setFilter("*." + extension);
559 if (item->data(EditableRole).toString().isEmpty()) {
560 m_view.buttonDelete->setEnabled(false);
561 m_view.buttonEdit->setEnabled(false);
563 m_view.buttonDelete->setEnabled(true);
564 m_view.buttonEdit->setEnabled(true);
566 m_view.buttonStart->setEnabled(true);
569 void RenderWidget::parseProfiles(QString group, QString profile) {
570 m_view.size_list->clear();
571 m_view.format_list->clear();
572 QString exportFile = KStandardDirs::locate("appdata", "export/profiles.xml");
573 parseFile(exportFile, false);
574 exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
575 if (QFile::exists(exportFile)) parseFile(exportFile, true);
577 QList<QListWidgetItem *> child;
578 child = m_view.format_list->findItems(group, Qt::MatchExactly);
579 if (!child.isEmpty()) m_view.format_list->setCurrentItem(child.at(0));
580 child = m_view.size_list->findItems(profile, Qt::MatchExactly);
581 if (!child.isEmpty()) m_view.size_list->setCurrentItem(child.at(0));
584 void RenderWidget::parseFile(QString exportFile, bool editable) {
586 QFile file(exportFile);
587 doc.setContent(&file, false);
589 QDomElement documentElement;
590 QDomElement profileElement;
591 QDomNodeList groups = doc.elementsByTagName("group");
593 if (groups.count() == 0) {
594 kDebug() << "// Export file: " << exportFile << " IS BROKEN";
602 QString prof_extension;
606 QListWidgetItem *item;
607 while (!groups.item(i).isNull()) {
608 documentElement = groups.item(i).toElement();
609 groupName = documentElement.attribute("name", QString::null);
610 extension = documentElement.attribute("extension", QString::null);
611 renderer = documentElement.attribute("renderer", QString::null);
612 if (m_view.format_list->findItems(groupName, Qt::MatchExactly).isEmpty())
613 new QListWidgetItem(groupName, m_view.format_list);
615 QDomNode n = groups.item(i).firstChild();
616 while (!n.isNull()) {
617 profileElement = n.toElement();
618 profileName = profileElement.attribute("name");
619 standard = profileElement.attribute("standard");
620 params = profileElement.attribute("args");
621 prof_extension = profileElement.attribute("extension");
622 if (!prof_extension.isEmpty()) extension = prof_extension;
623 item = new QListWidgetItem(profileName, m_view.size_list);
624 item->setData(GroupRole, groupName);
625 item->setData(ExtensionRole, extension);
626 item->setData(RenderRole, renderer);
627 item->setData(StandardRole, standard);
628 item->setData(ParamsRole, params);
629 if (editable) item->setData(EditableRole, "true");
637 void RenderWidget::setRenderJob(const QString &dest, int progress) {
638 QList<QTreeWidgetItem *> existing = m_view.running_jobs->findItems(dest, Qt::MatchExactly);
639 if (!existing.isEmpty()) {
640 if (progress == -1) {
641 // Job finished successfully
642 existing.at(0)->setIcon(0, KIcon("dialog-ok"));
643 existing.at(0)->setData(1, Qt::UserRole, 100);
644 } else if (progress == -2) {
646 existing.at(0)->setIcon(0, KIcon("dialog-close"));
647 existing.at(0)->setData(1, Qt::UserRole, 0);
648 } else existing.at(0)->setData(1, Qt::UserRole, progress);
651 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.running_jobs, QStringList() << dest << QString());
652 if (progress == -1) {
653 // Job finished successfully
654 item->setIcon(0, KIcon("dialog-ok"));
655 item->setData(1, Qt::UserRole, 100);
656 } else if (progress == -2) {
658 item->setIcon(0, KIcon("dialog-close"));
659 item->setData(1, Qt::UserRole, 0);
660 } else item->setData(1, Qt::UserRole, progress);
664 #include "renderwidget.moc"