]> git.sesse.net Git - kdenlive/commitdiff
Display clip usage
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 17 Feb 2008 15:39:28 +0000 (15:39 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 17 Feb 2008 15:39:28 +0000 (15:39 +0000)
svn path=/branches/KDE4/; revision=1856

src/customtrackview.cpp
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/projectitem.cpp
src/projectitem.h
src/projectlist.cpp
src/projectlist.h

index c03b44a6c0c627a443a600d001a749672938f12c..2cdd60cf75b2b3ad82d52ae78050d513d119727a 100644 (file)
@@ -352,6 +352,8 @@ void CustomTrackView::dropEvent ( QDropEvent * event ) {
   if (m_dropItem) {
     AddTimelineClipCommand *command = new AddTimelineClipCommand(this, m_dropItem->xml(), m_dropItem->clipProducer(), m_dropItem->track(), m_dropItem->startPos(), m_dropItem->rect(), m_dropItem->duration(), false);
     m_commandStack->push(command);
+    m_dropItem->baseClip()->addReference();
+    m_document->updateClip(m_dropItem->baseClip()->getId());
     kDebug()<<"IIIIIIIIIIIIIIIIIIIIIIII TRAX CNT: "<<m_tracksCount<<", DROP: "<<m_dropItem->track();
     m_document->renderer()->mltInsertClip(m_tracksCount - m_dropItem->track(), GenTime(m_dropItem->startPos(), 25), m_dropItem->xml());
   }
@@ -446,6 +448,8 @@ void CustomTrackView::deleteClip (int track, int startpos, const QRectF &rect )
     kDebug()<<"----------------  ERROR, CANNOT find clip to move at: "<<rect.x();
     return;
   }
+  item->baseClip()->removeReference();
+  m_document->updateClip(item->baseClip()->getId());
   delete item;
   m_document->renderer()->mltRemoveClip(m_tracksCount - track, GenTime(startpos, 25));
 }
@@ -456,6 +460,8 @@ void CustomTrackView::addClip ( QDomElement xml, int clipId, int track, int star
   DocClipBase *baseclip = m_document->clipManager()->getClipById(clipId);
   ClipItem *item = new ClipItem(baseclip, track, startpos, r, duration);
   scene()->addItem(item);
+  baseclip->addReference();
+  m_document->updateClip(baseclip->getId());
   m_document->renderer()->mltInsertClip(m_tracksCount - track, GenTime(startpos, 25), xml);
 }
 
index dad7c856c3f2b068626954a26ade4568dfcd0b5e..93eb9d2fc79c2d5261f3a0969ea53aff19c82143 100644 (file)
@@ -123,6 +123,11 @@ Render *KdenliveDoc::renderer()
   return m_render;
 }
 
+void KdenliveDoc::updateClip(int id)
+{
+  emit updateClipDisplay(id);
+}
+
 int KdenliveDoc::getFramePos(QString duration)
 {
   return m_timecode.getFrameCount(duration, m_fps);
index 2a435a828e970e2fa674c28a812166e7b164fa8d..be5c8331bba6851a1f4612e7482d14775ed239db 100644 (file)
@@ -62,6 +62,7 @@ class KdenliveDoc:public QObject {
     void deleteClip(const uint clipId);
     int getFramePos(QString duration);
     DocClipBase *getBaseClip(int clipId);
+    void updateClip(int id);
 
   private:
     KUrl m_url;
@@ -80,6 +81,7 @@ class KdenliveDoc:public QObject {
     
   signals:
     void addProjectClip(DocClipBase *);
+    void updateClipDisplay(int);
 };
 
 #endif
index 20f14176f109684c3c04de7c6894f45eb52e638a..59cfe52160dbc427366cb111cf873af0e7c3dd9b 100644 (file)
@@ -333,6 +333,8 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //chang
   connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
   connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
   connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
+  connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
+
 
   m_projectList->setDocument(doc);
   m_monitorManager->setTimecode(doc->timecode());
index 342496c9cebbcc24b6eace975844720e37e5af43..d58e23614e7298533448ffcb41ba64dd5c86b078 100644 (file)
@@ -34,8 +34,8 @@
 
   const int NameRole = Qt::UserRole;
   const int DurationRole = NameRole + 1;
-  const int FullPathRole = NameRole + 2;
-  const int ClipTypeRole = NameRole + 3;
+  const int UsageRole = NameRole + 2;
+
 
 ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId)
     : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(false), m_groupName(QString::null)
@@ -103,6 +103,12 @@ ProjectItem::~ProjectItem()
 {
 }
 
+int ProjectItem::numReferences() const
+{
+  if (!m_clip) return 0;
+  return m_clip->numReferences();
+}
+
 int ProjectItem::clipId() const
 {
   return m_clipId;
index 1cf05b7d4bdff866442e4c415d738a21c49925c5..ec6804ce452282a474532e93b492943cdb45cfb3 100644 (file)
@@ -40,6 +40,7 @@ class ProjectItem : public QTreeWidgetItem
     ProjectItem(QTreeWidget * parent, DocClipBase *clip);
     virtual ~ProjectItem();
     QDomElement toXml() const;
+    int numReferences() const;
 
     void setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata);
     int clipId() const;
index 24690255045128b60e19f193518e8a1fadcd7456..466e73dc682827817334b1c264da9708732b84ce 100644 (file)
@@ -232,7 +232,6 @@ void ProjectList::addClip(const QStringList &name, const QDomElement &elem, cons
   if (groupItem) item = new ProjectItem(groupItem, name, elem, clipId);
   else item = new ProjectItem(listView, name, elem, clipId);
   if (!url.isEmpty()) {
-    item->setData(1, FullPathRole, url.path());
     // if file has Nepomuk comment, use it
     Nepomuk::Resource f( url.path() );
     QString annotation = f.description();
@@ -295,15 +294,15 @@ void ProjectList::slotAddClip(DocClipBase *clip)
 {
   ProjectItem *item = new ProjectItem(listView, clip);
   listView->setCurrentItem(item);
-  /*
-  if (clip->clipType() != COLOR) {
-    Nepomuk::Resource f( clip->fileURL().path() );
-    QString annotation = f.description();
-    if (!annotation.isEmpty()) item->setText(2, annotation);
-  }*/
   emit getFileProperties(clip->toXML(), clip->getId());
 }
 
+void ProjectList::slotUpdateClip(int id)
+{
+  ProjectItem *item = getItemById(id);
+  item->setData(1, UsageRole, QString::number(item->numReferences()));
+}
+
 void ProjectList::slotAddClip(QUrl givenUrl, const QString &group)
 {
   if (!m_commandStack) kDebug()<<"!!!!!!!!!!!!!!!!  NO CMD STK";
@@ -431,15 +430,7 @@ void ProjectList::addProducer(QDomElement producer, int parentId)
       QStringList itemEntry;
       itemEntry.append(QString::null);
       itemEntry.append(resource.fileName());
-      addClip(itemEntry, producer, id, resource, groupName, parentId);
-      /*AddClipCommand *command = new AddClipCommand(this, itemEntry, producer, id, resource, true);
-      m_commandStack->push(command);*/
-
-
-      /*ProjectItem *item = new ProjectItem(listView, itemEntry, producer);
-      item->setData(1, FullPathRole, resource.path());
-      item->setData(1, ClipTypeRole, (int) type);*/
-      
+      addClip(itemEntry, producer, id, resource, groupName, parentId);  
     }
   }
   else if (type == COLOR) {
@@ -451,11 +442,6 @@ void ProjectList::addProducer(QDomElement producer, int parentId)
     itemEntry.append(QString::null);
     itemEntry.append(producer.attribute("name", i18n("Color clip")));
     addClip(itemEntry, producer, id, KUrl(), groupName, parentId);
-    /*AddClipCommand *command = new AddClipCommand(this, itemEntry, producer, id, KUrl(), true);
-    m_commandStack->push(command);*/
-    //ProjectItem *item = new ProjectItem(listView, itemEntry, producer);
-    /*item->setIcon(0, QIcon(pix));
-    item->setData(1, ClipTypeRole, (int) type);*/
   }
       
 }
index dc1fa24a278e61ae85af42f3b8461f33f8b26e56..3ab74f2624ba6d614e75918fd0ce70b1cdde7094 100644 (file)
@@ -40,8 +40,7 @@ class ProjectItem;
 
   const int NameRole = Qt::UserRole;
   const int DurationRole = NameRole + 1;
-  const int FullPathRole = NameRole + 2;
-  const int ClipTypeRole = NameRole + 3;
+  const int UsageRole = NameRole + 2;
 
 class ItemDelegate: public KExtendableItemDelegate
 {
@@ -85,7 +84,10 @@ void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIn
     //painter->setPen(Qt::green);
     font.setBold(false);
     painter->setFont(font);
-    painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , index.data(DurationRole).toString());
+    QString subText = index.data(DurationRole).toString();
+    QString usage = index.data(UsageRole).toString();
+    if (!usage.isEmpty()) subText.append(QString(" (%1)").arg(usage));
+    painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText);
     painter->restore();
   }
   else
@@ -115,6 +117,7 @@ class ProjectList : public QWidget
     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 slotUpdateClip(int id);
 
 
   private: