From 68abd34908fcfdeae9984dadcbeabecf27d34ac1 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 28 Jul 2010 21:24:14 +0200 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 | 12 ++++++++---- include/AutomatableModelView.h | 3 ++- src/core/AutomatableModel.cpp | 18 ++++++++++++++++-- src/gui/AutomatableModelView.cpp | 25 +++++++++++++++++++++---- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index e419190d1..e2b6847ac 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -1,7 +1,7 @@ /* * AutomatableModel.h - declaration of class AutomatableModel * - * Copyright (c) 2007-2009 Tobias Doerffel + * Copyright (c) 2007-2010 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -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" ) ); @@ -211,6 +213,8 @@ public: inline bool armed(){ return m_armed; } inline void setArmed( bool _armed ){ m_armed = _armed; } + inline bool hasLinkedModels() { return m_hasLinkedModels; } + public slots: virtual void reset(); @@ -289,7 +293,7 @@ class FloatModel : public AutomatableModel public: FloatModel( float _val = 0, float _min = 0, float _max = 0, float _step = 0, ::Model * _parent = NULL, - const QString & _display_name = QString(), + const QString & _display_name = QString(), bool _default_constructed = false ) : AutomatableModel( Float, _val, _min, _max, _step, _parent, _display_name, _default_constructed ) @@ -306,7 +310,7 @@ class IntModel : public AutomatableModel public: IntModel( int _val = 0, int _min = 0, int _max = 0, ::Model * _parent = NULL, - const QString & _display_name = QString(), + const QString & _display_name = QString(), bool _default_constructed = false ) : AutomatableModel( Integer, _val, _min, _max, 1, _parent, _display_name, _default_constructed ) @@ -322,7 +326,7 @@ class BoolModel : public AutomatableModel { public: BoolModel( const bool _val = false, ::Model * _parent = NULL, - const QString & _display_name = QString(), + const QString & _display_name = QString(), bool _default_constructed = false ) : AutomatableModel( Bool, _val, false, true, 1, _parent, _display_name, _default_constructed ) diff --git a/include/AutomatableModelView.h b/include/AutomatableModelView.h index 77c893a11..cd0888618 100644 --- a/include/AutomatableModelView.h +++ b/include/AutomatableModelView.h @@ -1,7 +1,7 @@ /* * AutomatableModelView.h - class AutomatableModelView * - * Copyright (c) 2008-2009 Tobias Doerffel + * Copyright (c) 2008-2010 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -101,6 +101,7 @@ public slots: void execConnectionDialog(); void removeConnection(); void editSongGlobalAutomation(); + void unlinkAllModels(); void arm(); void deArm(); diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 26d2e91bd..4b0f02cf2 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -1,7 +1,7 @@ /* * AutomatableModel.cpp - some implementations of AutomatableModel-class * - * Copyright (c) 2008-2009 Tobias Doerffel + * Copyright (c) 2008-2010 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -248,7 +248,7 @@ void AutomatableModel::setAutomatedValue( const float _value ) void AutomatableModel::setRange( const float _min, const float _max, const float _step ) { - if( ( m_maxValue != _max ) || ( m_minValue != _min ) ) + if( ( m_maxValue != _max ) || ( m_minValue != _min ) ) { m_minValue = _min; m_maxValue = _max; @@ -423,6 +423,20 @@ void AutomatableModel::unlinkModels( AutomatableModel * _model1, +void AutomatableModel::unlinkAllModels() + +{ + AutomatableModel * _model; + foreach( _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 272f0940e..94c1173c4 100644 --- a/src/gui/AutomatableModelView.cpp +++ b/src/gui/AutomatableModelView.cpp @@ -1,8 +1,8 @@ /* - * automatable_model_view.cpp - implementation of AutomatableModelView + * AutomatableModelView.cpp - implementation of AutomatableModelView + * + * Copyright (c) 2008-2010 Tobias Doerffel * - * Copyright (c) 2008 Tobias Doerffel - * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -22,7 +22,6 @@ * */ - #include #include @@ -69,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)" ). @@ -91,6 +91,14 @@ void AutomatableModelView::addDefaultActions( QMenu * _menu ) SLOT( editSongGlobalAutomation() ) ); _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() ) { @@ -259,6 +267,15 @@ void AutomatableModelViewSlots::editSongGlobalAutomation() +void AutomatableModelViewSlots::unlinkAllModels() +{ + AutomatableModel * m = amv->modelUntyped(); + m->unlinkAllModels(); +} + + + + void AutomatableModelViewSlots::arm() { amv->modelUntyped()->setArmed( true );