[vlmc-devel] commit: Timeline: Don't clone the inserted clip. (Hugo Beauzee-Luyssen )
git at videolan.org
git at videolan.org
Tue Apr 13 14:38:07 CEST 2010
vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Tue Apr 13 12:50:09 2010 +0200| [0287faa4b86892551029f44dd1e981b1ea71ec34] | committer: Hugo Beauzee-Luyssen
Timeline: Don't clone the inserted clip.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=0287faa4b86892551029f44dd1e981b1ea71ec34
---
src/Commands/Commands.cpp | 1 -
src/Gui/timeline/AbstractGraphicsMediaItem.h | 5 +++-
src/Gui/timeline/GraphicsAudioItem.h | 1 -
src/Gui/timeline/GraphicsMovieItem.cpp | 7 -----
src/Gui/timeline/GraphicsMovieItem.h | 1 -
src/Gui/timeline/TracksView.cpp | 38 +++++++-------------------
6 files changed, 14 insertions(+), 39 deletions(-)
diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index 02dd9df..f504d41 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -55,7 +55,6 @@ Commands::MainWorkflow::AddClip::AddClip( Clip* clip,
Commands::MainWorkflow::AddClip::~AddClip()
{
- delete m_clip;
}
void Commands::MainWorkflow::AddClip::redo()
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index bb002ba..4e39434 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -69,7 +69,10 @@ public:
virtual bool moveable() const = 0;
/// Should return the unique uid of the contained media.
- virtual const QUuid& uuid() const = 0;
+ virtual const QUuid& uuid() const
+ {
+ return m_uuid;
+ }
/// Clip contained in the item
virtual Clip* clip() const = 0;
diff --git a/src/Gui/timeline/GraphicsAudioItem.h b/src/Gui/timeline/GraphicsAudioItem.h
index 5cb9633..6e52ca4 100644
--- a/src/Gui/timeline/GraphicsAudioItem.h
+++ b/src/Gui/timeline/GraphicsAudioItem.h
@@ -50,7 +50,6 @@ public:
virtual int type() const { return Type; }
virtual bool expandable() const { return false; }
virtual bool moveable() const { return true; }
- virtual const QUuid& uuid() const { return m_clip->uuid(); }
virtual MainWorkflow::TrackType mediaType() const;
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );
diff --git a/src/Gui/timeline/GraphicsMovieItem.cpp b/src/Gui/timeline/GraphicsMovieItem.cpp
index 3ed591b..943560f 100644
--- a/src/Gui/timeline/GraphicsMovieItem.cpp
+++ b/src/Gui/timeline/GraphicsMovieItem.cpp
@@ -234,10 +234,3 @@ void GraphicsMovieItem::mouseReleaseEvent( QGraphicsSceneMouseEvent* event )
if ( tracksView()->tool() == TOOL_DEFAULT )
setCursor( Qt::OpenHandCursor );
}
-
-
-const QUuid&
-GraphicsMovieItem::uuid() const
-{
- return m_clip->uuid();
-}
diff --git a/src/Gui/timeline/GraphicsMovieItem.h b/src/Gui/timeline/GraphicsMovieItem.h
index ca01c69..4095f6d 100644
--- a/src/Gui/timeline/GraphicsMovieItem.h
+++ b/src/Gui/timeline/GraphicsMovieItem.h
@@ -50,7 +50,6 @@ public:
virtual int type() const { return Type; }
virtual bool expandable() const { return false; }
virtual bool moveable() const { return true; }
- virtual const QUuid& uuid() const;
virtual MainWorkflow::TrackType mediaType() const;
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 5e6b938..0a3a4c7 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -243,18 +243,6 @@ TracksView::addMediaItem( Clip *clip, unsigned int track, MainWorkflow::TrackTyp
}
}
- // Is the clip already existing in the timeline ?
- QList<QGraphicsItem*> trackItems = getTrack( trackType, track )->childItems();
- for ( int i = 0; i < trackItems.size(); ++i )
- {
- AbstractGraphicsMediaItem *item =
- dynamic_cast<AbstractGraphicsMediaItem*>( trackItems.at( i ) );
- if ( !item || item->uuid() != clip->uuid() ) continue;
- // Item already exists in the timeline, exit now.
- qWarning() << QString( "A clip with the same UUID (%1) already exists in the timeline!").arg( item->uuid() );
- return;
- }
-
AbstractGraphicsMediaItem *item = 0;
if ( trackType == MainWorkflow::VideoTrack )
{
@@ -292,16 +280,10 @@ TracksView::dragEnterEvent( QDragEnterEvent *event )
clip->getMedia()->hasVideoTrack() == false )
return ;
- Clip *audioClip = NULL;
- Clip *videoClip = NULL;
- //FIXME: Creating a new clip leaks, but at least we have independant clips.
-
if ( clip->getMedia()->hasAudioTrack() == true )
{
- audioClip = new Clip( clip );
-
if ( m_dragAudioItem ) delete m_dragAudioItem;
- m_dragAudioItem = new GraphicsAudioItem( audioClip );
+ m_dragAudioItem = new GraphicsAudioItem( clip );
m_dragAudioItem->m_tracksView = this;
m_dragAudioItem->setHeight( tracksHeight() );
m_dragAudioItem->setTrack( getTrack( m_dragAudioItem->mediaType(), 0 ) );
@@ -310,10 +292,8 @@ TracksView::dragEnterEvent( QDragEnterEvent *event )
}
if ( clip->getMedia()->hasVideoTrack() == true )
{
- videoClip = new Clip( clip );
-
if ( m_dragVideoItem ) delete m_dragVideoItem;
- m_dragVideoItem = new GraphicsMovieItem( videoClip );
+ m_dragVideoItem = new GraphicsMovieItem( clip );
m_dragVideoItem->m_tracksView = this;
m_dragVideoItem->setHeight( tracksHeight() );
m_dragVideoItem->setTrack( getTrack( m_dragVideoItem->mediaType(), 0 ) );
@@ -321,9 +301,10 @@ TracksView::dragEnterEvent( QDragEnterEvent *event )
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
}
// Group the items together
- if ( audioClip != NULL && videoClip != NULL )
+ if ( clip->getMedia()->hasAudioTrack() == true &&
+ clip->getMedia()->hasVideoTrack() == true )
m_dragVideoItem->group( m_dragAudioItem );
- if ( videoClip == NULL )
+ if ( clip->getMedia()->hasVideoTrack() == false )
moveMediaItem( m_dragAudioItem, event->pos() );
else
moveMediaItem( m_dragVideoItem, event->pos() );
@@ -700,7 +681,7 @@ TracksView::dropEvent( QDropEvent *event )
(qint64)mappedXPos,
MainWorkflow::AudioTrack );
Commands::trigger( clip );
-
+ m_dragAudioItem->m_uuid = clip->uuid();
m_dragAudioItem = NULL;
}
@@ -720,6 +701,7 @@ TracksView::dropEvent( QDropEvent *event )
(qint64)mappedXPos,
MainWorkflow::VideoTrack );
Commands::trigger( clip );
+ m_dragVideoItem->m_uuid = clip->uuid();
m_dragVideoItem = NULL;
}
@@ -955,7 +937,7 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
UndoStack::getInstance()->beginMacro( "Move clip" );
Commands::trigger( new Commands::MainWorkflow::MoveClip( m_mainWorkflow,
- m_actionItem->clip()->uuid(),
+ m_actionItem->uuid(),
m_actionItem->oldTrackNumber,
m_actionItem->trackNumber(),
m_actionItem->startPos(),
@@ -965,7 +947,7 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
if ( m_actionItem->groupItem() )
{
Commands::trigger( new Commands::MainWorkflow::MoveClip( m_mainWorkflow,
- m_actionItem->groupItem()->clip()->uuid(),
+ m_actionItem->groupItem()->uuid(),
m_actionItem->groupItem()->oldTrackNumber,
m_actionItem->groupItem()->trackNumber(),
m_actionItem->groupItem()->startPos(),
@@ -988,7 +970,7 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
Clip *clip = m_actionItem->clip();
//This is a "pointless action". The resize already occured. However, by doing this
//we can have an undo action.
- Commands::trigger( new Commands::MainWorkflow::ResizeClip( clip->uuid(), clip->begin(),
+ Commands::trigger( new Commands::MainWorkflow::ResizeClip( m_actionItem->uuid(), clip->begin(),
clip->end(), m_actionResizeOldBegin, m_actionResizeOldBegin + m_actionResizeBase,
m_actionItem->pos().x(), m_actionResizeStart, m_actionItem->trackNumber(), m_actionItem->mediaType() ) );
updateDuration();
More information about the Vlmc-devel
mailing list