+#include "kdenlivesettings.h"
+#include "folderprojectitem.h"
+#include "subprojectitem.h"
+#include <kdialog.h>
+
+namespace Mlt
+{
+class Producer;
+};
+
+struct PROXYINFO {
+ QString dest;
+ QString src;
+ CLIPTYPE type;
+ int exif;
+};
+
+class ProjectItem;
+class ProjectListView;
+class Render;
+class KdenliveDoc;
+class DocClipBase;
+
+const int NameRole = Qt::UserRole;
+const int DurationRole = NameRole + 1;
+const int UsageRole = NameRole + 2;
+
+class InvalidDialog: public KDialog
+{
+ Q_OBJECT
+public:
+ InvalidDialog(const QString &caption, const QString &message, bool infoOnly, QWidget *parent = 0);
+ virtual ~InvalidDialog();
+ void addClip(const QString &id, const QString &path);
+ QStringList getIds() const;
+private:
+ QListWidget *m_clipList;
+};
+
+
+class ItemDelegate: public QStyledItemDelegate
+{
+public:
+ ItemDelegate(QAbstractItemView* parent = 0): QStyledItemDelegate(parent) {
+ }
+
+ /*void drawFocus(QPainter *, const QStyleOptionViewItem &, const QRect &) const {
+ }*/
+
+ void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
+ if (index.column() == 0 && !index.data(DurationRole).isNull()) {
+ QRect r1 = option.rect;
+ painter->save();
+ QStyleOptionViewItemV4 opt(option);
+ QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
+ style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
+
+ if (option.state & QStyle::State_Selected) {
+ painter->setPen(option.palette.highlightedText().color());
+ }
+ const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
+ QPixmap pixmap = qVariantValue<QPixmap>(index.data(Qt::DecorationRole));
+ painter->drawPixmap(r1.left() + textMargin, r1.top() + (r1.height() - pixmap.height()) / 2, pixmap);
+ int decoWidth = pixmap.width() + 2 * textMargin;
+
+ QFont font = painter->font();
+ font.setBold(true);
+ painter->setFont(font);
+ int mid = (int)((r1.height() / 2));
+ r1.adjust(decoWidth, 0, 0, -mid);
+ QRect r2 = option.rect;
+ r2.adjust(decoWidth, mid, 0, 0);
+ painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom , index.data().toString());
+ font.setBold(false);
+ painter->setFont(font);
+ QString subText = index.data(DurationRole).toString();
+ int usage = index.data(UsageRole).toInt();
+ if (usage != 0) subText.append(QString(" (%1)").arg(usage));
+ if (option.state & (QStyle::State_Selected)) painter->setPen(option.palette.color(QPalette::Mid));
+ QRectF bounding;
+ painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText, &bounding);
+
+ int proxy = index.data(Qt::UserRole + 5).toInt();
+ if (proxy != 0) {
+ QRectF txtBounding;
+ QString proxyText;
+ QBrush brush;
+ QColor color;
+ if (proxy > 0) {
+ proxyText = QString::number(proxy) + "% ";
+ proxyText.append(i18n("Generating proxy ..."));
+ brush = option.palette.highlight();
+ color = option.palette.color(QPalette::HighlightedText);
+
+ }
+ else if (proxy == PROXYDONE) {
+ proxyText = i18n("Proxy");
+ brush = option.palette.mid();
+ color = option.palette.color(QPalette::WindowText);
+ }
+ else {
+ switch (proxy) {
+ case CREATINGPROXY:
+ proxyText = i18n("Generating proxy ...");
+ break;
+ case PROXYWAITING:
+ proxyText = i18n("Waiting proxy ...");
+ break;
+ case PROXYCRASHED:
+ default:
+ proxyText = i18n("Proxy crashed");
+ }
+ brush = option.palette.highlight();
+ color = option.palette.color(QPalette::HighlightedText);
+ }
+
+ txtBounding = painter->boundingRect(r2, Qt::AlignRight | Qt::AlignVCenter, " " + proxyText + " ");
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(brush);
+ painter->drawRoundedRect(txtBounding, 2, 2);
+ painter->setPen(option.palette.highlightedText().color());
+ painter->drawText(txtBounding, Qt::AlignHCenter | Qt::AlignVCenter , proxyText);
+ }
+
+ painter->restore();
+ } else if (index.column() == 2 && KdenliveSettings::activate_nepomuk()) {
+ if (index.data().toString().isEmpty()) {
+ QStyledItemDelegate::paint(painter, option, index);
+ return;
+ }
+ QRect r1 = option.rect;
+ if (option.state & (QStyle::State_Selected)) {
+ painter->fillRect(r1, option.palette.highlight());
+ }
+#ifdef NEPOMUK
+ KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt());
+#endif
+ } else {
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+ }
+};