]> git.sesse.net Git - kdenlive/blobdiff - src/subprojectitem.cpp
Fix indent
[kdenlive] / src / subprojectitem.cpp
index 27894af788fa6e63da4bb1340d349ee5a52c791c..7b1f7450db93ac536663b68537d65bcebba08d6e 100644 (file)
 #include "kdenlivesettings.h"
 #include "docclipbase.h"
 
+
 #include <KDebug>
 #include <KLocale>
 #include <KIcon>
 
 const int DurationRole = Qt::UserRole + 1;
+const int itemHeight = 30;
 
-SubProjectItem::SubProjectItem(QTreeWidgetItem * parent, int in, int out) :
-        QTreeWidgetItem(parent, PROJECTSUBCLIPTYPE), m_in(in), m_out(out)
+SubProjectItem::SubProjectItem(double display_ratio, QTreeWidgetItem * parent, int in, int out, const QString &description) :
+        QTreeWidgetItem(parent, PROJECTSUBCLIPTYPE), m_in(in), m_out(out), m_description(description)
 {
-    setSizeHint(0, QSize(65, 30));
-    setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+    setSizeHint(0, QSize((int) (itemHeight * display_ratio) + 2, itemHeight + 2));
+    setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
     QString name = Timecode::getStringTimecode(in, KdenliveSettings::project_fps());
-    setText(1, name);
+    setText(0, name);
+    setText(1, description);
     GenTime duration = GenTime(out - in, KdenliveSettings::project_fps());
-    if (duration != GenTime()) setData(1, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
+    if (duration != GenTime()) setData(0, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
+    QPixmap pix((int) (itemHeight * display_ratio), itemHeight);
+    pix.fill(Qt::gray);
+    setData(0, Qt::DecorationRole, pix);
     //setFlags(Qt::NoItemFlags);
     //kDebug() << "Constructed with clipId: " << m_clipId;
 }
@@ -53,6 +59,12 @@ int SubProjectItem::numReferences() const
     return 0;
 }
 
+//static
+int SubProjectItem::itemDefaultHeight()
+{
+    return itemHeight;
+}
+
 QDomElement SubProjectItem::toXml() const
 {
     //return m_clip->toXML();
@@ -65,9 +77,28 @@ QPoint SubProjectItem::zone() const
     return z;
 }
 
+void SubProjectItem::setZone(const QPoint& p)
+{
+    m_in = p.x();
+    m_out = p.y();
+    QString name = Timecode::getStringTimecode(m_in, KdenliveSettings::project_fps());
+    setText(0, name);
+    GenTime duration = GenTime(m_out - m_in, KdenliveSettings::project_fps());
+    if (duration != GenTime()) setData(0, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
+}
+
 DocClipBase *SubProjectItem::referencedClip()
 {
     return NULL; //m_clip;
 }
 
+QString SubProjectItem::description() const
+{
+    return m_description;
+}
 
+void SubProjectItem::setDescription(const QString &desc)
+{
+    m_description = desc;
+    setText(1, m_description);
+}