[vlmc-devel] commit: StackViewController: Watch for view deletion. ( Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Tue Mar 16 23:52:03 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Tue Mar 16 23:50:05 2010 +0100| [6e5eff0522d2bcfeb7bb29fc94b25c6f7741dca4] | committer: Hugo Beauzee-Luyssen 

StackViewController: Watch for view deletion.

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

 src/Gui/library/MediaListView.cpp       |    1 +
 src/Gui/library/StackViewController.cpp |   26 ++++++++++++++++++++++++++
 src/Gui/library/StackViewController.h   |    1 +
 3 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/Gui/library/MediaListView.cpp b/src/Gui/library/MediaListView.cpp
index 52cb427..76f1c44 100644
--- a/src/Gui/library/MediaListView.cpp
+++ b/src/Gui/library/MediaListView.cpp
@@ -38,6 +38,7 @@ MediaListView::MediaListView( StackViewController* nav, MediaContainer* mc ) :
              mc, SLOT( removeClip( const QUuid& ) ) );
     connect( mc, SIGNAL( clipRemoved( const QUuid& ) ),
              this, SLOT( __clipRemoved( const QUuid& ) ) );
+    connect( mc, SIGNAL( destroyed() ), this, SLOT( deleteLater() ) );
     foreach ( Clip* clip, mc->clips() )
         newClipLoaded( clip );
 }
diff --git a/src/Gui/library/StackViewController.cpp b/src/Gui/library/StackViewController.cpp
index ac513ba..b4bb6b5 100644
--- a/src/Gui/library/StackViewController.cpp
+++ b/src/Gui/library/StackViewController.cpp
@@ -47,6 +47,8 @@ void    StackViewController::pushViewController( ViewController* viewController,
 {
     animated = false;
 
+    connect( viewController, SIGNAL( destroyed() ),
+             this, SLOT( viewDestroyed() ) );
     if ( m_current )
     {
         m_layout->removeWidget( m_current->view() );
@@ -64,6 +66,30 @@ void    StackViewController::pushViewController( ViewController* viewController,
         m_current->view()->show();
 }
 
+void
+StackViewController::viewDestroyed()
+{
+    //This should'nt happen.
+    if ( m_controllerStack->isEmpty() )
+        return ;
+    if ( QObject::sender() == m_current )
+    {
+        m_current = m_controllerStack->pop();
+
+        m_nav->setTitle( m_current->title() );
+        m_layout->insertWidget( 1, m_current->view() );
+        m_current->view()->setHidden( false );
+
+        if ( !m_controllerStack->size() )
+            m_nav->previousButton()->setHidden( true );
+        else
+        {
+           m_nav->previousButton()->setText( "< " +
+           m_controllerStack->value( m_controllerStack->size() - 1 )->title() );
+        }
+    }
+}
+
 void        StackViewController::popViewController( bool animated )
 {
     animated = false;
diff --git a/src/Gui/library/StackViewController.h b/src/Gui/library/StackViewController.h
index 34721d4..d9d3435 100644
--- a/src/Gui/library/StackViewController.h
+++ b/src/Gui/library/StackViewController.h
@@ -54,6 +54,7 @@ private:
 
 public slots:
     void                        previous();
+    void                        viewDestroyed();
 
 signals:
     void                        previousButtonPushed();



More information about the Vlmc-devel mailing list