+#include "kdenlivesettings.h"
+#include "folderprojectitem.h"
+#include "subprojectitem.h"
+
+namespace Mlt
+{
+class Producer;
+};
+
+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 ItemDelegate: public QItemDelegate
+{
+public:
+ ItemDelegate(QAbstractItemView* parent = 0): QItemDelegate(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();
+ if (option.state & (QStyle::State_Selected)) {
+ painter->setPen(option.palette.color(QPalette::HighlightedText));
+ painter->fillRect(r1, option.palette.highlight());
+ }
+ QStyleOptionViewItemV2 opt = setOptions(index, option);
+ QPixmap pixmap = decoration(opt, index.data(Qt::DecorationRole));
+ QRect decorationRect = pixmap.rect(); //QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect());
+ const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
+ decorationRect.moveTo(r1.topLeft() + QPoint(0, 1));
+ drawDecoration(painter, opt, decorationRect, 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());
+ //painter->setPen(Qt::green);
+ 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));
+ painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText);
+ painter->restore();
+ } else if (index.column() == 2 && KdenliveSettings::activate_nepomuk()) {
+ if (index.data().toString().isEmpty()) {
+ QItemDelegate::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 {
+ QItemDelegate::paint(painter, option, index);
+ }
+ }
+};