From b629356c0cc2db46030cdab92240d6a1f13642bc Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 5 Jan 2015 17:05:36 +0000 Subject: [PATCH] Improve module to handle more than one for each window --- app/ModulesHandle.cpp | 25 +++++++++++++--------- app/VideoSubWindow.cpp | 47 +++++++++++++++++++++++------------------- app/VideoSubWindow.h | 20 +++++++----------- 3 files changed, 49 insertions(+), 43 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 488828d..9173dc3 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -158,10 +158,14 @@ Void ModulesHandle::updateMenus() m_arrayActions[FORCE_NEW_WINDOW_ACT]->setEnabled( hasSubWindow ); if( pcSubWindow ) { - if( pcSubWindow->getModule() ) + QVector apcCurrentModule = pcSubWindow->getModuleArray(); + for( Int i = 0; i < apcCurrentModule.size(); i++ ) { - currModuleAction = pcSubWindow->getModule()->m_pcModuleAction; + currModuleAction = apcCurrentModule.at( i )->m_pcModuleAction; currModuleAction->setChecked( true ); + } + if( apcCurrentModule.size() ) + { m_arrayActions[APPLY_ALL_ACT]->setEnabled( true ); m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( true ); } @@ -183,9 +187,10 @@ Void ModulesHandle::processOpt( Int index ) VideoSubWindow* pcSubWindow = qobject_cast( m_pcMdiArea->activeSubWindow() ); if( pcSubWindow ) { - PlaYUVerAppModuleIf* pcCurrModule = pcSubWindow->getModule(); - if( pcCurrModule ) + QVector apcCurrentModule = pcSubWindow->getModuleArray(); + if( apcCurrentModule.size() > 1 ) { + PlaYUVerAppModuleIf* pcCurrModule = apcCurrentModule.at( 0 ); switch( index ) { case INVALID_OPT: @@ -286,7 +291,6 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) for( Int i = 0; i < subWindowList.size(); i++ ) { pcCurrModuleIf->m_pcSubWindow[i] = subWindowList.at( i ); - pcCurrModuleIf->m_pcSubWindow[i]->disableModule(); } pcCurrModuleIf->m_pcDisplaySubWindow = NULL; @@ -302,7 +306,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) connect( interfaceChild, SIGNAL( zoomChanged() ), m_pcParent, SLOT( updateZoomFactorSBox() ) ); pcCurrModuleIf->m_pcDisplaySubWindow = interfaceChild; - pcCurrModuleIf->m_pcDisplaySubWindow->setModule( pcCurrModuleIf ); + pcCurrModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrModuleIf, true ); m_pcMdiArea->addSubWindow( interfaceChild ); } } @@ -322,14 +326,15 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) } } - // Create Module - pcCurrModuleIf->m_pcModule->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() ); - // Associate module with subwindows for( UInt i = 0; i < numberOfFrames; i++ ) { pcCurrModuleIf->m_pcSubWindow[i]->enableModule( pcCurrModuleIf ); } + + // Create Module + pcCurrModuleIf->m_pcModule->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() ); + applyModuleIf( pcCurrModuleIf, false ); return; @@ -357,7 +362,7 @@ Void ModulesHandle::destroyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) { if( pcCurrModuleIf->m_pcSubWindow[i] ) { - pcCurrModuleIf->m_pcSubWindow[i]->disableModule(); + pcCurrModuleIf->m_pcSubWindow[i]->disableModule( pcCurrModuleIf ); pcCurrModuleIf->m_pcSubWindow[i] = NULL; } } diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index ba7eaaf..ab2a162 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -75,7 +75,6 @@ VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) : SubWindowHandle( parent, SubWindowHandle::VIDEO_SUBWINDOW ), m_pCurrStream( NULL ), m_pcCurrFrame( NULL ), - m_pcCurrentModule( NULL ), m_pcReferenceSubWindow( NULL ), m_bIsPlaying( false ), m_bIsModule( isModule ) @@ -104,6 +103,8 @@ VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) : m_cScrollArea->setWidget( m_cViewArea ); m_cScrollArea->setWidgetResizable( true ); + m_apcCurrentModule.clear(); + m_cLastScroll = QPoint(); } @@ -206,25 +207,37 @@ Void VideoSubWindow::updateSelectedArea( QRect area ) * Functions to enable a module in the * current SubWindow */ -Void VideoSubWindow::enableModule( PlaYUVerAppModuleIf* select_module ) +Void VideoSubWindow::enableModule( PlaYUVerAppModuleIf* pcModule, Bool bThisWindow ) { - if( m_pcCurrentModule ) + if( bThisWindow ) { + m_apcCurrentModule.clear(); disableModule(); } - m_pcCurrentModule = select_module; -// refreshFrame(); + m_apcCurrentModule.append( pcModule ); } -Void VideoSubWindow::disableModule() +Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) { - if( m_pcCurrentModule ) + if( pcModule ) { - PlaYUVerAppModuleIf* pcCurrentModule = m_pcCurrentModule; - m_pcCurrentModule = NULL; - ModulesHandle::destroyModuleIf( pcCurrentModule ); - refreshFrame(); + Int modIdx = m_apcCurrentModule.indexOf( pcModule ); + if( modIdx != -1 ) + { + m_apcCurrentModule.remove( modIdx ); + ModulesHandle::destroyModuleIf( pcModule ); + } } + else + { + QVector apcCurrentModule = m_apcCurrentModule; + for( Int i = 0; i < apcCurrentModule.size(); i++ ) + { + ModulesHandle::destroyModuleIf( apcCurrentModule.at( i ) ); + } + assert( m_apcCurrentModule.size() == 0 ); + } + refreshFrame(); } Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) @@ -236,7 +249,6 @@ Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) show(); resize( sizeHint() ); zoomToFit(); - } } @@ -247,17 +259,10 @@ Void VideoSubWindow::refreshFrame() { m_pcCurrFrame = m_pCurrStream->getCurrFrame(); bSetFrame = true; - if( m_pcCurrentModule ) - { - bSetFrame = ModulesHandle::applyModuleIf( m_pcCurrentModule, m_bIsPlaying ); - } } - else + for( Int i = 0; i < m_apcCurrentModule.size(); i++ ) { - if( m_pcCurrentModule ) - { - bSetFrame = ModulesHandle::applyModuleIf( m_pcCurrentModule, m_bIsPlaying ); - } + bSetFrame = ModulesHandle::applyModuleIf( m_apcCurrentModule.at( i ), m_bIsPlaying ); } if( bSetFrame ) { diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index f69f3af..aa994f4 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -72,7 +72,8 @@ private: QRect m_cSelectedArea; QString m_cFilename; - PlaYUVerAppModuleIf* m_pcCurrentModule; + //PlaYUVerAppModuleIf* m_pcCurrentModule; + QVector m_apcCurrentModule; VideoSubWindow* m_pcReferenceSubWindow; @@ -131,15 +132,6 @@ public: return m_cViewArea; } - Void setModule( PlaYUVerAppModuleIf* pcCurrentModule ) - { - m_pcCurrentModule = pcCurrentModule; - } - PlaYUVerAppModuleIf* getModule() - { - return m_pcCurrentModule; - } - Void setRefSubWindow( VideoSubWindow* subWindow ) { m_pcReferenceSubWindow = NULL; @@ -156,8 +148,12 @@ public: * Functions to enable a module in the * current SubWindow */ - Void enableModule( PlaYUVerAppModuleIf* select_module ); - Void disableModule(); + Void enableModule( PlaYUVerAppModuleIf* pcModule, Bool bThisWindow = true ); + Void disableModule( PlaYUVerAppModuleIf* pcModule = NULL ); + QVector getModuleArray() + { + return m_apcCurrentModule; + } /** * Virtual functions from SubWindowHandle