Skip to content

Commit aecefc7

Browse files
authored
Merge pull request #3418 from pljones/sort-faders-by-channel
2 parents ebb58c5 + 01944f9 commit aecefc7

File tree

6 files changed

+46
-25
lines changed

6 files changed

+46
-25
lines changed

src/audiomixerboard.cpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,39 +1092,47 @@ void CAudioMixerBoard::ChangeFaderOrder ( const EChSortType eChSortType )
10921092
iMyFader = static_cast<int> ( i );
10931093
}
10941094

1095-
if ( eChSortType == ST_BY_NAME )
1095+
switch ( eChSortType )
10961096
{
1097+
case ST_BY_NAME:
10971098
PairList << QPair<QString, size_t> ( vecpChanFader[i]->GetReceivedName().toLower(), i );
1098-
}
1099-
else if ( eChSortType == ST_BY_CITY )
1100-
{
1101-
PairList << QPair<QString, size_t> ( vecpChanFader[i]->GetReceivedCity().toLower(), i );
1102-
}
1103-
else if ( eChSortType == ST_BY_INSTRUMENT )
1104-
{
1099+
break;
1100+
case ST_BY_CITY:
1101+
// sort first "by city" and second "by name" by adding the name after the city
1102+
PairList << QPair<QString, size_t> ( vecpChanFader[i]->GetReceivedCity().toLower() + vecpChanFader[i]->GetReceivedName().toLower(), i );
1103+
break;
1104+
case ST_BY_INSTRUMENT:
11051105
// sort first "by instrument" and second "by name" by adding the name after the instrument
11061106
PairList << QPair<QString, size_t> ( CInstPictures::GetName ( vecpChanFader[i]->GetReceivedInstrument() ) +
11071107
vecpChanFader[i]->GetReceivedName().toLower(),
11081108
i );
1109-
}
1110-
else if ( eChSortType == ST_BY_GROUPID )
1111-
{
1109+
break;
1110+
case ST_BY_GROUPID:
1111+
// sort first "by group" and second "by name" by adding the name after the group
11121112
if ( vecpChanFader[i]->GetGroupID() == INVALID_INDEX )
11131113
{
11141114
// put channels without a group at the end
1115-
PairList << QPair<QString, size_t> ( "z", i ); // group IDs are numbers, use letter to put it at the end
1115+
PairList << QPair<QString, size_t> ( "999" + vecpChanFader[i]->GetReceivedName().toLower(),
1116+
i ); // worst case is one group per channel (current max is 8)
11161117
}
11171118
else
11181119
{
1119-
PairList << QPair<QString, size_t> ( QString::number ( vecpChanFader[i]->GetGroupID() ), i );
1120+
PairList << QPair<QString, size_t> ( QString ( "%1" ).arg ( vecpChanFader[i]->GetGroupID(), 3, 10, QLatin1Char ( '0' ) ) +
1121+
vecpChanFader[i]->GetReceivedName().toLower(),
1122+
i );
11201123
}
1121-
}
1122-
else // ST_NO_SORT
1123-
{
1124+
break;
1125+
case ST_BY_SERVER_CHANNEL:
1126+
PairList << QPair<QString, size_t> ( QString ( "%1" ).arg ( vecpChanFader[i]->GetReceivedChID(), 3, 10, QLatin1Char ( '0' ) ) +
1127+
vecpChanFader[i]->GetReceivedName().toLower(),
1128+
i );
1129+
break;
1130+
default: // ST_NO_SORT
11241131
// per definition for no sort: faders are sorted in the order they appeared (note that we
11251132
// pad to a total of 11 characters with zeros to make sure the sorting is done correctly)
11261133
PairList << QPair<QString, size_t> ( QString ( "%1" ).arg ( vecpChanFader[i]->GetRunningNewClientCnt(), 11, 10, QLatin1Char ( '0' ) ),
11271134
i );
1135+
break;
11281136
}
11291137

11301138
// count the number of visible faders

src/audiomixerboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CChannelFader : public QObject
5555
QString GetReceivedName() { return cReceivedChanInfo.strName; }
5656
int GetReceivedInstrument() { return cReceivedChanInfo.iInstrument; }
5757
QString GetReceivedCity() { return cReceivedChanInfo.strCity; }
58+
int GetReceivedChID() { return cReceivedChanInfo.iChanID; }
5859
void SetChannelInfos ( const CChannelInfo& cChanInfo );
5960
void Show() { pFrame->show(); }
6061
void Hide() { pFrame->hide(); }

src/clientdlg.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
333333
QAction* ByCityAction =
334334
pViewMenu->addAction ( tr ( "Sort Users by &City" ), this, SLOT ( OnSortChannelsByCity() ), QKeySequence ( Qt::CTRL + Qt::Key_T ) );
335335

336+
QAction* ByServerChannelAction = pViewMenu->addAction ( tr ( "Sort Users by Se&rver Channel" ),
337+
this,
338+
SLOT ( OnSortChannelsByChannel() ),
339+
QKeySequence ( Qt::CTRL + Qt::Key_R ) );
340+
336341
OwnFaderFirstAction->setCheckable ( true );
337342
OwnFaderFirstAction->setChecked ( pSettings->bOwnFaderFirst );
338343

@@ -349,13 +354,12 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
349354
SortActionGroup->addAction ( ByGroupAction );
350355
ByCityAction->setCheckable ( true );
351356
SortActionGroup->addAction ( ByCityAction );
357+
ByServerChannelAction->setCheckable ( true );
358+
SortActionGroup->addAction ( ByServerChannelAction );
352359

353360
// initialize sort type setting (i.e., recover stored setting)
354361
switch ( pSettings->eChannelSortType )
355362
{
356-
case ST_NO_SORT:
357-
NoSortAction->setChecked ( true );
358-
break;
359363
case ST_BY_NAME:
360364
ByNameAction->setChecked ( true );
361365
break;
@@ -368,6 +372,12 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
368372
case ST_BY_CITY:
369373
ByCityAction->setChecked ( true );
370374
break;
375+
case ST_BY_SERVER_CHANNEL:
376+
ByServerChannelAction->setChecked ( true );
377+
break;
378+
default: // ST_NO_SORT
379+
NoSortAction->setChecked ( true );
380+
break;
371381
}
372382
MainMixerBoard->SetFaderSorting ( pSettings->eChannelSortType );
373383

src/clientdlg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public slots:
171171
void OnSortChannelsByInstrument() { MainMixerBoard->SetFaderSorting ( ST_BY_INSTRUMENT ); }
172172
void OnSortChannelsByGroupID() { MainMixerBoard->SetFaderSorting ( ST_BY_GROUPID ); }
173173
void OnSortChannelsByCity() { MainMixerBoard->SetFaderSorting ( ST_BY_CITY ); }
174+
void OnSortChannelsByChannel() { MainMixerBoard->SetFaderSorting ( ST_BY_SERVER_CHANNEL ); }
174175
void OnClearAllStoredSoloMuteSettings();
175176
void OnSetAllFadersToNewClientLevel() { MainMixerBoard->SetAllFaderLevelsToNewClientLevel(); }
176177
void OnAutoAdjustAllFaderLevels() { MainMixerBoard->AutoAdjustAllFaderLevels(); }

src/settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument,
266266
GetIniSetting ( IniXMLDocument, "client", "language", CLocale::FindSysLangTransFileName ( CLocale::GetAvailableTranslations() ).first );
267267

268268
// fader channel sorting
269-
if ( GetNumericIniSet ( IniXMLDocument, "client", "channelsort", 0, 4 /* ST_BY_CITY */, iValue ) )
269+
if ( GetNumericIniSet ( IniXMLDocument, "client", "channelsort", 0, 5 /* ST_BY_SERVER_CHANNEL */, iValue ) )
270270
{
271271
eChannelSortType = static_cast<EChSortType> ( iValue );
272272
}

src/util.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,12 @@ enum ERecorderState
558558
enum EChSortType
559559
{
560560
// used for settings -> enum values should be fixed
561-
ST_NO_SORT = 0,
562-
ST_BY_NAME = 1,
563-
ST_BY_INSTRUMENT = 2,
564-
ST_BY_GROUPID = 3,
565-
ST_BY_CITY = 4
561+
ST_NO_SORT = 0,
562+
ST_BY_NAME = 1,
563+
ST_BY_INSTRUMENT = 2,
564+
ST_BY_GROUPID = 3,
565+
ST_BY_CITY = 4,
566+
ST_BY_SERVER_CHANNEL = 5
566567
};
567568

568569
// Directory type --------------------------------------------------------------

0 commit comments

Comments
 (0)