]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.h
Title clips now really usable (only transparency & duration change still missing)
[kdenlive] / src / projectlist.h
index 9628b3e49a78a25e98d44a4c170abd66476fc5ff..4bc08c82064224ce87a6e4f2e6f43dbe22bec3be 100644 (file)
 #include <QToolBar>
 #include <QTreeWidget>
 #include <QPainter>
+#include <QItemDelegate>
 
 #include <KUndoStack>
 #include <KTreeWidgetSearchLine>
-#include <KExtendableItemDelegate>
+#include <KUrl>
 
 #include "definitions.h"
-#include "kdenlivedoc.h"
-#include "renderer.h"
 #include "timecode.h"
-#include "projectlistview.h"
 
 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) {
+    }
+    /*
+    static_cast<ProjectItem *>( index.internalPointer() );
 
-  const int NameRole = Qt::UserRole;
-  const int DurationRole = NameRole + 1;
-  const int FullPathRole = NameRole + 2;
-  const int ClipTypeRole = NameRole + 3;
-
-class ItemDelegate: public KExtendableItemDelegate
-{
-  public:
-    ItemDelegate(QAbstractItemView* parent = 0): KExtendableItemDelegate(parent)
+    void expand()
     {
+      QWidget *w = new QWidget;
+      QVBoxLayout *layout = new QVBoxLayout;
+      layout->addWidget( new KColorButton(w));
+      w->setLayout( layout );
+      extendItem(w,
     }
-/*
-void expand()
-{
-  QWidget *w = new QWidget;
-  QVBoxLayout *layout = new QVBoxLayout;
-  layout->addWidget( new KColorButton(w)); 
-  w->setLayout( layout );
-  extendItem(w, 
-}
-*/
-
-void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
-{
-  if (index.column() == 1)
-  {
-    const bool hover = option.state & (QStyle::State_Selected|QStyle::State_MouseOver|QStyle::State_HasFocus);
-    QRect r1 = option.rect;
-    painter->save();
-    if (hover) {
-        painter->setPen(option.palette.color(QPalette::HighlightedText));
-        QColor backgroundColor = option.palette.color(QPalette::Highlight);
-        painter->setBrush(QBrush(backgroundColor));
-       painter->fillRect(r1, QBrush(backgroundColor));
+    */
+
+    void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
+        if (index.column() == 1) {
+            const bool hover = option.state & (QStyle::State_Selected);
+            QRect r1 = option.rect;
+            painter->save();
+            if (hover) {
+                painter->setPen(option.palette.color(QPalette::HighlightedText));
+                QColor backgroundColor = option.palette.color(QPalette::Highlight);
+                painter->setBrush(QBrush(backgroundColor));
+                painter->fillRect(r1, QBrush(backgroundColor));
+            }
+            QFont font = painter->font();
+            font.setPointSize(font.pointSize() - 1);
+            font.setBold(true);
+            painter->setFont(font);
+            int mid = (int)((r1.height() / 2));
+            r1.setBottom(r1.y() + mid);
+            QRect r2 = option.rect;
+            r2.setTop(r2.y() + mid);
+            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));
+            painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText);
+            painter->restore();
+        } else {
+            QItemDelegate::paint(painter, option, index);
+        }
     }
-    QFont font = painter->font();
-    font.setPointSize(font.pointSize() - 1 );
-    font.setBold(true);
-    painter->setFont(font);
-    int mid = (int) ((r1.height() / 2 ));
-    r1.setBottom(r1.y() + mid);
-    QRect r2 = option.rect;
-    r2.setTop(r2.y() + mid);
-    painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom , index.data().toString());
-    //painter->setPen(Qt::green);
-    font.setBold(false);
-    painter->setFont(font);
-    painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , index.data(DurationRole).toString());
-    painter->restore();
-  }
-  else
-  {
-    KExtendableItemDelegate::paint(painter, option, index);
-  }
-}
 };
 
-class ProjectList : public QWidget
-{
-  Q_OBJECT
-  
-  public:
-    ProjectList(QWidget *parent=0);
+class ProjectList : public QWidget {
+    Q_OBJECT
+
+public:
+    ProjectList(QWidget *parent = 0);
     virtual ~ProjectList();
 
     QDomElement producersList();
     void setRenderer(Render *projectRender);
 
     void addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url = KUrl(), const QString &group = QString::null, int parentId = -1);
-    void deleteClip(const int clipId);
+    void slotUpdateClipProperties(int id, QMap <QString, QString> properties);
 
-  public slots:
+public slots:
     void setDocument(KdenliveDoc *doc);
     void addProducer(QDomElement producer, int parentId = -1);
     void slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h);
     void slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
+    void slotAddClip(DocClipBase *clip);
+    void slotDeleteClip(int clipId);
+    void slotUpdateClip(int id);
+    void slotRefreshClipThumbnail(int clipId);
 
 
-  private:
+private:
     ProjectListView *listView;
     KTreeWidgetSearchLine *searchView;
     Render *m_render;
@@ -130,27 +133,30 @@ class ProjectList : public QWidget
     ProjectItem *getItemById(int id);
     QAction *m_editAction;
     QAction *m_deleteAction;
+    KdenliveDoc *m_doc;
     ItemDelegate *m_listViewDelegate;
 
-  private slots:
-    void slotAddClip(QUrl givenUrl = QUrl(), const QString &group = QString::null);
+private slots:
+    void slotAddClip(QUrl givenUrl = QUrl(), QString group = QString());
     void slotRemoveClip();
-    void slotEditClip();
     void slotClipSelected();
     void slotAddColorClip();
-    void slotEditClip(QTreeWidgetItem *, int);
-    void slotContextMenu( const QPoint &pos, QTreeWidgetItem * );
+    void slotAddTitleClip();
+    void slotContextMenu(const QPoint &pos, QTreeWidgetItem *);
     void slotAddFolder();
+    void slotAddFolder(const QString foldername, int clipId, bool remove, bool edit);
     /** This is triggered when a clip description has been modified */
-    void slotUpdateItemDescription(QTreeWidgetItem *item, int column);
+    void slotItemEdited(QTreeWidgetItem *item, int column);
+    void slotUpdateClipProperties(ProjectItem *item, QMap <QString, QString> properties);
     //void slotShowMenu(const QPoint &pos);
 
 
 
-  signals:
+signals:
     void clipSelected(const QDomElement &);
     void getFileProperties(const QDomElement&, int);
     void receivedClipDuration(int, int);
+    void showClipProperties(DocClipBase *);
 };
 
 #endif