Use range-based for loops + fix const correctness

This commit is contained in:
Colin Wallace
2018-04-15 18:17:37 -07:00
committed by Lukas W
parent ae0dd21df3
commit da126bfb5c
4 changed files with 19 additions and 33 deletions

View File

@@ -130,6 +130,7 @@ public:
void removeConnection( ControllerConnection * );
int connectionCount() const;
bool hasModel( const Model * m ) const;
public slots:
virtual ControllerDialog * createDialog( QWidget * _parent );
@@ -139,8 +140,6 @@ public slots:
m_name = _new_name;
}
bool hasModel( const Model * m );
protected:
// The internal per-controller get-value function

View File

@@ -70,7 +70,6 @@ private:
} ;
typedef BoolModel groupBoxModel;
#endif

View File

@@ -63,11 +63,9 @@ Controller::Controller( ControllerTypes _type, Model * _parent,
// Check if name is already in use
bool name_used = false;
QVector<Controller *>::const_iterator it;
for ( it = s_controllers.constBegin();
it != s_controllers.constEnd(); ++it )
for (Controller * controller : s_controllers)
{
if ( (*it)->name() == new_name )
if ( controller->name() == new_name )
{
name_used = true;
break;
@@ -157,13 +155,13 @@ float Controller::runningTime()
void Controller::triggerFrameCounter()
{
for( int i = 0; i < s_controllers.size(); ++i )
for (Controller * controller : s_controllers)
{
// This signal is for updating values for both stubborn knobs and for
// painting. If we ever get all the widgets to use or at least check
// currentValue() then we can throttle the signal and only use it for
// GUI.
emit s_controllers.at(i)->valueChanged();
emit controller->valueChanged();
}
s_periods ++;
@@ -174,10 +172,10 @@ void Controller::triggerFrameCounter()
void Controller::resetFrameCounter()
{
for( int i = 0; i < s_controllers.size(); ++i )
for (Controller * controller : s_controllers)
{
s_controllers.at( i )->m_bufferLastUpdated = 0;
}
controller->m_bufferLastUpdated = 0;
}
s_periods = 0;
}
@@ -190,15 +188,11 @@ Controller * Controller::create( ControllerTypes _ct, Model * _parent )
switch( _ct )
{
case Controller::DummyController:
if( dummy )
c = dummy;
else
{
c = new Controller( DummyController, NULL,
case Controller::DummyController:
if (!dummy)
dummy = new Controller( DummyController, NULL,
QString() );
dummy = c;
}
c = dummy;
break;
case Controller::LfoController:
@@ -247,12 +241,10 @@ Controller * Controller::create( const QDomElement & _this, Model * _parent )
bool Controller::hasModel( const Model * m )
bool Controller::hasModel( const Model * m ) const
{
QObjectList chldren = children();
for( int i = 0; i < chldren.size(); ++i )
for (QObject * c : children())
{
QObject * c = chldren.at(i);
AutomatableModel * am = qobject_cast<AutomatableModel*>(c);
if( am != NULL )
{
@@ -262,16 +254,13 @@ bool Controller::hasModel( const Model * m )
}
ControllerConnection * cc = am->controllerConnection();
if( cc != NULL )
if( cc != NULL && cc->getController()->hasModel( m ) )
{
if( cc->getController()->hasModel( m ) )
{
return true;
}
return true;
}
}
}
return false;
}

View File

@@ -189,12 +189,11 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent,
m_userController = new ComboBox( m_userGroupBox, "Controller" );
m_userController->setGeometry( 10, 24, 200, 22 );
for( int i = 0; i < Engine::getSong()->controllers().size(); ++i )
for (Controller * c : Engine::getSong()->controllers())
{
Controller * c = Engine::getSong()->controllers().at( i );
m_userController->model()->addItem( c->name() );
}
// Mapping functions
m_mappingBox = new TabWidget( tr( "MAPPING FUNCTION" ), this );