]> git.sesse.net Git - kdenlive/commitdiff
More work on timeline widget
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 25 Jan 2008 23:31:09 +0000 (23:31 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 25 Jan 2008 23:31:09 +0000 (23:31 +0000)
svn path=/branches/KDE4/; revision=1819

12 files changed:
src/CMakeLists.txt
src/addtimelineclipcommand.cpp
src/addtimelineclipcommand.h
src/clipitem.cpp
src/clipitem.h
src/customtrackview.cpp
src/customtrackview.h
src/kdenlivesettings.kcfg
src/kthumb.cpp [new file with mode: 0644]
src/kthumb.h [new file with mode: 0644]
src/labelitem.cpp
src/trackview.cpp

index 6a8c96377ee40aef7510237cba2824057c568291..a6800013d1b2c469c3fdde3c800176a0e84bd709 100644 (file)
@@ -56,6 +56,7 @@ set(kdenlive_SRCS
   moveclipcommand.cpp
   resizeclipcommand.cpp
   addtimelineclipcommand.cpp
+  kthumb.cpp
 )
 
 kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc )
index b8ab71b0c18f6855d1f7714a9fc79b17a0de0418..de33fa997fd1945bbabfede279fdf9e4346691dc 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "addtimelineclipcommand.h"
 
-AddTimelineClipCommand::AddTimelineClipCommand(CustomTrackView *view, int clipType, QString clipName, int clipProducer, int maxDuration, QRectF rect, bool doIt)
-         : m_view(view), m_clipType(clipType), m_clipName(clipName), m_clipProducer(clipProducer), m_maxDuration(maxDuration), m_clipRect(rect), m_doIt(doIt) {
+AddTimelineClipCommand::AddTimelineClipCommand(CustomTrackView *view, QDomElement xml, int track, int startpos, QRectF rect, int duration, bool doIt)
+         : m_view(view), m_xml(xml), m_clipTrack(track), m_clipPos(startpos), m_clipRect(rect), m_clipDuration(duration), m_doIt(doIt) {
            setText(i18n("Add timeline clip"));
         }
 
@@ -36,7 +36,7 @@ void AddTimelineClipCommand::undo()
 void AddTimelineClipCommand::redo()
 {
   //kDebug()<<"----  redoing action";
-  if (m_doIt) m_view->addClip(m_clipType, m_clipName, m_clipProducer, m_maxDuration, m_clipRect);
+  if (m_doIt) m_view->addClip(m_xml, m_clipTrack, m_clipPos, m_clipRect, m_clipDuration);
   m_doIt = true;
 }
 
index ad907a0211d7aafa9fa132b26d69bbfe3ef7700f..e163d810bf3644ba4923ba54067cde2c0553021d 100644 (file)
 class AddTimelineClipCommand : public QUndoCommand
  {
  public:
-     AddTimelineClipCommand(CustomTrackView *view, int clipType, QString clipName, int clipProducer, int maxDuration, QRectF rect, bool doIt);
+     AddTimelineClipCommand(CustomTrackView *view, QDomElement xml, int track, int startpos, QRectF rect, int duration, bool doIt);
     virtual void undo();
     virtual void redo();
 
  private:
      CustomTrackView *m_view;
-     int m_clipType;
-     QString m_clipName;
-     int m_clipProducer;
-     int m_maxDuration;
+     int m_clipDuration;
+     QDomElement m_xml;
+     int m_clipTrack;
+     int m_clipPos;
      QRectF m_clipRect;
      bool m_doIt;
  };
index a97ffb9add6ee1923ce38a07d4edace3c3dc4a5e..1e1049f5921f4879fa4432e3895fb793602501b1 100644 (file)
 
 
 #include <QPainter>
+#include <QTimer>
 #include <QStyleOptionGraphicsItem>
 #include <QGraphicsScene>
+
+
 #include <KDebug>
 
+#include <mlt++/Mlt.h>
 
 #include "clipitem.h"
+#include "renderer.h"
+#include "kdenlivesettings.h"
 
-ClipItem::ClipItem(int clipType, QString name, int producer, int maxDuration, const QRectF & rect)
-    : QGraphicsRectItem(rect), m_resizeMode(NONE), m_grabPoint(0), m_clipType(clipType), m_clipName(name), m_producer(producer), m_cropStart(0), m_cropDuration(maxDuration), m_maxDuration(maxDuration), m_maxTrack(0)
+ClipItem::ClipItem(QDomElement xml, int track, int startpos, const QRectF & rect, int duration)
+    : QGraphicsRectItem(rect), m_xml(xml), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_track(track), m_startPos(startpos)
 {
-  setToolTip(name);
+  //setToolTip(name);
+
+  m_clipName = xml.attribute("name");
+  if (m_clipName.isEmpty()) m_clipName = KUrl(xml.attribute("resource")).fileName();
+
+  m_producer = xml.attribute("id").toInt();
+
+  m_clipType = xml.attribute("type").toInt();
+
+  m_cropStart = xml.attribute("in", 0).toInt();
+  m_maxDuration = xml.attribute("duration", 0).toInt();
+  if (m_maxDuration == 0) m_maxDuration = xml.attribute("out", 0).toInt() - m_cropStart;
+
+  if (duration != -1) m_cropDuration = duration;
+  else m_cropDuration = m_maxDuration;
+
   //setCursor(Qt::SizeHorCursor);
   setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemClipsChildrenToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
-  m_label = new LabelItem( name, this);
+  m_label = new LabelItem( m_clipName, this);
   QRectF textRect = m_label->boundingRect();
   m_textWidth = textRect.width();
   m_label->setPos(rect.x() + rect.width()/2 - m_textWidth/2, rect.y() + rect.height() / 2 - textRect.height()/2);
   setBrush(QColor(100, 100, 150));
+  m_thumbProd = new KThumb(KUrl(xml.attribute("resource")));
+  connect(this, SIGNAL(getThumb(int, int, int, int)), m_thumbProd, SLOT(extractImage(int, int, int, int)));
+  connect(m_thumbProd, SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
+  QTimer::singleShot(300, this, SLOT(slotFetchThumbs())); 
+
+  //m_startPix.load("/home/one/Desktop/thumb.jpg");
+}
+
+void ClipItem::slotFetchThumbs()
+{
+  emit getThumb(m_cropStart, m_cropStart + m_cropDuration, 50 * KdenliveSettings::project_display_ratio(), 50);
+}
+
+void ClipItem::slotThumbReady(int frame, QPixmap pix)
+{
+  if (frame == m_cropStart) m_startPix = pix;
+  else m_endPix = pix;
+  update();
 }
 
 int ClipItem::type () const
@@ -45,6 +84,11 @@ int ClipItem::type () const
   return 70000;
 }
 
+QDomElement ClipItem::xml() const
+{
+  return m_xml;
+}
+
 int ClipItem::clipType()
 {
   return m_clipType;
@@ -65,34 +109,64 @@ int ClipItem::maxDuration()
   return m_maxDuration;
 }
 
+int ClipItem::duration()
+{
+  return m_cropDuration;
+}
+
+int ClipItem::startPos()
+{
+  return m_startPos;
+}
+
 // virtual 
  void ClipItem::paint(QPainter *painter,
                            const QStyleOptionGraphicsItem *option,
                            QWidget *widget)
  {
+    QRectF br = rect();
+    painter->setRenderHints(QPainter::Antialiasing);
+    QPainterPath roundRectPath;
+    double roundingY = 20;
+    double roundingX = 20;
+    double offset = 1;
+    painter->setClipRect(option->exposedRect);
+    if (roundingX > br.width() / 2) roundingX = br.width() / 2;
+    //kDebug()<<"-----PAINTING, SCAL: "<<scale<<", height: "<<br.height();
+    roundRectPath.moveTo(br.x() + br .width() - offset, br.y() + roundingY);
+    roundRectPath.arcTo(br.x() + br .width() - roundingX - offset, br.y(), roundingX, roundingY, 0.0, 90.0);
+    roundRectPath.lineTo(br.x() + roundingX, br.y());
+    roundRectPath.arcTo(br.x() + offset, br.y(), roundingX, roundingY, 90.0, 90.0);
+    roundRectPath.lineTo(br.x() + offset, br.y() + br.height() - roundingY);
+    roundRectPath.arcTo(br.x() + offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 180.0, 90.0);
+    roundRectPath.lineTo(br.x() + br .width() - roundingX, br.y() + br.height() - offset);
+    roundRectPath.arcTo(br.x() + br .width() - roundingX - offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 270.0, 90.0);
+    roundRectPath.closeSubpath();
+    painter->fillPath(roundRectPath, brush()); //, QBrush(QColor(Qt::red)));
+    painter->setClipPath(roundRectPath, Qt::IntersectClip);
+    painter->drawPixmap(QPointF(br.x() + br.width() - m_endPix.width(), br.y()), m_endPix);
+    QLineF l(br.x() + br.width() - m_endPix.width(), br.y(), br.x() + br.width() - m_endPix.width(), br.y() + br.height());
+    painter->drawLine(l);
 
-    //painter->setClipRect( option->exposedRect );
-    /*painter->setRenderHint(QPainter::TextAntialiasing);
-    painter->fillRect(rect(), QColor(200, 50, 50, 150));
-    QPointF pos = option->matrix.map(QPointF(1.0, 1.0));
-    //painter->setPen(QPen(Qt::black, 1.0 / option->levelOfDetail));
-    painter->setPen(QPen(Qt::black, 1.0 / pos.x()));
-    double scale = 1.0 / pos.x();
-    //QPointF size = option->matrix.map(QPointF(1, 1));
-    //double off = painter->pen().width();
-    QRectF br = boundingRect();
-    QRectF recta(rect().x(), rect().y(), scale,rect().height());
+    painter->drawPixmap(QPointF(br.x(), br.y()), m_startPix);
+    QLineF l2(br.x() + m_startPix.width(), br.y(), br.x() + m_startPix.width(), br.y() + br.height());
+    painter->drawLine(l2);
+    painter->setClipRect(option->exposedRect);
+    painter->drawPath(roundRectPath);
+    //painter->fillRect(QRect(br.x(), br.y(), roundingX, roundingY), QBrush(QColor(Qt::green)));
+
+    /*QRectF recta(rect().x(), rect().y(), scale,rect().height());
     painter->drawRect(recta);
-    //painter->drawLine(rect().x() + 1, rect().y(), rect().x() + 1, rect().y() + rect().height());
+    painter->drawLine(rect().x() + 1, rect().y(), rect().x() + 1, rect().y() + rect().height());
     painter->drawLine(rect().x() + rect().width(), rect().y(), rect().x() + rect().width(), rect().y() + rect().height());
-    painter->setPen(QPen(Qt::black, 1.0 / pos.y()));
+    painter->setPen(QPen(Qt::black, 1.0));
     painter->drawLine(rect().x(), rect().y(), rect().x() + rect().width(), rect().y());
     painter->drawLine(rect().x(), rect().y() + rect().height(), rect().x() + rect().width(), rect().y() + rect().height());*/
 
-    QGraphicsRectItem::paint(painter, option, widget);
+    //QGraphicsRectItem::paint(painter, option, widget);
     //QPen pen(Qt::green, 1.0 / size.x() + 0.5);
     //painter->setPen(pen);
-    //painter->drawLine(rect().x(), rect().y(), rect().x() + rect().width(), rect().y());*/
+    //painter->drawLine(rect().x(), rect().y(), rect().x() + rect().width(), rect().y());
     //kDebug()<<"ITEM REPAINT RECT: "<<boundingRect().width();
     //painter->drawText(rect(), Qt::AlignCenter, m_name);
     // painter->drawRect(boundingRect());
@@ -113,6 +187,7 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
     return MOVE;
 }
 
+
 // virtual
  void ClipItem::mousePressEvent ( QGraphicsSceneMouseEvent * event ) 
  {
@@ -131,17 +206,18 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
     QGraphicsRectItem::mouseReleaseEvent(event);
  }
 
- void ClipItem::moveTo(double x, double offset)
+ void ClipItem::moveTo(double x, double scale, double offset, int newTrack)
  {
   double origX = rect().x();
   double origY = rect().y();
-    setRect(x, origY + offset, rect().width(), rect().height());
-
-    QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
-    for (int i = 0; i < collisionList.size(); ++i) {
-      QGraphicsItem *item = collisionList.at(i);
-      if (item->type() == 70000)
-      {
+  bool success = true;
+  setRect(x, origY + offset, rect().width(), rect().height());
+  QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
+  if (collisionList.size() == 0) m_track = newTrack;
+  for (int i = 0; i < collisionList.size(); ++i) {
+    QGraphicsItem *item = collisionList.at(i);
+    if (item->type() == 70000)
+    {
        if (offset == 0)
        {
          QRectF other = ((QGraphicsRectItem *)item)->rect();
@@ -157,11 +233,15 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
        setRect(origX, origY, rect().width(), rect().height());
        offset = 0;
        origX = rect().x();
+       success = false;
        break;
       }
     }
-
-    QList <QGraphicsItem *> childrenList = children();
+    if (success) {
+       m_track = newTrack;
+       m_startPos = x / scale;
+    }
+    QList <QGraphicsItem *> childrenList = QGraphicsItem::children();
     for (int i = 0; i < childrenList.size(); ++i) {
       childrenList.at(i)->moveBy(rect().x() - origX , offset);
     }
@@ -192,7 +272,7 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
            break;
          }
       }
-      QList <QGraphicsItem *> childrenList = children();
+      QList <QGraphicsItem *> childrenList = QGraphicsItem::children();
       for (int i = 0; i < childrenList.size(); ++i) {
        childrenList.at(i)->moveBy((moveX - originalX) / 2 , 0);
       }
@@ -216,13 +296,13 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
          }
       }
 
-      QList <QGraphicsItem *> childrenList = children();
+      QList <QGraphicsItem *> childrenList = QGraphicsItem::children();
       for (int i = 0; i < childrenList.size(); ++i) {
        childrenList.at(i)->moveBy((newWidth - originalWidth) / 2 , 0);
       }
       return;
     }
-    if (m_resizeMode == MOVE) {
+    /*if (m_resizeMode == MOVE) {
       kDebug()<<"///////  MOVE CLIP, EVENT Y: "<<event->scenePos().y()<<", SCENE HEIGHT: "<<scene()->sceneRect().height();
       int moveTrack = (int) event->scenePos().y() / 50;
       int currentTrack = (int) rect().y() / 50;
@@ -233,9 +313,19 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
       }
       if (offset != 0) offset = 50 * offset;
       moveTo(moveX - m_grabPoint, offset);
-    }
+    }*/
  }
 
+int ClipItem::track()
+{
+  return  m_track;
+}
+
+void ClipItem::setTrack(int track)
+{
+  m_track = track;
+}
+
 
 // virtual 
 /*
index 9f548a000fc2237089d8346ee62fbd8022d41235..853c24e0c03060727a2def6504568b39a5a3ccbf 100644 (file)
 #define CLIPITEM_H
 
 #include <QGraphicsRectItem>
+#include <QDomElement>
 #include <QGraphicsSceneMouseEvent>
 
 #include "labelitem.h"
 #include "definitions.h"
+#include "kthumb.h"
 
-class ClipItem : public QGraphicsRectItem
+
+class ClipItem : public QObject, public QGraphicsRectItem
 {
-  
+  Q_OBJECT
+
   public:
-    ClipItem(int clipType, QString name, int producer, int maxDuration, const QRectF & rect);
+    ClipItem(QDomElement xml, int track, int startpos, const QRectF & rect, int duration = -1);
     virtual void paint(QPainter *painter,
                            const QStyleOptionGraphicsItem *option,
                            QWidget *widget);
     virtual int type () const;
-    void moveTo(double x, double offset);
+    void moveTo(double x, double scale, double offset, int newTrack);
     OPERATIONTYPE operationMode(QPointF pos);
     int clipProducer();
     int clipType();
     QString clipName();
     int maxDuration();
+    int track();
+    void setTrack(int track);
+    int startPos();
+    int duration();
+    QDomElement xml() const;
 
   protected:
     virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
@@ -49,6 +58,7 @@ class ClipItem : public QGraphicsRectItem
     virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
 
   private:
+    QDomElement m_xml;
     LabelItem *m_label;
     int m_textWidth;
     OPERATIONTYPE m_resizeMode;
@@ -60,6 +70,19 @@ class ClipItem : public QGraphicsRectItem
     int m_cropStart;
     int m_cropDuration;
     int m_maxTrack;
+    int m_track;
+    int m_startPos;
+    QPixmap m_startPix;
+    QPixmap m_endPix;
+    KThumb *m_thumbProd;
+
+  private slots:
+    void slotThumbReady(int frame, QPixmap pix);
+    void slotFetchThumbs();
+
+  signals:
+    void getThumb(int, int, int, int);
+
 };
 
 #endif
index cee97f92c09ff691e966bc90f3575b5554dafd9f..d92fcd5427d0630659fbff5f2fa490e1f9f97b21 100644 (file)
@@ -35,7 +35,7 @@
 #include "addtimelineclipcommand.h"
 
 CustomTrackView::CustomTrackView(KUndoStack *commandStack, QGraphicsScene * projectscene, QWidget *parent)
-    : QGraphicsView(projectscene, parent), m_commandStack(commandStack), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0)
+    : QGraphicsView(projectscene, parent), m_commandStack(commandStack), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0)
 {
   setMouseTracking(true);
   setAcceptDrops(true);
@@ -47,6 +47,7 @@ CustomTrackView::CustomTrackView(KUndoStack *commandStack, QGraphicsScene * proj
   setContentsMargins(0, 0, 0, 0);
   if (projectscene) {
     m_cursorLine = projectscene->addLine(0, 0, 0, 50);
+    m_cursorLine->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIgnoresTransformations);
     m_cursorLine->setZValue(1000);
   }
 }
@@ -86,8 +87,23 @@ void CustomTrackView::mouseMoveEvent ( QMouseEvent * event )
     setDragMode(QGraphicsView::RubberBandDrag);
   else*/ {
 
-      if (event->button() == Qt::LeftButton) {
+      if (m_dragItem) { //event->button() == Qt::LeftButton) {
        // a button was pressed, delete visual tips
+
+if (m_operationMode == MOVE) {
+      int moveX = mapToScene(event->pos()).x();
+      //kDebug()<<"///////  MOVE CLIP, EVENT Y: "<<event->scenePos().y()<<", SCENE HEIGHT: "<<scene()->sceneRect().height();
+      int moveTrack = (int)  mapToScene(event->pos()).y() / 50;
+      int currentTrack = m_dragItem->track();
+
+      if (moveTrack > m_tracksCount - 1) moveTrack = m_tracksCount - 1;
+      else if (moveTrack < 0) moveTrack = 0;
+
+      int offset = moveTrack - currentTrack;
+      if (offset != 0) offset = 50 * offset;
+      m_dragItem->moveTo(moveX - m_clickPoint, m_scale, offset, moveTrack);
+  }
+
        if (m_animation) delete m_animation;
        m_animation = NULL;
        if (m_visualTip) delete m_visualTip;
@@ -238,8 +254,9 @@ void CustomTrackView::mousePressEvent ( QMouseEvent * event )
     if (item && item->type() != 70000) item = item->parentItem();
     if (item && item->type() == 70000) {
       m_dragItem = (ClipItem *) item;
+      m_clickPoint = mapToScene(event->pos()).x() - m_dragItem->startPos() * m_scale;
       m_operationMode = m_dragItem->operationMode(item->mapFromScene(mapToScene(event->pos())));
-      if (m_operationMode == MOVE || m_operationMode == RESIZESTART) m_startPos = QPointF(m_dragItem->rect().x(), m_dragItem->rect().y());
+      if (m_operationMode == MOVE || m_operationMode == RESIZESTART) m_startPos = QPointF(m_dragItem->startPos(), m_dragItem->track());
       else if (m_operationMode == RESIZEEND) m_startPos = QPointF(m_dragItem->rect().x() + m_dragItem->rect().width(), m_dragItem->rect().y());
 
      kDebug()<<"//////// ITEM CLICKED: "<<m_startPos;
@@ -287,9 +304,7 @@ void CustomTrackView::addItem(QString producer, QPoint pos)
   if (out == 0) out = elem.attribute("out", 0).toInt() - in;
   kDebug()<<"ADDING CLIP: "<<producer<<", OUT: "<<out<<", POS: "<<mapToScene(pos);
   int trackTop = ((int) mapToScene(pos).y()/50) * 50 + 1;
-  QString clipName = elem.attribute("name");
-  if (clipName.isEmpty()) clipName = KUrl(elem.attribute("resource")).fileName();
-  m_dropItem = new ClipItem(elem.attribute("type").toInt(), clipName, elem.attribute("id").toInt(), out, QRectF(mapToScene(pos).x(), trackTop, out, 49));
+  m_dropItem = new ClipItem(elem, ((int) mapToScene(pos).y()/50), in, QRectF(mapToScene(pos).x() * m_scale, trackTop, out * m_scale, 49));
   scene()->addItem(m_dropItem);
 }
 
@@ -297,14 +312,15 @@ void CustomTrackView::addItem(QString producer, QPoint pos)
 void CustomTrackView::dragMoveEvent(QDragMoveEvent * event) {
   event->setDropAction(Qt::IgnoreAction);
   if (m_dropItem) {
-    int trackTop = ((int) mapToScene(event->pos()).y()/50) * 50 + 1;
-    m_dropItem->moveTo(mapToScene(event->pos()).x(), trackTop - m_dropItem->rect().y());
+    int track = (int) mapToScene(event->pos()).y()/50; //) * (m_scale * 50) + m_scale;
+     kDebug()<<"+++++++++++++   DRAG MOVE, : "<<mapToScene(event->pos()).x()<<", SCAL: "<<m_scale;
+    m_dropItem->moveTo(mapToScene(event->pos()).x(), m_scale, (track - m_dropItem->track()) * 50, track);
+  }
+       //if (item) {
+  event->setDropAction(Qt::MoveAction);
+  if (event->mimeData()->hasText()) {
+    event->acceptProposedAction();
   }
-        //if (item) {
-                event->setDropAction(Qt::MoveAction);
-                if (event->mimeData()->hasText()) {
-                        event->acceptProposedAction();
-                }
         //}
 }
 
@@ -317,7 +333,7 @@ void CustomTrackView::dragLeaveEvent ( QDragLeaveEvent * event ) {
 
 void CustomTrackView::dropEvent ( QDropEvent * event ) {
   if (m_dropItem) {
-    AddTimelineClipCommand *command = new AddTimelineClipCommand(this, m_dropItem->clipType(), m_dropItem->clipName(), m_dropItem->clipProducer(), m_dropItem->maxDuration(), m_dropItem->rect(), false);
+    AddTimelineClipCommand *command = new AddTimelineClipCommand(this, m_dropItem->xml(), m_dropItem->track(), m_dropItem->startPos(), m_dropItem->rect(), m_dropItem->duration(), false);
     m_commandStack->push(command);
   }
   m_dropItem = NULL;
@@ -380,7 +396,7 @@ void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event )
   //kDebug()<<"/// MOVING CLIP: "<<m_startPos<<", END: "<<QPoint(m_dragItem->rect().x(),m_dragItem->rect().y());
   if (m_operationMode == MOVE) {
     // move clip
-    MoveClipCommand *command = new MoveClipCommand(this, m_startPos, QPointF(m_dragItem->rect().x(), m_dragItem->rect().y()), false);
+    MoveClipCommand *command = new MoveClipCommand(this, m_startPos, QPointF(m_dragItem->startPos(), m_dragItem->track()), false);
     m_commandStack->push(command);
   }
   else if (m_operationMode == RESIZESTART) {
@@ -393,6 +409,7 @@ void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event )
     ResizeClipCommand *command = new ResizeClipCommand(this, m_startPos, QPointF(m_dragItem->rect().x() + m_dragItem->rect().width(), m_dragItem->rect().y()), false, false);
     m_commandStack->push(command);
   }
+  m_dragItem = NULL; 
 }
 
 void CustomTrackView::deleteClip ( const QRectF &rect )
@@ -405,24 +422,27 @@ void CustomTrackView::deleteClip ( const QRectF &rect )
   delete item;
 }
 
-void CustomTrackView::addClip ( int clipType, QString clipName, int clipProducer, int maxDuration, const QRectF &rect )
+void CustomTrackView::addClip ( QDomElement xml, int track, int startpos, const QRectF &rect, int duration )
 {
-  ClipItem *item = new ClipItem(clipType, clipName, clipProducer, maxDuration, rect);
+  QRect r(startpos * m_scale, 50 * track, duration * m_scale, 49); 
+  ClipItem *item = new ClipItem(xml, track, startpos, r, duration);
   scene()->addItem(item);
 }
 
 void CustomTrackView::moveClip ( const QPointF &startPos, const QPointF &endPos )
 {
-  ClipItem *item = (ClipItem *) scene()->itemAt(startPos.x() + 1, startPos.y() + 1);
+  ClipItem *item = (ClipItem *) scene()->itemAt((startPos.x() + 1) * m_scale, startPos.y() * 50 + 25);
   if (!item) {
-    kDebug()<<"----------------  ERROR, CANNOT find clip to move at: "<<startPos;
+    kDebug()<<"----------------  ERROR, CANNOT find clip to move at: "<<startPos.x() * m_scale * FRAME_SIZE + 1<<", "<<startPos.y() * 50 + 25;
     return;
   }
-  item->setRect(QRectF(endPos.x(), endPos.y(), item->rect().width(), item->rect().height()));
-  QList <QGraphicsItem *> childrenList = item->children();
+  kDebug()<<"----------------  Move CLIP FROM: "<<startPos.x()<<", END:"<<endPos.x();
+  //item->setRect(QRectF(endPos.x() * m_scale, endPos.y() * 50, item->rect().width(), item->rect().height()));
+  item->moveTo(endPos.x() * m_scale, m_scale, (endPos.y() - startPos.y()) * 50, endPos.y());
+  /*QList <QGraphicsItem *> childrenList = item->children();
   for (int i = 0; i < childrenList.size(); ++i) {
-    childrenList.at(i)->moveBy(endPos.x() - startPos.x() , endPos.y() - startPos.y());
-  }
+    childrenList.at(i)->moveBy((endPos.x() - startPos.x()) * m_scale , (endPos.y() - startPos.y()) * 50);
+  }*/
 }
 
 void CustomTrackView::resizeClip ( const QPointF &startPos, const QPointF &endPos, bool resizeClipStart )
@@ -438,7 +458,7 @@ void CustomTrackView::resizeClip ( const QPointF &startPos, const QPointF &endPo
   qreal diff = endPos.x() - startPos.x();
   if (resizeClipStart) {
     item->setRect(QRectF(endPos.x(), endPos.y(), item->rect().width() - diff, item->rect().height()));
-    QList <QGraphicsItem *> childrenList = item->children();
+    QList <QGraphicsItem *> childrenList = item->QGraphicsItem::children();
     for (int i = 0; i < childrenList.size(); ++i) {
       childrenList.at(i)->moveBy(diff / 2 , endPos.y() - startPos.y());
     }
@@ -446,7 +466,7 @@ void CustomTrackView::resizeClip ( const QPointF &startPos, const QPointF &endPo
   else {
     //kdDebug()<<"///////  RESIZE CLIP END: "<<item->rect().x()<<", "<<item->rect().width()<<", "<<startPos<<", "<<endPos;
     item->setRect(QRectF(item->rect().x(), item->rect().y(), endPos.x() - item->rect().x(), item->rect().height()));
-    QList <QGraphicsItem *> childrenList = item->children();
+    QList <QGraphicsItem *> childrenList = item->QGraphicsItem::children();
     for (int i = 0; i < childrenList.size(); ++i) {
       childrenList.at(i)->moveBy(-diff/2, endPos.y() - startPos.y());
     }
@@ -454,21 +474,43 @@ void CustomTrackView::resizeClip ( const QPointF &startPos, const QPointF &endPo
 }
 
 
+void CustomTrackView::setScale(double scaleFactor)
+{
+  //scale(scaleFactor, scaleFactor);
+  m_scale = scaleFactor;
+  kDebug()<<" HHHHHHHH  SCALING: "<<m_scale;
+  QList<QGraphicsItem *> itemList = items();
+
+  for (int i = 0; i < itemList.count(); i++) {
+      if (itemList.at(i)->type() == 70000) {
+       ClipItem *clip = (ClipItem *)itemList.at(i);
+       clip->setRect(clip->startPos() * m_scale, clip->rect().y(), clip->duration() * m_scale, clip->rect().height());
+      }
+      else if (itemList.at(i)->type() == 70001) {
+       LabelItem *label = (LabelItem *)itemList.at(i);
+       QGraphicsItem *parent = label->parentItem();
+       QRectF r = label->boundingRect();
+       QRectF p = parent->boundingRect();
+       label->setPos(p.x() + p.width() / 2 - r.width() / 2, p.y() + p.height() / 2 - r.height() / 2);
+       //label->setRect(clip->startPos() * m_scale, clip->rect().y(), clip->duration() * m_scale, clip->rect().height());
+      }
+    }
+}
+
 void CustomTrackView::drawBackground ( QPainter * painter, const QRectF & rect )  
 {
-  kDebug()<<"/////  DRAWING BG TRACKS: "<<m_tracksCount;
   QColor base = palette().button().color();
   painter->setPen(base);
   painter->setClipRect(rect);
   painter->drawLine(0, 0, rect.width(), 0);
     for (uint i = 0; i < m_tracksCount;i++)
     {
-    painter->drawLine(0, 50 * (i+1), rect.width(), 50 * (i+1));
+    painter->drawLine(0, 50 * (i+1), width(), 50 * (i+1));
       //painter->drawText(QRectF(10, 50 * i, 100, 50 * i + 49), Qt::AlignLeft, i18n(" Track ") + QString::number(i));
     }
   int lowerLimit = 50 * m_tracksCount;
   if (height() > lowerLimit)
-  painter->fillRect(QRectF(0, lowerLimit - rect.y(), rect.width(), height() - lowerLimit - rect.y()), QBrush(base));
+  painter->fillRect(QRectF(0, lowerLimit, rect.width(), height() - lowerLimit), QBrush(base));
 }
 /*
 void CustomTrackView::drawForeground ( QPainter * painter, const QRectF & rect )  
index 23cf3e10b07e7f448aec8360981a1f956740c7d7..4ee97e3185bc10b2487dfa1ed01edebe26810de4 100644 (file)
@@ -44,9 +44,10 @@ class CustomTrackView : public QGraphicsView
     void initView();
     void moveClip ( const QPointF &startPos, const QPointF &endPos );
     void resizeClip ( const QPointF &startPos, const QPointF &endPos, bool resizeClipStart );
-    void addClip ( int clipType, QString clipName, int clipProducer, int maxDuration, const QRectF &rect );
+    void addClip ( QDomElement xml, int track, int startpos, const QRectF &rect, int duration);
     void deleteClip ( const QRectF &rect );
     void setDuration(int duration);
+    void setScale(double scaleFactor);
 
   public slots:
     void setCursorPos(int pos);
@@ -79,6 +80,8 @@ class CustomTrackView : public QGraphicsView
     QGraphicsItemAnimation *m_animation;
     QTimeLine *m_animationTimer;
     QColor m_tipColor;
+    double m_scale;
+    int m_clickPoint;
 
   signals:
     void cursorMoved(int);
index ecac237408380f75a3df1c03e2ccb9e6fb4af9a2..f7875f8adcd48cf534ee604b47f07b60ab28f49f 100644 (file)
       <default>00:00:05:00</default>
     </entry>
   </group>
+
+  <group name="unmanaged">
+    <entry name="project_display_ratio" type="Double">
+      <label>Current project display ratio.</label>
+      <default>1.7777778</default>
+    </entry>
+  </group>
 </kcfg>
\ No newline at end of file
diff --git a/src/kthumb.cpp b/src/kthumb.cpp
new file mode 100644 (file)
index 0000000..7030071
--- /dev/null
@@ -0,0 +1,323 @@
+/***************************************************************************
+                        krender.cpp  -  description
+                           -------------------
+  begin                : Fri Nov 22 2002
+  copyright            : (C) 2002 by Jason Wood
+  email                : jasonwood@blueyonder.co.uk
+  copyright            : (C) 2005 Lcio Fl�io Corr� 
+  email                : lucio.correa@gmail.com
+  copyright            : (C) Marco Gittler
+  email                : g.marco@freenet.de
+
+***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include <qapplication.h>
+
+#include <kio/netaccess.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kdenlivesettings.h>
+#include <kfileitem.h>
+#include <kmessagebox.h>
+
+#include <mlt++/Mlt.h>
+
+#include <qxml.h>
+#include <qimage.h>
+#include <qlabel.h>
+#include <qthread.h>
+#include <qapplication.h>
+
+
+
+#include "renderer.h"
+#include "kthumb.h"
+
+/*
+    void MyThread::init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth)
+    {
+       stop_me = false;
+       m_isWorking = false;
+       f.setName(target);
+       m_url = url;
+       m_frame = frame;
+       m_frameLength = frameLength;
+       m_frequency = frequency;
+       m_channels = channels;
+       m_arrayWidth = arrayWidth;
+
+    }
+
+    bool MyThread::isWorking()
+    {
+       return m_isWorking;
+    }
+
+    void MyThread::run()
+    {
+               if (!f.open( IO_WriteOnly )) {
+                       kdDebug()<<"++++++++  ERROR WRITING TO FILE: "<<f.name()<<endl;
+                       kdDebug()<<"++++++++  DISABLING AUDIO THUMBS"<<endl;
+                       KdenliveSettings::setAudiothumbnails(false);
+                       return;
+               }
+               m_isWorking = true;
+               char *tmp = KRender::decodedString(m_url.path());
+               Mlt::Producer m_producer(tmp);
+               delete tmp;
+
+               if (KdenliveSettings::normaliseaudiothumbs()) {
+                   Mlt::Filter m_convert("volume");
+                   m_convert.set("gain", "normalise");
+                   m_producer.attach(m_convert);
+               }
+
+               if (qApp->mainWidget()) 
+                   QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(-1, 10005));
+
+               int last_val = 0;
+               int val = 0;
+               for (int z=(int) m_frame;z<(int) (m_frame+m_frameLength) && m_producer.is_valid();z++){
+                       if (stop_me) break;
+                       val=(int)((z-m_frame)/(m_frame+m_frameLength)*100.0);
+                       if (last_val!=val & val > 1){
+                               QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(val, 10005));
+                               last_val=val;
+                       }
+                               m_producer.seek( z );
+                               Mlt::Frame *mlt_frame = m_producer.get_frame();
+                               if ( mlt_frame->is_valid() )
+                               {
+                                       double m_framesPerSecond = mlt_producer_get_fps( m_producer.get_producer() ); //mlt_frame->get_double( "fps" );
+                                       int m_samples = mlt_sample_calculator( m_framesPerSecond, m_frequency, mlt_frame_get_position(mlt_frame->get_frame()) );
+                                       mlt_audio_format m_audioFormat = mlt_audio_pcm;
+                               
+                                       int16_t* m_pcm = mlt_frame->get_audio(m_audioFormat, m_frequency, m_channels, m_samples ); 
+
+                                       for (int c=0;c< m_channels;c++){
+                                               QByteArray m_array(m_arrayWidth);
+                                               for (uint i = 0; i < m_array.size(); i++){
+                                                       m_array[i] =  QABS((*( m_pcm + c + i * m_samples / m_array.size() ))>>8);
+                                               }
+                                               f.writeBlock(m_array);
+                                       }
+                               } else{
+                                       f.writeBlock(QByteArray(m_arrayWidth));
+                               }
+                               if (mlt_frame)
+                                       delete mlt_frame;
+               }
+               f.close();
+               m_isWorking = false;
+               if (stop_me) {
+                   f.remove();
+                   QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(-1, 10005));
+               }
+               else QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(0, 10005));
+    }
+
+
+#define _S(a)           (a)>255 ? 255 : (a)<0 ? 0 : (a)
+#define _R(y,u,v) (0x2568*(y)                          + 0x3343*(u)) /0x2000
+#define _G(y,u,v) (0x2568*(y) - 0x0c92*(v) - 0x1a1e*(u)) /0x2000
+#define _B(y,u,v) (0x2568*(y) + 0x40cf*(v))                                          /0x2000
+*/
+KThumb::KThumb(KUrl url, QObject * parent, const char *name):QObject(parent), m_url(url)
+{
+}
+
+KThumb::~KThumb()
+{
+    //if (thumbProducer.running ()) thumbProducer.exit();
+}
+
+void KThumb::extractImage(int frame, int frame2, int width, int height)
+{
+    if (m_url.isEmpty()) return;
+    QPixmap pix(width, height);
+    char *tmp = Render::decodedString(m_url.path());
+    Mlt::Producer m_producer(tmp);
+    delete tmp;
+    pix.fill(Qt::black);
+
+    if (m_producer.is_blank()) {
+       emit thumbReady(frame, pix);
+       return;
+    }
+
+    mlt_image_format format = mlt_image_rgb24a;
+    Mlt::Filter m_convert("avcolour_space");
+    m_convert.set("forced", mlt_image_rgb24a);
+    m_producer.attach(m_convert);
+    m_producer.seek(frame);
+    Mlt::Frame * m_frame = m_producer.get_frame();
+
+    if (m_frame && m_frame->is_valid()) {
+      uint8_t *thumb = m_frame->get_image(format, width, height);
+      QImage image(thumb, width, height, QImage::Format_ARGB32);
+  
+      if (!image.isNull()) {
+       pix = pix.fromImage(image);
+      }
+      else pix.fill(Qt::black);
+    }
+    if (m_frame) delete m_frame;
+    emit thumbReady(frame, pix);
+
+    if (frame2 == -1) return;
+    m_producer.seek(frame2);
+    m_frame = m_producer.get_frame();
+    if (m_frame && m_frame->is_valid()) {
+      uint8_t *thumb = m_frame->get_image(format, width, height);
+      QImage image(thumb, width, height, QImage::Format_ARGB32);
+  
+      if (!image.isNull()) {
+       pix = pix.fromImage(image);
+      }
+      else pix.fill(Qt::black);
+    }
+    if (m_frame) delete m_frame;
+    emit thumbReady(frame2, pix);
+
+}
+/*
+void KThumb::getImage(KUrl url, int frame, int width, int height)
+{
+    if (url.isEmpty()) return;
+    QPixmap image(width, height);
+    char *tmp = KRender::decodedString(url.path());
+    Mlt::Producer m_producer(tmp);
+    delete tmp;
+    image.fill(Qt::black);
+
+    if (m_producer.is_blank()) {
+       emit thumbReady(frame, image);
+       return;
+    }
+    Mlt::Filter m_convert("avcolour_space");
+    m_convert.set("forced", mlt_image_rgb24a);
+    m_producer.attach(m_convert);
+    m_producer.seek(frame);
+    Mlt::Frame * m_frame = m_producer.get_frame();
+    mlt_image_format format = mlt_image_rgb24a;
+    width = width - 2;
+    height = height - 2;
+    if (m_frame && m_frame->is_valid()) {
+       uint8_t *thumb = m_frame->get_image(format, width, height);
+       QImage tmpimage(thumb, width, height, 32, NULL, 0, QImage::IgnoreEndian);
+       if (!tmpimage.isNull()) bitBlt(&image, 1, 1, &tmpimage, 0, 0, width + 2, height + 2);
+    }
+    if (m_frame) delete m_frame;
+    emit thumbReady(frame, image);
+}
+
+void KThumb::getThumbs(KUrl url, int startframe, int endframe, int width, int height)
+{
+    if (url.isEmpty()) return;
+    QPixmap image(width, height);
+    char *tmp = KRender::decodedString(url.path());
+    Mlt::Producer m_producer(tmp);
+    delete tmp;
+    image.fill(Qt::black);
+
+    if (m_producer.is_blank()) {
+       emit thumbReady(startframe, image);
+       emit thumbReady(endframe, image);
+       return;
+    }
+    Mlt::Filter m_convert("avcolour_space");
+    m_convert.set("forced", mlt_image_rgb24a);
+    m_producer.attach(m_convert);
+    m_producer.seek(startframe);
+    Mlt::Frame * m_frame = m_producer.get_frame();
+    mlt_image_format format = mlt_image_rgb24a;
+    width = width - 2;
+    height = height - 2;
+
+    if (m_frame && m_frame->is_valid()) {
+       uint8_t *thumb = m_frame->get_image(format, width, height);
+       QImage tmpimage(thumb, width, height, 32, NULL, 0, QImage::IgnoreEndian);
+       if (!tmpimage.isNull()) bitBlt(&image, 1, 1, &tmpimage, 0, 0, width - 2, height - 2);
+    }
+    if (m_frame) delete m_frame;
+    emit thumbReady(startframe, image);
+
+    image.fill(Qt::black);
+    m_producer.seek(endframe);
+    m_frame = m_producer.get_frame();
+
+    if (m_frame && m_frame->is_valid()) {
+       uint8_t *thumb = m_frame->get_image(format, width, height);
+       QImage tmpimage(thumb, width, height, 32, NULL, 0, QImage::IgnoreEndian);
+       if (!tmpimage.isNull()) bitBlt(&image, 1, 1, &tmpimage, 0, 0, width - 2, height - 2);
+    }
+    if (m_frame) delete m_frame;
+    emit thumbReady(endframe, image);
+}
+
+void KThumb::stopAudioThumbs()
+{
+       if (thumbProducer.running ()) thumbProducer.stop_me = true;
+}
+
+
+void KThumb::removeAudioThumb()
+{
+       if (m_thumbFile.isEmpty()) return;
+       stopAudioThumbs();
+       QFile f(m_thumbFile);
+       f.remove();
+}
+
+void KThumb::getAudioThumbs(KUrl url, int channel, double frame, double frameLength, int arrayWidth){
+       if ((thumbProducer.running () && thumbProducer.isWorking()) || channel == 0) {
+           return;
+       }
+
+       QMap <int, QMap <int, QByteArray> > storeIn;
+       //FIXME: Hardcoded!!! 
+       int m_frequency = 48000;
+       int m_channels = channel;
+       if (m_url != url) {
+               m_url = url;
+               KMD5 context ((KFileItem(m_url,"text/plain", S_IFREG).timeString() + m_url.fileName()).ascii());
+               m_thumbFile = KdenliveSettings::currenttmpfolder() + context.hexDigest().data() + ".thumb";
+       }
+       QFile f(m_thumbFile);
+       if (f.open( IO_ReadOnly )) {
+               QByteArray channelarray = f.readAll();
+               f.close();
+               if (channelarray.size() != arrayWidth*(frame+frameLength)*m_channels) {
+                       kdDebug()<<"--- BROKEN THUMB FOR: "<<m_url.filename()<<" ---------------------- "<<endl;
+                       f.remove();
+                       return;
+               }
+               
+               for (int z=(int) frame;z<(int) (frame+frameLength);z++) {
+                       for (int c=0;c< m_channels;c++){
+                               QByteArray m_array(arrayWidth);
+                               for (int i = 0; i < arrayWidth; i++)
+                                       m_array[i] = channelarray[z*arrayWidth*m_channels + c*arrayWidth + i];
+                               storeIn[z][c] = m_array;
+                       }
+               }
+               emit audioThumbReady(storeIn);
+       }
+       else {
+               if (thumbProducer.running()) return;
+               thumbProducer.init(m_url, m_thumbFile, frame, frameLength, m_frequency, m_channels, arrayWidth);
+               thumbProducer.start(QThread::LowestPriority );
+       }
+}
+*/
+
+
diff --git a/src/kthumb.h b/src/kthumb.h
new file mode 100644 (file)
index 0000000..a3b73b0
--- /dev/null
@@ -0,0 +1,91 @@
+/***************************************************************************
+                         krender.h  -  description
+                            -------------------
+   begin                : Fri Nov 22 2002
+   copyright            : (C) 2002 by Jason Wood
+   email                : jasonwood@blueyonder.co.uk
+***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef KTHUMB_H
+#define KTHUMB_H
+
+#include <qobject.h>
+#include <qpixmap.h>
+#include <qfile.h>
+#include <qthread.h>
+
+#include <kurl.h>
+
+
+/**KRender encapsulates the client side of the interface to a renderer.
+From Kdenlive's point of view, you treat the KRender object as the
+renderer, and simply use it as if it was local. Calls are asyncrhonous -
+you send a call out, and then recieve the return value through the
+relevant signal that get's emitted once the call completes.
+  *@author Jason Wood
+  */
+
+
+namespace Mlt {
+    class Miracle;
+    class Consumer;
+    class Producer;
+    class Frame;
+};
+
+
+  /*  class MyThread : public QThread {
+
+    public:
+        virtual void run();
+       void init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth);
+       bool isWorking();
+       bool stop_me;
+
+    private:
+       QFile f;
+       KUrl m_url;
+       double m_frame;
+       double m_frameLength;
+       int m_frequency;
+       int m_channels;
+       int m_arrayWidth;
+       bool m_isWorking;
+    };
+
+*/
+class KThumb:public QObject {
+  Q_OBJECT public:
+
+
+     KThumb(KUrl url, QObject * parent = 0, const char *name = 0);
+    ~KThumb();
+
+public slots:
+       void extractImage( int frame, int frame2, int width, int height);
+/*     void getImage(KUrl url, int frame, int width, int height);
+       void getThumbs(KUrl url, int startframe, int endframe, int width, int height);
+       void stopAudioThumbs();
+       void removeAudioThumb();
+       void getAudioThumbs(KUrl url, int channel, double frame, double frameLength, int arrayWidth);
+*/
+private:
+//     MyThread thumbProducer;
+       KUrl m_url;
+       QString m_thumbFile;
+
+signals:
+       void thumbReady(int frame, QPixmap pm);
+       void audioThumbReady(QMap <int, QMap <int, QByteArray> >);
+};
+
+#endif
index 5cd54e2208af88935c1bce2a4503b3f783417fab..3805e18e925a4786b46d12ac0ba2c2365b7601f7 100644 (file)
@@ -30,7 +30,8 @@ LabelItem::LabelItem(QString text, QGraphicsRectItem *parent)
     : QGraphicsSimpleTextItem(" " + text + " ", parent)
 {
   //setParentItem(parent); 
-  setFlags(QGraphicsItem::ItemIgnoresTransformations);
+  //setFlags(QGraphicsItem::ItemIgnoresTransformations);
+  setZValue(200);
 }
 
 int LabelItem::type () const
@@ -44,7 +45,7 @@ int LabelItem::type () const
                            const QStyleOptionGraphicsItem *option,
                            QWidget *widget)
  {
-    kDebug()<<"REPAINT LABEL ------------------------";
+    //kDebug()<<"REPAINT LABEL ------------------------";
     QRectF rep = option->exposedRect;
     //painter->setClipRect(rep);
     QGraphicsRectItem *parent = (QGraphicsRectItem *) parentItem();
index 269929f8dff02180eecbb4235b4c0a0593ab1724..9a5e0984e687399c43d13a60774daac72c323d0c 100644 (file)
@@ -45,7 +45,7 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
 
   m_scene = new QGraphicsScene();
   m_trackview = new CustomTrackView(m_doc->commandStack(), m_scene, this);
-  m_trackview->scale(FRAME_SIZE, 1);
+  m_trackview->scale(1, 1);
   m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
   //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
 
@@ -130,15 +130,15 @@ void TrackView::slotCursorMoved(int pos, bool emitSignal)
 void TrackView::slotChangeZoom(int factor)
 {
   m_ruler->setPixelPerMark(factor);
-  m_scale = (double) m_ruler->comboScale[m_currentZoom] / m_ruler->comboScale[factor];
+  m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] / 
   m_currentZoom = factor;
-  m_trackview->scale(m_scale, 1);
+  m_trackview->setScale(m_scale);
   m_trackview->centerOn(QPointF(m_trackview->cursorPos(), 50));
 }
 
 const double TrackView::zoomFactor() const
 {
-  return m_scale * FRAME_SIZE;
+  return m_scale;
 }
 
 void TrackView::slotZoomIn()
@@ -192,10 +192,8 @@ int TrackView::slotAddVideoTrack(int ix, QDomElement xml)
     else if (elem.tagName() == "entry") {
     int in = elem.attribute("in", 0).toInt();
     int out = elem.attribute("out", 0).toInt() - in;
-    QString clipName = m_doc->producerName(elem.attribute("producer").toInt());
-    int clipMaxDuration = m_doc->getProducerDuration(elem.attribute("producer").toInt());
     //kDebug()<<"++++++++++++++\n\n / / /ADDING CLIP: "<<clip.cropTime<<", out: "<<clip.duration<<", Producer: "<<clip.producer<<"\n\n++++++++++++++++++++";
-    ClipItem *item = new ClipItem(elem.attribute("type").toInt(), clipName, elem.attribute("producer").toInt(), clipMaxDuration, QRectF(position, trackTop + 1, out, 49));
+    ClipItem *item = new ClipItem(elem, ix, in, QRectF(position * m_scale, trackTop + 1, out * m_scale, 49), out);
     m_scene->addItem(item);
     position += out;
 
@@ -239,7 +237,6 @@ const QString & TrackView::editMode() const
 
 /** This event occurs when the mouse has been moved. */
     void TrackView::mouseMoveEvent(QMouseEvent * event) {
-    kDebug()<<"--------  TRACKVIEW MOUSE MOVE EVENT -----";
        if (m_panelUnderMouse) {
            if (event->buttons() & Qt::LeftButton) {
                bool result = false;