Refactoring to follow current code style guide

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Achim Settelmeier
2009-05-29 00:05:15 +02:00
committed by Tobias Doerffel
parent 720e332891
commit cc317032e3
5 changed files with 117 additions and 115 deletions

View File

@@ -30,9 +30,9 @@
#include "midi_event_processor.h"
#include "midi_port.h"
#include "note.h"
#include <QString>
#include <QPair>
#include <QDomElement>
#include <QtCore/QString>
#include <QtCore/QPair>
#include <QtXml/QDomElement>
class QDomDocument;

View File

@@ -50,10 +50,10 @@ private:
bool m_keysActive; // true: configure key, false: configure controller
groupBox * m_actionKey_gb;
groupBox * m_actionController_gb;
QComboBox * m_actionsKey_box;
QComboBox * m_actionsController_box;
groupBox * m_actionKeyGroupBox;
groupBox * m_actionControllerGroupBox;
QComboBox * m_actionsKeyBox;
QComboBox * m_actionsControllerBox;
lcdSpinBoxModel * m_controllerSbModel;
} ;

View File

@@ -25,7 +25,7 @@
*/
#include <QtCore/QDir>
#include <QDomDocument>
#include <QtXml/QDomDocument>
#include "engine.h"
#include "automation_editor.h"

View File

@@ -24,11 +24,10 @@
*/
#include <stdio.h>
#include <QString>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNodeList>
#include <QtCore/QString>
#include <QtXml/QDomDocument>
#include <QtXml/QDomElement>
#include <QtXml/QDomNodeList>
#include "midi_control_listener.h"
#include "mixer.h"
@@ -39,7 +38,7 @@
#include "song.h"
#include "config_mgr.h"
const QString MidiControlListener::configClass = "midicontrollistener";
const QString MidiControlListener::configClass = "MidiControlListener";
QDomElement MidiControlListener::s_configTree;
const MidiControlListener::ActionNameMap MidiControlListener::actionNames[] =
@@ -54,7 +53,7 @@ const MidiControlListener::ActionNameMap MidiControlListener::actionNames[] =
MidiControlListener::MidiControlListener() :
m_port( "unnamed_midi_controller",
m_port( "UnnamedMidiController",
engine::getMixer()->getMidiClient(), this, NULL,
midiPort::Input ),
m_controlKeyCount( 0 ),
@@ -87,62 +86,64 @@ void MidiControlListener::processInEvent( const midiEvent & _me,
// pre-check whether this MIDI packet suits our configuration
switch( _me.m_type )
{
case MidiNoteOn:
case MidiNoteOff:
case MidiControlChange:
// ignore commands for other channels
if( m_channel != -1 && m_channel != _me.channel() )
case MidiNoteOn:
case MidiNoteOff:
case MidiControlChange:
// ignore commands for other channels
if( m_channel != -1 && m_channel != _me.channel() )
{
return;
}
break;
default:
// ignore commands other than note on/off and control change
return;
break;
default:
// ignore commands other than note on/off and control change
return;
}
// check MIDI packet type and act upon
switch( _me.m_type )
switch( _me.m_type )
{
case MidiNoteOn:
if( m_actionMapKeys.contains( _me.key() ) )
{
if( m_actionMapKeys.value( _me.key(), ActionNone ) == ActionControl )
case MidiNoteOn:
if( m_actionMapKeys.contains( _me.key() ) )
{
if( _me.velocity() > 0 )
if( m_actionMapKeys.value( _me.key(), ActionNone ) == ActionControl )
{
m_controlKeyCount++;
}
else
{
m_controlKeyCount--;
if( m_controlKeyCount < 0 )
if( _me.velocity() > 0 )
{
m_controlKeyCount = 0;
m_controlKeyCount++;
}
else
{
m_controlKeyCount--;
if( m_controlKeyCount < 0 )
{
m_controlKeyCount = 0;
}
}
}
else if( _me.velocity() > 0 &&
( !m_useControlKey || m_controlKeyCount > 0) )
{
act( m_actionMapKeys.value( _me.key(), ActionNone ) );
}
}
else if( _me.velocity() > 0 &&
( !m_useControlKey || m_controlKeyCount > 0) )
break;
case MidiNoteOff:
break;
case MidiControlChange:
// controller changed to a value other than zero
if( _me.m_data.m_param[1] > 0 )
{
act( m_actionMapKeys.value( _me.key(), ActionNone ) );
act( m_actionMapControllers.value( _me.m_data.m_param[0], ActionNone ) );
}
}
break;
case MidiNoteOff:
break;
case MidiControlChange:
// controller changed to a value other than zero
if( _me.m_data.m_param[1] > 0 )
{
act( m_actionMapControllers.value( _me.m_data.m_param[0], ActionNone ) );
}
break;
default:
// nop
break;
break;
default:
// nop
break;
}
}
@@ -153,15 +154,16 @@ void MidiControlListener::act( EventAction _action )
{
switch( _action )
{
case ActionNone:
case ActionControl:
break;
case ActionPlay:
engine::getSong()->play();
break;
case ActionStop:
engine::getSong()->stop();
break;
case ActionNone:
break;
case ActionControl:
break;
case ActionPlay:
engine::getSong()->play();
break;
case ActionStop:
engine::getSong()->stop();
break;
}
}
@@ -222,8 +224,8 @@ void MidiControlListener::saveConfiguration( QDomDocument & doc )
confRoot.appendChild( actionNode );
}
QDomElement lmms_config = doc.documentElement();
lmms_config.appendChild( confRoot );
QDomElement lmmsConfig = doc.documentElement();
lmmsConfig.appendChild( confRoot );
}

View File

@@ -27,7 +27,7 @@
#include <QtGui/QLayout>
#include <QtGui/QPushButton>
#include <QComboBox>
#include <QtGui/QComboBox>
#include "embed.h"
#include "group_box.h"
@@ -46,25 +46,25 @@ setupDialogMCL::setupDialogMCL( setupDialog * _parent ) :
resize( 270, 330 );
QWidget * buttons = new QWidget( this );
QHBoxLayout * btn_layout = new QHBoxLayout( buttons );
btn_layout->setSpacing( 0 );
btn_layout->setMargin( 0 );
QPushButton * ok_btn = new QPushButton( embed::getIconPixmap( "apply" ),
QHBoxLayout * buttonLayout = new QHBoxLayout( buttons );
buttonLayout->setSpacing( 0 );
buttonLayout->setMargin( 0 );
QPushButton * okButton = new QPushButton( embed::getIconPixmap( "apply" ),
tr( "OK" ), buttons );
connect( ok_btn, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
QPushButton * cancel_btn = new QPushButton( embed::getIconPixmap(
QPushButton * cancelButton = new QPushButton( embed::getIconPixmap(
"cancel" ),
tr( "Cancel" ),
buttons );
connect( cancel_btn, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
btn_layout->addStretch();
btn_layout->addSpacing( 10 );
btn_layout->addWidget( ok_btn );
btn_layout->addSpacing( 10 );
btn_layout->addWidget( cancel_btn );
btn_layout->addSpacing( 10 );
buttonLayout->addStretch();
buttonLayout->addSpacing( 10 );
buttonLayout->addWidget( okButton );
buttonLayout->addSpacing( 10 );
buttonLayout->addWidget( cancelButton );
buttonLayout->addSpacing( 10 );
QWidget * settings = new QWidget( this );
settings->setGeometry( 10, 10, 280, 100 );
@@ -79,56 +79,56 @@ setupDialogMCL::setupDialogMCL( setupDialog * _parent ) :
vlayout->addStretch();
m_actionKey_gb = new groupBox( tr( "MIDI KEYBOARD" ),
m_actionKeyGroupBox = new groupBox( tr( "MIDI KEYBOARD" ),
settings );
m_actionKey_gb->setFixedHeight( 160 );
m_actionKey_gb->ledButton()->setChecked( m_keysActive );
connect( m_actionKey_gb->ledButton(), SIGNAL( clicked() ),
m_actionKeyGroupBox->setFixedHeight( 160 );
m_actionKeyGroupBox->ledButton()->setChecked( m_keysActive );
connect( m_actionKeyGroupBox->ledButton(), SIGNAL( clicked() ),
this, SLOT( clickedKeyBox( ) ) );
m_actionController_gb = new groupBox( tr( "MIDI CONTROLLER" ),
m_actionControllerGroupBox = new groupBox( tr( "MIDI CONTROLLER" ),
settings );
m_actionController_gb->setFixedHeight( 100 );
m_actionController_gb->ledButton()->setChecked( ! m_keysActive );
connect( m_actionController_gb->ledButton(), SIGNAL( clicked() ),
m_actionControllerGroupBox->setFixedHeight( 100 );
m_actionControllerGroupBox->ledButton()->setChecked( ! m_keysActive );
connect( m_actionControllerGroupBox->ledButton(), SIGNAL( clicked() ),
this, SLOT( clickedControllerBox( ) ) );
QVBoxLayout * settings_vl = new QVBoxLayout( settings );
settings_vl->setSpacing( 0 );
settings_vl->setMargin( 0 );
settings_vl->addWidget( m_actionController_gb );
settings_vl->addSpacing( 10 );
settings_vl->addWidget( m_actionKey_gb );
settings_vl->addSpacing( 10 );
settings_vl->addStretch();
QVBoxLayout * settingsLayout = new QVBoxLayout( settings );
settingsLayout->setSpacing( 0 );
settingsLayout->setMargin( 0 );
settingsLayout->addWidget( m_actionControllerGroupBox );
settingsLayout->addSpacing( 10 );
settingsLayout->addWidget( m_actionKeyGroupBox );
settingsLayout->addSpacing( 10 );
settingsLayout->addStretch();
m_actionsKey_box = new QComboBox( m_actionKey_gb );
m_actionsKey_box->setGeometry( 10, 20, 150, 22 );
m_actionsKeyBox = new QComboBox( m_actionKeyGroupBox );
m_actionsKeyBox->setGeometry( 10, 20, 150, 22 );
for( int i = 0; i < MidiControlListener::numActions; ++i )
{
MidiControlListener::ActionNameMap action = MidiControlListener::action2ActionNameMap( (MidiControlListener::EventAction) i );
if( action.name != "" )
{
m_actionsKey_box->addItem( action.name );
m_actionsKeyBox->addItem( action.name );
}
}
QWidget * pianoWidget = new QWidget( m_actionKey_gb );
QWidget * pianoWidget = new QWidget( m_actionKeyGroupBox );
pianoWidget->move( 10, 60 );
PianoView * piano_view = new PianoView( pianoWidget );
piano_view->setFixedSize( 250, 84 );
PianoView * pianoViewWidget = new PianoView( pianoWidget );
pianoViewWidget->setFixedSize( 250, 84 );
m_actionsController_box = new QComboBox( m_actionController_gb );
m_actionsController_box->setGeometry( 10, 30, 150, 22 );
m_actionsControllerBox = new QComboBox( m_actionControllerGroupBox );
m_actionsControllerBox->setGeometry( 10, 30, 150, 22 );
for( int i = 0; i < MidiControlListener::numActions; ++i )
{
MidiControlListener::ActionNameMap action = MidiControlListener::action2ActionNameMap( (MidiControlListener::EventAction) i );
if( action.name != "" &&
action.action != MidiControlListener::ActionControl )
{
m_actionsController_box->addItem( action.name );
m_actionsControllerBox->addItem( action.name );
}
}
@@ -136,7 +136,7 @@ setupDialogMCL::setupDialogMCL( setupDialog * _parent ) :
m_controllerSbModel->setRange( 0, 127 );
m_controllerSbModel->setStep( 1 );
m_controllerSbModel->setValue( 63 );
lcdSpinBox * controllerSb = new lcdSpinBox( 3, m_actionController_gb );
lcdSpinBox * controllerSb = new lcdSpinBox( 3, m_actionControllerGroupBox );
controllerSb->setModel( m_controllerSbModel );
controllerSb->setLabel( tr( "CONTROLLER" ) );
controllerSb->move( 20, 60 );
@@ -160,7 +160,7 @@ void setupDialogMCL::accept( void )
{
MidiControlListener::ActionNameMap action =
MidiControlListener::actionName2ActionNameMap(
m_actionsKey_box->currentText() );
m_actionsKeyBox->currentText() );
m_parent->mclAddKeyAction( 40, action.action );
}
@@ -168,7 +168,7 @@ void setupDialogMCL::accept( void )
{
MidiControlListener::ActionNameMap action =
MidiControlListener::actionName2ActionNameMap(
m_actionsController_box->currentText() );
m_actionsControllerBox->currentText() );
m_parent->mclAddControllerAction( m_controllerSbModel->value(),
action.action );
@@ -182,8 +182,8 @@ void setupDialogMCL::accept( void )
void setupDialogMCL::clickedKeyBox( void )
{
m_keysActive = true;
m_actionKey_gb->ledButton()->setChecked( true );
m_actionController_gb->ledButton()->setChecked( false );
m_actionKeyGroupBox->ledButton()->setChecked( true );
m_actionControllerGroupBox->ledButton()->setChecked( false );
}
@@ -192,8 +192,8 @@ void setupDialogMCL::clickedKeyBox( void )
void setupDialogMCL::clickedControllerBox( void )
{
m_keysActive = false;
m_actionKey_gb->ledButton()->setChecked( false );
m_actionController_gb->ledButton()->setChecked( true );
m_actionKeyGroupBox->ledButton()->setChecked( false );
m_actionControllerGroupBox->ledButton()->setChecked( true );
}