From 40438689922e843fcf07d22dd52378cb7e5237d5 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Fri, 2 Jan 2015 21:40:49 +0100 Subject: [PATCH 1/3] Add "Remove unused channels" option to FX-Mixer This makes it easier to delete all FX-Channels that are not in use. --- include/FxLine.h | 1 + include/FxMixerView.h | 3 +++ src/gui/FxMixerView.cpp | 33 +++++++++++++++++++++++++++++++++ src/gui/widgets/FxLine.cpp | 15 +++++++++++++-- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/include/FxLine.h b/include/FxLine.h index 2cc479799..69f6a9ed0 100644 --- a/include/FxLine.h +++ b/include/FxLine.h @@ -73,6 +73,7 @@ private: private slots: void renameChannel(); void removeChannel(); + void removeUnusedChannels(); void moveChannelLeft(); void moveChannelRight(); void displayHelp(); diff --git a/include/FxMixerView.h b/include/FxMixerView.h index e2cee4be6..76d6bbb21 100644 --- a/include/FxMixerView.h +++ b/include/FxMixerView.h @@ -92,6 +92,9 @@ public: // notify the view that an fx channel was deleted void deleteChannel(int index); + // delete all unused channels + void deleteUnusedChannels(); + // move the channel to the left or right void moveChannelLeft(int index); void moveChannelRight(int index); diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index aefdcf274..55bed9e7a 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -395,6 +395,39 @@ void FxMixerView::deleteChannel(int index) +void FxMixerView::deleteUnusedChannels() +{ + TrackContainer::TrackList tracks; + tracks += Engine::getSong()->tracks(); + tracks += Engine::getBBTrackContainer()->tracks(); + + // go through all FX Channels + for(int i = m_fxChannelViews.size()-1; i>0; --i) + { + // check if an instrument references to the current channel + bool empty=true; + foreach( Track* t, tracks ) + { + if( t->type() == Track::InstrumentTrack ) + { + InstrumentTrack* inst = dynamic_cast( t ); + if( i == inst->effectChannelModel()->value(0) ) + { + empty=false; + break; + } + } + } + // delete channel if no references found + if( empty ) + { + deleteChannel( i ); + } + } +} + + + void FxMixerView::moveChannelLeft(int index) { // can't move master or first channel left or last channel right diff --git a/src/gui/widgets/FxLine.cpp b/src/gui/widgets/FxLine.cpp index 8f39af38c..adb47d4f8 100644 --- a/src/gui/widgets/FxLine.cpp +++ b/src/gui/widgets/FxLine.cpp @@ -192,14 +192,18 @@ void FxLine::contextMenuEvent( QContextMenuEvent * ) } contextMenu->addAction( tr( "Rename &channel" ), this, SLOT( renameChannel() ) ); contextMenu->addSeparator(); - + if( m_channelIndex != 0 ) // no remove-option in master { contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "R&emove channel" ), this, SLOT( removeChannel() ) ); contextMenu->addSeparator(); } - + + contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "Remove &unused channels" ), + this, SLOT( removeUnusedChannels() ) ); + contextMenu->addSeparator(); + contextMenu->addHelpAction(); contextMenu->exec( QCursor::pos() ); delete contextMenu; @@ -230,6 +234,13 @@ void FxLine::removeChannel() } +void FxLine::removeUnusedChannels() +{ + FxMixerView * mix = Engine::fxMixerView(); + mix->deleteUnusedChannels(); +} + + void FxLine::moveChannelLeft() { FxMixerView * mix = Engine::fxMixerView(); From e6e8f28fc867d836020e6199e36313c9d56f3569 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Sat, 3 Jan 2015 06:52:05 +0100 Subject: [PATCH 2/3] Don't count channels reveiving input from another channel as unused --- src/gui/FxMixerView.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index 55bed9e7a..b1787bac3 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -418,8 +418,9 @@ void FxMixerView::deleteUnusedChannels() } } } + FxChannel * ch = Engine::fxMixer()->effectChannel( i ); // delete channel if no references found - if( empty ) + if( empty && ch->m_receives.isEmpty() ) { deleteChannel( i ); } From 5e4752e041f007dea1b50d98fc962511cd7c8f46 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Sun, 4 Jan 2015 16:33:19 +0100 Subject: [PATCH 3/3] Adjust coding style --- src/gui/FxMixerView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index b1787bac3..8692245ff 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -402,7 +402,7 @@ void FxMixerView::deleteUnusedChannels() tracks += Engine::getBBTrackContainer()->tracks(); // go through all FX Channels - for(int i = m_fxChannelViews.size()-1; i>0; --i) + for(int i = m_fxChannelViews.size()-1; i > 0; --i) { // check if an instrument references to the current channel bool empty=true;