improve the channel sorting algorithm (much cleaner code now)
This commit is contained in:
parent
77c24059b5
commit
e7b291d906
1 changed files with 14 additions and 18 deletions
|
@ -323,7 +323,7 @@ void CChannelFader::SetFaderLevel ( const int iLevel )
|
||||||
// server about the change
|
// server about the change
|
||||||
pFader->setValue ( iLevel );
|
pFader->setValue ( iLevel );
|
||||||
SendFaderLevelToServer ( iLevel );
|
SendFaderLevelToServer ( iLevel );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannelFader::SetPanValue ( const int iPan )
|
void CChannelFader::SetPanValue ( const int iPan )
|
||||||
|
@ -662,13 +662,13 @@ inline void CAudioMixerBoard::connectFaderSignalsToMixerBoardSlots()
|
||||||
&CAudioMixerBoardSlots<slotId>::OnChPanValueChanged;
|
&CAudioMixerBoardSlots<slotId>::OnChPanValueChanged;
|
||||||
|
|
||||||
QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::soloStateChanged,
|
QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::soloStateChanged,
|
||||||
this, &CAudioMixerBoard::UpdateSoloStates );
|
this, &CAudioMixerBoard::UpdateSoloStates );
|
||||||
|
|
||||||
QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::gainValueChanged,
|
QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::gainValueChanged,
|
||||||
this, pGainValueChanged );
|
this, pGainValueChanged );
|
||||||
|
|
||||||
QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::panValueChanged,
|
QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::panValueChanged,
|
||||||
this, pPanValueChanged );
|
this, pPanValueChanged );
|
||||||
|
|
||||||
connectFaderSignalsToMixerBoardSlots<slotId - 1>();
|
connectFaderSignalsToMixerBoardSlots<slotId - 1>();
|
||||||
}
|
}
|
||||||
|
@ -766,30 +766,26 @@ void CAudioMixerBoard::HideAll()
|
||||||
|
|
||||||
void CAudioMixerBoard::ChangeFaderOrder ( const bool bDoSort )
|
void CAudioMixerBoard::ChangeFaderOrder ( const bool bDoSort )
|
||||||
{
|
{
|
||||||
// TODO better solution to sort by names and get the indexes after sorting (here
|
// create a pair list of lower strings and fader ID for each channel
|
||||||
// we utilize the "data" property to store the original ID value)
|
QList<QPair<QString, int> > PairList;
|
||||||
QListWidget ListWidget;
|
|
||||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
// fill list widget (used for sorting the channels)
|
PairList << QPair<QString, int> ( vecpChanFader[i]->GetReceivedName().toLower(), i );
|
||||||
QListWidgetItem* pNewItem = new QListWidgetItem ( vecpChanFader[i]->GetReceivedName() );
|
|
||||||
pNewItem->setData ( Qt::UserRole, i );
|
|
||||||
ListWidget.addItem ( pNewItem );
|
|
||||||
|
|
||||||
// remove channels from layout (note that we keep the spacer on the right side)
|
|
||||||
pMainLayout->removeWidget ( vecpChanFader[i]->GetMainWidget() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if requested, sort the channels
|
||||||
if ( bDoSort )
|
if ( bDoSort )
|
||||||
{
|
{
|
||||||
ListWidget.sortItems();
|
qStableSort ( PairList.begin(), PairList.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// add channels to the layout in the new order (since we insert on the left, we
|
// add channels to the layout in the new order (since we insert on the left, we
|
||||||
// have to use a backwards counting loop)
|
// have to use a backwards counting loop), note that it is not required to remove
|
||||||
|
// the widget from the layout first but it is moved to the new position automatically
|
||||||
for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- )
|
for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- )
|
||||||
{
|
{
|
||||||
// add fader frame to the audio mixer board layout
|
pMainLayout->insertWidget ( 0, vecpChanFader[PairList[i].second]->GetMainWidget() );
|
||||||
pMainLayout->insertWidget ( 0, vecpChanFader[ListWidget.item ( i )->data ( Qt::UserRole ).toInt()]->GetMainWidget() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue