]> git.sesse.net Git - kdenlive/commitdiff
Connect project monitor
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 10 Feb 2008 10:19:37 +0000 (10:19 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 10 Feb 2008 10:19:37 +0000 (10:19 +0000)
svn path=/branches/KDE4/; revision=1829

17 files changed:
src/customtrackview.cpp
src/customtrackview.h
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/monitor.cpp
src/monitor.h
src/projectitem.cpp
src/projectitem.h
src/projectlist.cpp
src/projectlist.h
src/projectlistview.cpp
src/projectlistview.h
src/renderer.cpp
src/renderer.h
src/trackview.cpp
src/trackview.h

index 8a0a07aa79a5ededd61910d1a240a4496b8180de..1207ee6110ea93750dedbbc3582df4ea199bd9e2 100644 (file)
 #include "resizeclipcommand.h"
 #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), m_scale(1.0), m_clickPoint(0)
+CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent)
+    : QGraphicsView(projectscene, parent), 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), m_document(doc)
 {
+  if (doc) m_commandStack = doc->commandStack();
+  else m_commandStack == NULL;
   setMouseTracking(true);
   setAcceptDrops(true);
   m_animationTimer = new QTimeLine(800);
@@ -347,6 +349,7 @@ void CustomTrackView::dropEvent ( QDropEvent * event ) {
   if (m_dropItem) {
     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_document->renderer()->mltInsertClip(m_dropItem->track(), GenTime(m_dropItem->startPos(), 25), m_dropItem->xml());
   }
   m_dropItem = NULL;
 }
@@ -393,6 +396,8 @@ void CustomTrackView::setCursorPos(int pos)
 {
   m_cursorPos = pos;
   m_cursorLine->setPos(pos, 0);
+  int frame = mapToScene(QPoint(pos, 0)).x() / m_scale;
+  m_document->renderer()->seek(GenTime(frame, 25));
 }
 
 int CustomTrackView::cursorPos()
index 9b06e1fda555e5b4c68ee6e3624788dc3220acf7..8bc238b371e9110c6eb3ba849b1222f7f8b8bc3f 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <KUndoStack>
 
+#include "kdenlivedoc.h"
 #include "clipitem.h"
 
 class CustomTrackView : public QGraphicsView
@@ -34,7 +35,7 @@ class CustomTrackView : public QGraphicsView
   Q_OBJECT
   
   public:
-    CustomTrackView(KUndoStack *commandStack, QGraphicsScene * projectscene, QWidget *parent=0);
+    CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent=0);
     virtual void mousePressEvent ( QMouseEvent * event );
     virtual void mouseReleaseEvent ( QMouseEvent * event );
     virtual void mouseMoveEvent ( QMouseEvent * event );
@@ -69,6 +70,7 @@ class CustomTrackView : public QGraphicsView
     int m_projectDuration;
     int m_cursorPos;
     ClipItem *m_dropItem;
+    KdenliveDoc *m_document;
     void addItem(QString producer, QPoint pos);
     QGraphicsLineItem *m_cursorLine;
     QPointF m_startPos;
index a0f61f1efdba5e6baa950e7a295a3a196979fb70..05844d167efbdf98c05eb260822f88812a33f633 100644 (file)
 #include "kdenlivedoc.h"
 
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL)
+KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL), m_commandStack(new KUndoStack())
 {
-
-  m_commandStack = new KUndoStack();
   if (!url.isEmpty()) {
     QString tmpFile;
     if(KIO::NetAccess::download(url.path(), tmpFile, parent))
@@ -109,6 +107,11 @@ void KdenliveDoc::setRenderer(Render *render)
   if (m_render) m_render->setSceneList(m_document);
 }
 
+Render *KdenliveDoc::renderer()
+{
+  return m_render;
+}
+
 QString KdenliveDoc::producerName(int id)
 {
   QString result = "unnamed";
index 7d7b6d115935540b5dc75cf108f3865b51ca125e..0c7d93ea64e44ddbe266ea8e7084ffa37c2e5232 100644 (file)
@@ -53,6 +53,7 @@ class KdenliveDoc:public QObject {
     QString producerName(int id);
     void setProducerDuration(int id, int duration);
     int getProducerDuration(int id);
+    Render *renderer();
 
   private:
     KUrl m_url;
index 0a42b1ed6cd1ef5a7778a43934eedc0b3f1d8be3..95f0d704814401ad954f58f46b7a50489330982e 100644 (file)
@@ -213,6 +213,9 @@ void MainWindow::setupActions()
   KStandardAction::openNew(this, SLOT(newFile()),
                         actionCollection());
 
+  KStandardAction::preferences(this, SLOT(slotPreferences()),
+                        actionCollection());
+
   /*KStandardAction::undo(this, SLOT(undo()),
                         actionCollection());
 
index 29e04eb77f00af1f9ead24492b1f4acbda53539c..7d0a5938a1337cdee71bfc0e2094769e3a0c7a54 100644 (file)
@@ -188,13 +188,6 @@ void Monitor::refreshMonitor(bool visible)
   if (visible && render) render->askForRefresh();
 }
 
-void Monitor::slotOpen()
-{
-  if ( render == NULL ) return;
-  render->mltInsertClip(2, GenTime(1, 25), QString("<westley><producer mlt_service=\"colour\" colour=\"red\" in=\"1\" out=\"30\" /></westley>"));
-  render->mltInsertClip(2, GenTime(0, 25), QString("<westley><producer mlt_service=\"avformat\" resource=\"/home/one/.vids/clip3e.mpg\" in=\"1\" out=\"300\" /></westley>"));
-}
-
 void Monitor::slotPlay()
 {
   if ( render == NULL ) return;
index 904b79b166c28aff7224ce2630e04d5d9ca7022e..bf20b6643e384390c3abff8290acb167186e187b 100644 (file)
@@ -56,7 +56,6 @@ class Monitor : public QWidget
 
   private slots:
     void slotPlay();
-    void slotOpen();
     void adjustRulerSize(int length);
     void seekCursor(int pos);
     void rendererStopped(int pos);
index a2dd17244285b1a7f76cf73f419abc02992a6031..53fde22ad5b6a345c88800c782b04420d3cd4560 100644 (file)
@@ -42,7 +42,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDom
 {
   m_element = xml.cloneNode().toElement();
   setSizeHint(0, QSize(65, 45));
-  setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
+  setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
   if (!m_element.isNull()) {
     m_element.setAttribute("id", clipId);
     QString cType = m_element.attribute("type", QString::null);
@@ -63,7 +63,7 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings,
 {
   m_element = xml.cloneNode().toElement();
   setSizeHint(0, QSize(65, 45));
-  setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
+  setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
   if (!m_element.isNull()) {
     m_element.setAttribute("id", clipId);
     QString cType = m_element.attribute("type", QString::null);
@@ -78,7 +78,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, int
     : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(true), m_groupName(strings.at(1))
 {
   setSizeHint(0, QSize(65, 45));
-  setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
+  setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
   setIcon(0, KIcon("folder"));
 }
 
@@ -91,6 +91,11 @@ int ProjectItem::clipId() const
   return m_clipId;
 }
 
+CLIPTYPE ProjectItem::clipType() const
+{
+ return m_clipType;
+}
+
 int ProjectItem::clipMaxDuration() const
 {
   return m_element.attribute("duration").toInt();
@@ -123,7 +128,7 @@ QDomElement ProjectItem::toXml() const
 const KUrl ProjectItem::clipUrl() const
 {
     if (m_clipType != COLOR && m_clipType != VIRTUAL && m_clipType != UNKNOWN)
-      return KUrl(m_element.attribute("resouce"));
+      return KUrl(m_element.attribute("resource"));
     else return KUrl();
 }
 
index 083db29a2b505296bd9dd51af9a549c08ab6ceb5..95b4e14fb1fed588d78033c016768fe269936eea 100644 (file)
@@ -46,6 +46,7 @@ class ProjectItem : public QTreeWidgetItem
     const QString groupName() const;
     const KUrl clipUrl() const;
     int clipMaxDuration() const;
+    CLIPTYPE clipType() const;
 
   private:
     QDomElement m_element;
index 7fe59f7cb1c716124fc093bed50229f200ef31bb..026e5b29d1ac91c657edf701166148fe31a0b434 100644 (file)
@@ -107,6 +107,7 @@ ProjectList::ProjectList(QWidget *parent)
   connect(listView, SIGNAL(requestMenu ( const QPoint &, QTreeWidgetItem * )), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
   connect(listView, SIGNAL(addClip ()), this, SLOT(slotAddClip()));
   connect(listView, SIGNAL(addClip (QUrl, const QString &)), this, SLOT(slotAddClip(QUrl, const QString &)));
+  connect(listView, SIGNAL (itemChanged ( QTreeWidgetItem *, int )), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int )));
 
   m_listViewDelegate = new ItemDelegate(listView);
   listView->setItemDelegate(m_listViewDelegate);
@@ -131,6 +132,19 @@ void ProjectList::slotClipSelected()
   if (item && !item->isGroup()) emit clipSelected(item->toXml());
 }
 
+void ProjectList::slotUpdateItemDescription( QTreeWidgetItem *item, int column)
+{
+  if (column != 2) return;
+  ProjectItem *clip = (ProjectItem*) item;
+  CLIPTYPE type = clip->clipType(); 
+  if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST) {
+    // Use Nepomuk system to store clip description
+    Nepomuk::Resource f( clip->clipUrl().path() );
+    f.setDescription(item->text(2));
+    kDebug()<<"NEPOMUK, SETTING CLIP: "<<clip->clipUrl().path()<<", TO TEXT: "<<item->text(2);
+  }
+}
+
 void ProjectList::slotEditClip()
 {
   kDebug()<<"////////////////////////////////////////   DBL CLK";
index 86939085a6c9a6f5d3ddaa90e926d897d3cd7ccb..9628b3e49a78a25e98d44a4c170abd66476fc5ff 100644 (file)
@@ -141,6 +141,8 @@ class ProjectList : public QWidget
     void slotEditClip(QTreeWidgetItem *, int);
     void slotContextMenu( const QPoint &pos, QTreeWidgetItem * );
     void slotAddFolder();
+    /** This is triggered when a clip description has been modified */
+    void slotUpdateItemDescription(QTreeWidgetItem *item, int column);
     //void slotShowMenu(const QPoint &pos);
 
 
index a8ebce7f86138d038ce3d58a44aa334d4699b478..400e5a5e7980cf3f553f807e7be52ffe5636649c 100644 (file)
@@ -39,6 +39,11 @@ ProjectListView::~ProjectListView()
 {
 }
 
+void ProjectListView::editItem ( QTreeWidgetItem * item, int column )
+{
+  kDebug()<<"////////////////  EDIT ITEM, COL: "<<column;
+}
+
 // virtual
 void ProjectListView::contextMenuEvent ( QContextMenuEvent * event )
 {
@@ -49,6 +54,7 @@ void ProjectListView::contextMenuEvent ( QContextMenuEvent * event )
 void ProjectListView::mouseDoubleClickEvent ( QMouseEvent * event )
 {
   if (!itemAt(event->pos())) emit addClip();
+  else if (columnAt(event->pos().x()) == 2) QTreeWidget::mouseDoubleClickEvent( event );
 }
 
 // virtual
index da5756a5820006762a9eb1523d94f9cc3440a58d..55dd920bfe81e8a4f9ba7f62ae5f67969170f618 100644 (file)
@@ -31,6 +31,7 @@ class ProjectListView : public QTreeWidget
   public:
     ProjectListView(QWidget *parent=0);
     virtual ~ProjectListView();
+    void editItem ( QTreeWidgetItem * item, int column = 0 );
 
   protected:
     virtual void contextMenuEvent ( QContextMenuEvent * event );
@@ -52,6 +53,7 @@ class ProjectListView : public QTreeWidget
 
   private slots:
 
+
   signals:
     void requestMenu(const QPoint &, QTreeWidgetItem *);
     void addClip();
index f828dd63232b1374cbd6438878a378d9f292638b..aac9bad2b28acccc2f243d95791eb3abbcfddd8f 100644 (file)
@@ -986,14 +986,19 @@ void Render::mltCheckLength()
        blackTrackPlaylist.remove_region( 0, blackDuration );
        int i = 0;
        int dur = duration;
-       
+       QDomDocument doc;
+       QDomElement black = doc.createElement("producer");
+       black.setAttribute("mlt_service", "colour");
+       black.setAttribute("colour", "black");
+       black.setAttribute("in", "0");
+       black.setAttribute("out", "13999");
         while (dur > 14000) { // <producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" />
-           mltInsertClip(0, GenTime(i * 14000, m_fps), QString("<westley><producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" /></westley>"));
+           mltInsertClip(0, GenTime(i * 14000, m_fps), black);
            dur = dur - 14000;
            i++;
         }
-
-       mltInsertClip(0, GenTime(), QString("<westley><producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"" + QString::number(dur) + "\" /></westley>"));
+       black.setAttribute("out", QString::number(dur));
+       mltInsertClip(0, GenTime(), black);
 
        m_mltProducer->set("out", duration);
        emit durationChanged();
@@ -1001,7 +1006,7 @@ void Render::mltCheckLength()
 }
 
 
-void Render::mltInsertClip(int track, GenTime position, QString resource)
+void Render::mltInsertClip(int track, GenTime position, QDomElement element)
 {
     if (!m_mltProducer) {
        kDebug()<<"PLAYLIST NOT INITIALISED //////";
@@ -1015,6 +1020,10 @@ void Render::mltInsertClip(int track, GenTime position, QString resource)
     Mlt::Service service(parentProd.get_service());
     Mlt::Tractor tractor(service);
 
+    QDomDocument doc;
+    doc.appendChild(doc.importNode(element, true));
+    QString resource = doc.toString();
+    kDebug()<<"///////  ADDING CLIP TMLNE: "<<resource;
     Mlt::Producer trackProducer(tractor.track(track));
     Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
     char *tmp = decodedString(resource);
index a5d3c4892600fcc84742f3b1f5fdfb71ea50a0f7..fd4120083a5c810cf4074a23d5b2579d63ca1eb3 100644 (file)
@@ -155,7 +155,7 @@ class Render:public QObject {
     const double fps() const;
 
     /** Playlist manipulation */
-    void mltInsertClip(int track, GenTime position, QString resource);
+    void mltInsertClip(int track, GenTime position, QDomElement element);
     void mltCutClip(int track, GenTime position);
     void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
     void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
index cf09b464528e7b7284d911918c381c455426bcd9..77b32b6a37060ca46ae1fca53a89d773fa47d3e7 100644 (file)
@@ -44,7 +44,7 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
   layout->addWidget(m_ruler);
 
   m_scene = new QGraphicsScene();
-  m_trackview = new CustomTrackView(m_doc->commandStack(), m_scene, this);
+  m_trackview = new CustomTrackView(doc, m_scene, this);
   m_trackview->scale(1, 1);
   m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
   //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
@@ -65,7 +65,7 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
   setEditMode("move");*/
 
   connect(view->horizontalSlider, SIGNAL(valueChanged ( int )), this, SLOT(slotChangeZoom( int )));
-  connect(m_ruler, SIGNAL(cursorMoved ( int )), m_trackview, SLOT(setCursorPos( int )));
+  connect(m_ruler, SIGNAL(cursorMoved ( int )), this, SLOT(setCursorPos( int )));
   connect(m_trackview, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int )));
   connect(m_trackview, SIGNAL(zoomIn ()), this, SLOT(slotZoomIn()));
   connect(m_trackview, SIGNAL(zoomOut ()), this, SLOT(slotZoomOut()));
@@ -120,10 +120,15 @@ void TrackView::parseDocument(QDomDocument doc)
   //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
 }
 
+void TrackView::setCursorPos(int pos)
+{
+  m_trackview->setCursorPos(pos * m_scale);
+}
+
 void TrackView::slotCursorMoved(int pos, bool emitSignal)
 {
   kDebug()<<"///// CURSOR: "<<pos;
-  m_ruler->slotNewValue(pos * FRAME_SIZE, emitSignal); //(int) m_trackview->mapToScene(QPoint(pos, 0)).x());
+  m_ruler->slotNewValue(pos * FRAME_SIZE / m_scale, emitSignal); //(int) m_trackview->mapToScene(QPoint(pos, 0)).x());
   //m_trackview->setCursorPos(pos);
   //m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer);
 }
index 6c35a58ec099cb67f66d84690b50226d39a381f8..a13b92ee028a429f68338cda8c056e9953e8b7be 100644 (file)
@@ -95,6 +95,7 @@ class TrackView : public QWidget
     void slotCursorMoved(int pos, bool slotCursorMoved = false);
     void slotZoomIn();
     void slotZoomOut();
+    void setCursorPos(int pos);
 
   signals:
     void mousePosition(int);