From 17c1ede50c3427f08844a05c2846660e15bc450c Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 15 Jan 2014 23:50:13 +0100 Subject: [PATCH] AutomatableModelView/ContextMenu: option for unlinking all controls Integrated patch by Rodrigo Rodrigues da Silva which adds an option to all AutomatableModelView's context menu allowing to unlink all linked controls. --- include/AutomatableModel.h | 7 +++++++ include/AutomatableModelView.h | 1 + src/core/AutomatableModel.cpp | 13 +++++++++++++ src/gui/AutomatableModelView.cpp | 14 ++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 453949b73..2913d2efc 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -180,6 +180,8 @@ public: static void unlinkModels( AutomatableModel * _m1, AutomatableModel * _m2 ); + void unlinkAllModels(); + virtual void saveSettings( QDomDocument & _doc, QDomElement & _this, const QString & _name = QString( "value" ) ); @@ -208,6 +210,11 @@ public: return "0"; } + bool hasLinkedModels() const + { + return m_hasLinkedModels; + } + public slots: virtual void reset(); diff --git a/include/AutomatableModelView.h b/include/AutomatableModelView.h index 1c35d02aa..cbc3ab816 100644 --- a/include/AutomatableModelView.h +++ b/include/AutomatableModelView.h @@ -92,6 +92,7 @@ public slots: void execConnectionDialog(); void removeConnection(); void editSongGlobalAutomation(); + void unlinkAllModels(); void removeSongGlobalAutomation(); diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 034be3bb5..895e2342d 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -418,6 +418,19 @@ void AutomatableModel::unlinkModels( AutomatableModel * _model1, +void AutomatableModel::unlinkAllModels() +{ + foreach( AutomatableModel* model, m_linkedModels ) + { + unlinkModels( this, model ); + } + + m_hasLinkedModels = false; +} + + + + void AutomatableModel::setControllerConnection( ControllerConnection * _c ) { m_controllerConnection = _c; diff --git a/src/gui/AutomatableModelView.cpp b/src/gui/AutomatableModelView.cpp index 3d1995636..c41eab59c 100644 --- a/src/gui/AutomatableModelView.cpp +++ b/src/gui/AutomatableModelView.cpp @@ -68,6 +68,7 @@ void AutomatableModelView::addDefaultActions( QMenu * _menu ) _model->initValue() ) ). arg( m_unit ), _model, SLOT( reset() ) ); + _menu->addSeparator(); _menu->addAction( embed::getIconPixmap( "edit_copy" ), AutomatableModel::tr( "&Copy value (%1%2)" ). @@ -96,6 +97,14 @@ void AutomatableModelView::addDefaultActions( QMenu * _menu ) _menu->addSeparator(); + if( _model->hasLinkedModels() ) + { + _menu->addAction( embed::getIconPixmap( "edit-delete" ), + AutomatableModel::tr( "Remove all linked controls" ), + amvSlots, SLOT( unlinkAllModels() ) ); + _menu->addSeparator(); + } + QString controllerTxt; if( _model->getControllerConnection() ) { @@ -253,5 +262,10 @@ void AutomatableModelViewSlots::removeSongGlobalAutomation() } +void AutomatableModelViewSlots::unlinkAllModels() +{ + amv->modelUntyped()->unlinkAllModels(); +} + #include "moc_AutomatableModelView.cxx"