[vlmc-devel] commit: MediaCellView: Unbreak the way clip count should be handled. ( Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Wed Mar 10 14:52:55 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Mon Mar  8 20:22:06 2010 +0100| [4f66175b007242ffcfdb0dfd5ea570f45f3de195] | committer: Hugo Beauzee-Luyssen 

MediaCellView: Unbreak the way clip count should be handled.

This doesn't restore the functionnality yet.

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

 src/Gui/library/MediaCellView.cpp           |   46 +++++++++++++++++----------
 src/Gui/library/MediaCellView.h             |    3 +-
 src/Gui/library/MediaListViewController.cpp |    1 -
 src/Media/Clip.cpp                          |    6 +++
 src/Media/Clip.h                            |    2 +
 src/Media/Media.cpp                         |    7 +++-
 src/Media/Media.h                           |    3 +-
 7 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/src/Gui/library/MediaCellView.cpp b/src/Gui/library/MediaCellView.cpp
index 80f58d6..ebdfdc1 100644
--- a/src/Gui/library/MediaCellView.cpp
+++ b/src/Gui/library/MediaCellView.cpp
@@ -38,24 +38,46 @@ MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
     setAutoFillBackground( true );
     connect( m_ui->delLabel, SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
              this, SLOT( deleteButtonClicked( QWidget*, QMouseEvent* ) ) );
-    connect( m_ui->arrow,
-             SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
-             SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
+    if ( clip->isBaseClip() == true )
+    {
+        connect( m_ui->arrow,
+                 SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
+                 SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
+        m_ui->clipCount->setText( QString::number( clip->getParent()->clipsCount() ) );
+        connect( clip->getParent(), SIGNAL( clipAdded(Clip*) ),
+                 this, SLOT( nbClipUpdated( Clip* ) ) );
+        connect( clip->getParent(), SIGNAL( clipRemoved( Clip* ) ),
+                 this, SLOT( nbClipUpdated( Clip* ) ) );
+    }
+    else
+    {
+        m_ui->clipCount->hide();
+        m_ui->clipCountLabel->hide();
+        m_ui->arrow->hide();
+        disconnect( m_ui->arrow,
+                    SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this,
+                    SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
+    }
     if ( clip->getParent()->isMetadataComputed() == false )
         setEnabled( false );
     connect( clip->getParent(), SIGNAL( metaDataComputed(const Media*) ),
              this, SLOT( metadataUpdated( const Media*) ) );
     connect( clip->getParent(), SIGNAL( snapshotComputed(const Media*) ),
              this, SLOT( snapshotUpdated(const Media*) ) );
+
     setThumbnail( clip->getParent()->snapshot() );
     setTitle( clip->getParent()->fileName() );
     setLength( clip->lengthSecond() * 1000 );
 }
 
+MediaCellView::~MediaCellView()
+{
+    delete m_ui;
+}
+
 void
 MediaCellView::metadataUpdated( const Media *media )
 {
-    setNbClips( media->clipsCount() );
     setLength( media->lengthMS() );
     setEnabled( true );
 }
@@ -66,11 +88,6 @@ MediaCellView::snapshotUpdated( const Media *media )
     setThumbnail( media->snapshot() );
 }
 
-MediaCellView::~MediaCellView()
-{
-    delete m_ui;
-}
-
 void MediaCellView::changeEvent( QEvent *e )
 {
     QWidget::changeEvent( e );
@@ -89,9 +106,9 @@ void            MediaCellView::setTitle( const QString& title )
     m_ui->title->setText( title );
 }
 
-void            MediaCellView::setNbClips( int nbClip )
+void            MediaCellView::nbClipUpdated( Clip *clip )
 {
-    m_ui->clipCount->setText( QString::number( nbClip ) );
+    m_ui->clipCount->setText( QString::number( clip->getParent()->clipsCount() ) );
 }
 
 void
@@ -194,12 +211,7 @@ void        MediaCellView::decrementClipCount( const int nb )
 void
 MediaCellView::containsClip()
 {
-    m_ui->clipCount->hide();
-    m_ui->clipCountLabel->hide();
-    m_ui->arrow->hide();
-    disconnect( m_ui->arrow,
-                SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this,
-                SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
+
 }
 
 const QUuid&
diff --git a/src/Gui/library/MediaCellView.h b/src/Gui/library/MediaCellView.h
index e5e5ce3..9cdbd67 100644
--- a/src/Gui/library/MediaCellView.h
+++ b/src/Gui/library/MediaCellView.h
@@ -45,7 +45,6 @@ public:
     ~MediaCellView();
 
     void                    setTitle( const QString& title );
-    void                    setNbClips( int nbClip );
     void                    setThumbnail( const QPixmap& pixmap );
     const QPixmap*          getThumbnail() const;
     /**
@@ -84,6 +83,8 @@ public slots:
 private slots:
     void        snapshotUpdated( const Media *media );
     void        metadataUpdated( const Media *media );
+    void        nbClipUpdated( Clip *clip );
+
 };
 
 #endif // MEDIACELLVIEW_H
diff --git a/src/Gui/library/MediaListViewController.cpp b/src/Gui/library/MediaListViewController.cpp
index 3e23d97..3793e1f 100644
--- a/src/Gui/library/MediaListViewController.cpp
+++ b/src/Gui/library/MediaListViewController.cpp
@@ -54,7 +54,6 @@ void        MediaListViewController::newMediaLoaded( Media* media )
              this, SLOT( showClipList( const QUuid& ) ) );
     connect( media, SIGNAL( clipAdded( Clip* ) ),
              this, SLOT( newClipAdded(Clip*) ) );
-    cell->setNbClips( media->clipsCount() );
     addCell(cell);
     m_cells->insert( media->baseClip()->uuid(), cell );
 }
diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
index ae53eb2..65405f6 100644
--- a/src/Media/Clip.cpp
+++ b/src/Media/Clip.cpp
@@ -236,3 +236,9 @@ Clip::maxEnd() const
 {
     return m_maxEnd;
 }
+
+bool
+Clip::isBaseClip() const
+{
+    return ( m_parent->baseClip() == this );
+}
diff --git a/src/Media/Clip.h b/src/Media/Clip.h
index d572f90..d3fe44b 100644
--- a/src/Media/Clip.h
+++ b/src/Media/Clip.h
@@ -115,6 +115,8 @@ class   Clip : public QObject
 
         void                computeLength();
 
+        bool                isBaseClip() const;
+
     private:
         Media               *m_parent;
         /**
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index 02b843d..215134a 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -291,9 +291,12 @@ Media::clips() const
     return m_clips;
 }
 
-void            Media::removeClip( const QUuid& uuid )
+Clip*
+Media::removeClip( const QUuid& uuid )
 {
-    m_clips.remove( uuid );
+    Clip*   clip = m_clips.take( uuid );
+    emit clipRemoved( clip );
+    return clip;
 }
 
 bool
diff --git a/src/Media/Media.h b/src/Media/Media.h
index dfd062d..0ffd4f9 100644
--- a/src/Media/Media.h
+++ b/src/Media/Media.h
@@ -138,7 +138,7 @@ public:
 //    bool                        hasMetadata() const;
 
     bool                        addClip( Clip* clip );
-    void                        removeClip( const QUuid& uuid );
+    Clip                        *removeClip( const QUuid& uuid );
     Clip*                       clip( const QUuid& uuid );
     quint32                     clipsCount() const;
     const QHash<QUuid, Clip*>   &clips() const;
@@ -181,6 +181,7 @@ signals:
     void                        snapshotComputed( const Media* );
     void                        audioSpectrumComputed( const QUuid& );
     void                        clipAdded( Clip* );
+    void                        clipRemoved( Clip* );
 };
 
 #endif // CLIP_H__



More information about the Vlmc-devel mailing list