[vlmc-devel] commit: Avoid creating two ClipHelper when the new clip is added from the backend. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Apr 18 19:53:20 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Apr 18 19:47:34 2010 +0200| [55894a5d8d0336a577d48e357ceba695b078a196] | committer: Hugo Beauzée-Luyssen 

Avoid creating two ClipHelper when the new clip is added from the backend.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=55894a5d8d0336a577d48e357ceba695b078a196
---

 src/Gui/timeline/AbstractGraphicsMediaItem.cpp |   13 +++++++++++++
 src/Gui/timeline/AbstractGraphicsMediaItem.h   |    1 +
 src/Gui/timeline/GraphicsAudioItem.cpp         |   14 ++++++++++++++
 src/Gui/timeline/GraphicsAudioItem.h           |    1 +
 src/Gui/timeline/GraphicsMovieItem.cpp         |   14 ++++++++++++++
 src/Gui/timeline/GraphicsMovieItem.h           |    2 ++
 src/Gui/timeline/TracksView.cpp                |    4 ++--
 7 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index d0f6b0b..b128f0f 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -46,6 +46,19 @@ AbstractGraphicsMediaItem::AbstractGraphicsMediaItem( Clip* clip ) :
              this, SLOT( clipDestroyed( Clip* ) ), Qt::DirectConnection );
 }
 
+AbstractGraphicsMediaItem::AbstractGraphicsMediaItem( ClipHelper* ch ) :
+        oldTrackNumber( -1 ), oldPosition( -1 ), m_tracksView( NULL ),
+        m_group( NULL ), m_width( 0 ), m_height( 0 ), m_resizeExpected( false ),
+        m_muted( false ), m_clipHelper( ch )
+{
+    // Adjust the width
+    setWidth( ch->length() );
+    // Automatically adjust future changes
+    connect( ch, SIGNAL( lengthUpdated() ), this, SLOT( adjustLength() ) );
+    connect( ch->clip(), SIGNAL( unloaded( Clip* ) ),
+             this, SLOT( clipDestroyed( Clip* ) ), Qt::DirectConnection );
+}
+
 AbstractGraphicsMediaItem::~AbstractGraphicsMediaItem()
 {
     ungroup();
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index 04c4739..fe7c6e8 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -54,6 +54,7 @@ public:
     };
 
     AbstractGraphicsMediaItem( Clip* clip );
+    AbstractGraphicsMediaItem( ClipHelper* ch );
     virtual ~AbstractGraphicsMediaItem();
 
     /// Defines the outer bounds of the item as a rectangle
diff --git a/src/Gui/timeline/GraphicsAudioItem.cpp b/src/Gui/timeline/GraphicsAudioItem.cpp
index b5e668e..fe579e2 100644
--- a/src/Gui/timeline/GraphicsAudioItem.cpp
+++ b/src/Gui/timeline/GraphicsAudioItem.cpp
@@ -46,6 +46,20 @@ GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) :
     setAcceptHoverEvents( true );
 }
 
+GraphicsAudioItem::GraphicsAudioItem( ClipHelper* ch ) :
+        AbstractGraphicsMediaItem( ch )
+{
+    setFlags( QGraphicsItem::ItemIsSelectable );
+
+    QTime length = QTime().addMSecs( ch->clip()->getMedia()->lengthMS() );
+    QString tooltip( tr( "<p style='white-space:pre'><b>Name:</b> %1"
+                     "<br><b>Length:</b> %2" )
+                     .arg( ch->clip()->getMedia()->fileName() )
+                     .arg( length.toString("hh:mm:ss.zzz") ) );
+    setToolTip( tooltip );
+    setAcceptHoverEvents( true );
+}
+
 GraphicsAudioItem::~GraphicsAudioItem()
 {
 }
diff --git a/src/Gui/timeline/GraphicsAudioItem.h b/src/Gui/timeline/GraphicsAudioItem.h
index b09345a..a355c82 100644
--- a/src/Gui/timeline/GraphicsAudioItem.h
+++ b/src/Gui/timeline/GraphicsAudioItem.h
@@ -45,6 +45,7 @@ public:
      */
     enum { Type = UserType + 1 };
     GraphicsAudioItem( Clip* clip );
+    GraphicsAudioItem( ClipHelper *ch );
     virtual ~GraphicsAudioItem();
 
     virtual int type() const { return Type; }
diff --git a/src/Gui/timeline/GraphicsMovieItem.cpp b/src/Gui/timeline/GraphicsMovieItem.cpp
index cc8b7d6..5575e0a 100644
--- a/src/Gui/timeline/GraphicsMovieItem.cpp
+++ b/src/Gui/timeline/GraphicsMovieItem.cpp
@@ -47,6 +47,20 @@ GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) :
     setAcceptHoverEvents( true );
 }
 
+GraphicsMovieItem::GraphicsMovieItem( ClipHelper* ch ) :
+        AbstractGraphicsMediaItem( ch )
+{
+    setFlags( QGraphicsItem::ItemIsSelectable );
+
+    QTime length = QTime().addMSecs( ch->clip()->getMedia()->lengthMS() );
+    QString tooltip( tr( "<p style='white-space:pre'><b>Name:</b> %1"
+                     "<br><b>Length:</b> %2" )
+                     .arg( ch->clip()->getMedia()->fileName() )
+                     .arg( length.toString("hh:mm:ss.zzz") ) );
+    setToolTip( tooltip );
+    setAcceptHoverEvents( true );
+}
+
 GraphicsMovieItem::~GraphicsMovieItem()
 {
 }
diff --git a/src/Gui/timeline/GraphicsMovieItem.h b/src/Gui/timeline/GraphicsMovieItem.h
index 639bcdf..78ca391 100644
--- a/src/Gui/timeline/GraphicsMovieItem.h
+++ b/src/Gui/timeline/GraphicsMovieItem.h
@@ -45,6 +45,8 @@ public:
      */
     enum { Type = UserType + 1 };
     GraphicsMovieItem( Clip* clipHelper );
+    /// The same CTOR, but this one won't create a new ClipHelper.
+    GraphicsMovieItem( ClipHelper* clipHelper );
     virtual ~GraphicsMovieItem();
 
     virtual int type() const { return Type; }
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 8b110bb..649ff01 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -244,13 +244,13 @@ TracksView::addMediaItem( ClipHelper *ch, unsigned int track, MainWorkflow::Trac
     AbstractGraphicsMediaItem *item = 0;
     if ( trackType == MainWorkflow::VideoTrack )
     {
-        item = new GraphicsMovieItem( ch->clip() );
+        item = new GraphicsMovieItem( ch );
         connect( item, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
                  this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
     }
     else if ( trackType == MainWorkflow::AudioTrack )
     {
-        item = new GraphicsAudioItem( ch->clip() );
+        item = new GraphicsAudioItem( ch );
         connect( item, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
                  this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
     }



More information about the Vlmc-devel mailing list