+void ProjectList::processThumbOverlays(ProjectItem *item, QPixmap &pix)
+{
+ if (item->hasProxy()) {
+ QPainter p(&pix);
+ QColor c = QPalette().base().color();
+ c.setAlpha(160);
+ QBrush br(c);
+ p.setBrush(br);
+ p.setPen(Qt::NoPen);
+ QRect r(1, 1, 10, 10);
+ p.drawRect(r);
+ p.setPen(QPalette().text().color());
+ p.drawText(r, Qt::AlignCenter, i18nc("The first letter of Proxy, used as abbreviation", "P"));
+ }
+}
+
+void ProjectList::slotCancelJobs()
+{
+ m_abortAllJobs = true;
+ m_jobThreads.waitForFinished();
+ m_jobThreads.clearFutures();
+ QUndoCommand *command = new QUndoCommand();
+ command->setText(i18np("Cancel job", "Cancel jobs", m_jobList.count()));
+ m_jobMutex.lock();
+ for (int i = 0; i < m_jobList.count(); i++) {
+ ProjectItem *item = getItemById(m_jobList.at(i)->clipId());
+ if (!item || !item->referencedClip()) continue;
+ QMap <QString, QString> newProps = m_jobList.at(i)->cancelProperties();
+ if (newProps.isEmpty()) continue;
+ QMap <QString, QString> oldProps = item->referencedClip()->currentProperties(newProps);
+ new EditClipCommand(this, m_jobList.at(i)->clipId(), oldProps, newProps, true, command);
+ }
+ m_jobMutex.unlock();
+ if (command->childCount() > 0) {
+ m_doc->commandStack()->push(command);
+ }
+ else delete command;
+ if (!m_jobList.isEmpty()) qDeleteAll(m_jobList);
+ m_processingProxy.clear();
+ m_jobList.clear();
+ m_abortAllJobs = false;
+ m_infoLabel->slotSetJobCount(0);
+}
+
+void ProjectList::slotCancelRunningJob(const QString id, stringMap newProps)
+{
+ if (newProps.isEmpty()) return;
+ ProjectItem *item = getItemById(id);
+ if (!item || !item->referencedClip()) return;
+ QMap <QString, QString> oldProps = item->referencedClip()->currentProperties(newProps);
+ if (newProps == oldProps) return;
+ QMapIterator<QString, QString> i(oldProps);
+ EditClipCommand *command = new EditClipCommand(this, id, oldProps, newProps, true);
+ m_commandStack->push(command);
+}
+
+bool ProjectList::hasPendingProxy(ProjectItem *item)
+{
+ if (!item || !item->referencedClip() || m_abortAllJobs) return false;
+ AbstractClipJob *job;
+ QMutexLocker lock(&m_jobMutex);
+ for (int i = 0; i < m_jobList.count(); i++) {
+ if (m_abortAllJobs) break;
+ job = m_jobList.at(i);
+ if (job->clipId() == item->clipId() && job->jobType == PROXYJOB && (job->jobStatus == JOBWAITING || job->jobStatus == JOBWORKING)) return true;
+ }
+
+ return false;
+}
+
+void ProjectList::deleteJobsForClip(const QString &clipId)
+{
+ QMutexLocker lock(&m_jobMutex);
+ for (int i = 0; i < m_jobList.count(); i++) {
+ if (m_abortAllJobs) break;
+ if (m_jobList.at(i)->clipId() == clipId) {
+ m_jobList.at(i)->setStatus(JOBABORTED);
+ }
+ }
+}
+
+void ProjectList::slotUpdateJobStatus(const QString &id, int type, int status, const QString &label, const QString &actionName, const QString details)
+{
+ ProjectItem *item = getItemById(id);
+ if (!item) return;
+ slotUpdateJobStatus(item, type, status, label, actionName, details);
+
+}
+
+void ProjectList::slotUpdateJobStatus(ProjectItem *item, int type, int status, const QString &label, const QString &actionName, const QString details)
+{
+ item->setJobStatus((JOBTYPE) type, (CLIPJOBSTATUS) status);
+ if (status != JOBCRASHED) return;
+#if KDE_IS_VERSION(4,7,0)
+ m_infoMessage->animatedHide();
+ m_errorLog.clear();
+ m_infoMessage->setText(label);
+ m_infoMessage->setWordWrap(label.length() > 35);
+ m_infoMessage->setMessageType(KMessageWidget::Warning);
+ QList<QAction *> actions = m_infoMessage->actions();
+ for (int i = 0; i < actions.count(); i++) {
+ m_infoMessage->removeAction(actions.at(i));
+ }
+
+ if (!actionName.isEmpty()) {
+ QAction *action = NULL;
+ QList< KActionCollection * > collections = KActionCollection::allCollections();
+ for (int i = 0; i < collections.count(); i++) {
+ KActionCollection *coll = collections.at(i);
+ action = coll->action(actionName);
+ if (action) break;
+ }
+ if (action) m_infoMessage->addAction(action);
+ }
+ if (!details.isEmpty()) {
+ m_errorLog = details;
+ m_infoMessage->addAction(m_logAction);
+ }
+ m_infoMessage->animatedShow();
+#endif
+}
+
+void ProjectList::slotShowJobLog()
+{
+#if KDE_IS_VERSION(4,7,0)
+ KDialog d(this);
+ d.setButtons(KDialog::Close);
+ QTextEdit t(&d);
+ t.setPlainText(m_errorLog);
+ t.setReadOnly(true);
+ d.setMainWidget(&t);
+ d.exec();
+#endif
+}
+
+void ProjectList::discardJobs(const QString &id, JOBTYPE type) {
+ QMutexLocker lock(&m_jobMutex);
+ for (int i = 0; i < m_jobList.count(); i++) {
+ if (m_jobList.at(i)->clipId() == id && m_jobList.at(i)->jobType == type) {
+ // discard this job
+ m_jobList.at(i)->setStatus(JOBABORTED);
+ }
+ }
+}
+
+