Connect project monitor

svn path=/branches/KDE4/; revision=1829
parent f1fc545b
......@@ -34,9 +34,11 @@
#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()
......
......@@ -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;
......
......@@ -28,10 +28,8 @@
#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";
......
......@@ -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;
......
......@@ -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());
......
......@@ -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;
......
......@@ -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);
......
......@@ -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();
}
......
......@@ -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;
......
......@@ -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";
......
......@@ -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);
......
......@@ -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
......
......@@ -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();
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment