New methods to unsubscribe all readable/writeable ports of a midiPort object.
Moved the code to unsubscribe all readable and/or writeable ports to own methods and thus made them publically available to avoid duplicate code. Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
committed by
Tobias Doerffel
parent
227de591bd
commit
de26ba5f00
@@ -126,6 +126,14 @@ public:
|
||||
return( m_writablePorts );
|
||||
}
|
||||
|
||||
void unsubscribeAllReadablePorts( void );
|
||||
void unsubscribeAllWriteablePorts( void );
|
||||
inline void unsubscribeAllPorts( void )
|
||||
{
|
||||
unsubscribeAllReadablePorts();
|
||||
unsubscribeAllWriteablePorts();
|
||||
}
|
||||
|
||||
midiPortMenu * m_readablePortsMenu;
|
||||
midiPortMenu * m_writablePortsMenu;
|
||||
|
||||
|
||||
@@ -256,16 +256,7 @@ void MidiControlListener::readConfiguration()
|
||||
m_actionMapControllers.clear();
|
||||
|
||||
// unsubscribe all ports
|
||||
midiPort::map map = m_port.readablePorts();
|
||||
for( midiPort::map::iterator it = map.begin();
|
||||
it != map.end(); ++it )
|
||||
{
|
||||
if( it.value() )
|
||||
{
|
||||
m_port.subscribeReadablePort( it.key(), false );
|
||||
}
|
||||
}
|
||||
|
||||
m_port.unsubscribeAllPorts();
|
||||
|
||||
// check whether there's a configuration tree at all
|
||||
if( s_configTree.isNull() || ! s_configTree.hasChildNodes() )
|
||||
|
||||
@@ -304,6 +304,38 @@ void midiPort::subscribeWritablePort( const QString & _port, bool _subscribe )
|
||||
|
||||
|
||||
|
||||
void midiPort::unsubscribeAllReadablePorts( void )
|
||||
{
|
||||
for( map::const_iterator it = m_readablePorts.begin();
|
||||
it != m_readablePorts.end(); ++it )
|
||||
{
|
||||
// subscribed?
|
||||
if( it.value() )
|
||||
{
|
||||
subscribeReadablePort( it.key(), false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void midiPort::unsubscribeAllWriteablePorts( void )
|
||||
{
|
||||
for( map::const_iterator it = m_writablePorts.begin();
|
||||
it != m_writablePorts.end(); ++it )
|
||||
{
|
||||
// subscribed?
|
||||
if( it.value() )
|
||||
{
|
||||
subscribeWritablePort( it.key(), false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void midiPort::updateMidiPortMode( void )
|
||||
{
|
||||
// this small lookup-table makes everything easier
|
||||
@@ -317,28 +349,12 @@ void midiPort::updateMidiPortMode( void )
|
||||
// check whether we have to dis-check items in connection-menu
|
||||
if( !inputEnabled() )
|
||||
{
|
||||
for( map::const_iterator it = m_readablePorts.begin();
|
||||
it != m_readablePorts.end(); ++it )
|
||||
{
|
||||
// subscribed?
|
||||
if( it.value() )
|
||||
{
|
||||
subscribeReadablePort( it.key(), false );
|
||||
}
|
||||
}
|
||||
unsubscribeAllReadablePorts();
|
||||
}
|
||||
|
||||
if( !outputEnabled() )
|
||||
{
|
||||
for( map::const_iterator it = m_writablePorts.begin();
|
||||
it != m_writablePorts.end(); ++it )
|
||||
{
|
||||
// subscribed?
|
||||
if( it.value() )
|
||||
{
|
||||
subscribeWritablePort( it.key(), false );
|
||||
}
|
||||
}
|
||||
unsubscribeAllWriteablePorts();
|
||||
}
|
||||
|
||||
emit readablePortsChanged();
|
||||
|
||||
Reference in New Issue
Block a user