Skip to content

Commit

Permalink
Merge pull request #3418 from pljones/sort-faders-by-channel
Browse files Browse the repository at this point in the history
  • Loading branch information
ann0see authored Oct 29, 2024
2 parents ebb58c5 + 01944f9 commit aecefc7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 25 deletions.
40 changes: 24 additions & 16 deletions src/audiomixerboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,39 +1092,47 @@ void CAudioMixerBoard::ChangeFaderOrder ( const EChSortType eChSortType )
iMyFader = static_cast<int> ( i );
}

if ( eChSortType == ST_BY_NAME )
switch ( eChSortType )
{
case ST_BY_NAME:
PairList << QPair<QString, size_t> ( vecpChanFader[i]->GetReceivedName().toLower(), i );
}
else if ( eChSortType == ST_BY_CITY )
{
PairList << QPair<QString, size_t> ( vecpChanFader[i]->GetReceivedCity().toLower(), i );
}
else if ( eChSortType == ST_BY_INSTRUMENT )
{
break;
case ST_BY_CITY:
// sort first "by city" and second "by name" by adding the name after the city
PairList << QPair<QString, size_t> ( vecpChanFader[i]->GetReceivedCity().toLower() + vecpChanFader[i]->GetReceivedName().toLower(), i );
break;
case ST_BY_INSTRUMENT:
// sort first "by instrument" and second "by name" by adding the name after the instrument
PairList << QPair<QString, size_t> ( CInstPictures::GetName ( vecpChanFader[i]->GetReceivedInstrument() ) +
vecpChanFader[i]->GetReceivedName().toLower(),
i );
}
else if ( eChSortType == ST_BY_GROUPID )
{
break;
case ST_BY_GROUPID:
// sort first "by group" and second "by name" by adding the name after the group
if ( vecpChanFader[i]->GetGroupID() == INVALID_INDEX )
{
// put channels without a group at the end
PairList << QPair<QString, size_t> ( "z", i ); // group IDs are numbers, use letter to put it at the end
PairList << QPair<QString, size_t> ( "999" + vecpChanFader[i]->GetReceivedName().toLower(),
i ); // worst case is one group per channel (current max is 8)
}
else
{
PairList << QPair<QString, size_t> ( QString::number ( vecpChanFader[i]->GetGroupID() ), i );
PairList << QPair<QString, size_t> ( QString ( "%1" ).arg ( vecpChanFader[i]->GetGroupID(), 3, 10, QLatin1Char ( '0' ) ) +
vecpChanFader[i]->GetReceivedName().toLower(),
i );
}
}
else // ST_NO_SORT
{
break;
case ST_BY_SERVER_CHANNEL:
PairList << QPair<QString, size_t> ( QString ( "%1" ).arg ( vecpChanFader[i]->GetReceivedChID(), 3, 10, QLatin1Char ( '0' ) ) +
vecpChanFader[i]->GetReceivedName().toLower(),
i );
break;
default: // ST_NO_SORT
// per definition for no sort: faders are sorted in the order they appeared (note that we
// pad to a total of 11 characters with zeros to make sure the sorting is done correctly)
PairList << QPair<QString, size_t> ( QString ( "%1" ).arg ( vecpChanFader[i]->GetRunningNewClientCnt(), 11, 10, QLatin1Char ( '0' ) ),
i );
break;
}

// count the number of visible faders
Expand Down
1 change: 1 addition & 0 deletions src/audiomixerboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CChannelFader : public QObject
QString GetReceivedName() { return cReceivedChanInfo.strName; }
int GetReceivedInstrument() { return cReceivedChanInfo.iInstrument; }
QString GetReceivedCity() { return cReceivedChanInfo.strCity; }
int GetReceivedChID() { return cReceivedChanInfo.iChanID; }
void SetChannelInfos ( const CChannelInfo& cChanInfo );
void Show() { pFrame->show(); }
void Hide() { pFrame->hide(); }
Expand Down
16 changes: 13 additions & 3 deletions src/clientdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
QAction* ByCityAction =
pViewMenu->addAction ( tr ( "Sort Users by &City" ), this, SLOT ( OnSortChannelsByCity() ), QKeySequence ( Qt::CTRL + Qt::Key_T ) );

QAction* ByServerChannelAction = pViewMenu->addAction ( tr ( "Sort Users by Se&rver Channel" ),
this,
SLOT ( OnSortChannelsByChannel() ),
QKeySequence ( Qt::CTRL + Qt::Key_R ) );

OwnFaderFirstAction->setCheckable ( true );
OwnFaderFirstAction->setChecked ( pSettings->bOwnFaderFirst );

Expand All @@ -349,13 +354,12 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
SortActionGroup->addAction ( ByGroupAction );
ByCityAction->setCheckable ( true );
SortActionGroup->addAction ( ByCityAction );
ByServerChannelAction->setCheckable ( true );
SortActionGroup->addAction ( ByServerChannelAction );

// initialize sort type setting (i.e., recover stored setting)
switch ( pSettings->eChannelSortType )
{
case ST_NO_SORT:
NoSortAction->setChecked ( true );
break;
case ST_BY_NAME:
ByNameAction->setChecked ( true );
break;
Expand All @@ -368,6 +372,12 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
case ST_BY_CITY:
ByCityAction->setChecked ( true );
break;
case ST_BY_SERVER_CHANNEL:
ByServerChannelAction->setChecked ( true );
break;
default: // ST_NO_SORT
NoSortAction->setChecked ( true );
break;
}
MainMixerBoard->SetFaderSorting ( pSettings->eChannelSortType );

Expand Down
1 change: 1 addition & 0 deletions src/clientdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public slots:
void OnSortChannelsByInstrument() { MainMixerBoard->SetFaderSorting ( ST_BY_INSTRUMENT ); }
void OnSortChannelsByGroupID() { MainMixerBoard->SetFaderSorting ( ST_BY_GROUPID ); }
void OnSortChannelsByCity() { MainMixerBoard->SetFaderSorting ( ST_BY_CITY ); }
void OnSortChannelsByChannel() { MainMixerBoard->SetFaderSorting ( ST_BY_SERVER_CHANNEL ); }
void OnClearAllStoredSoloMuteSettings();
void OnSetAllFadersToNewClientLevel() { MainMixerBoard->SetAllFaderLevelsToNewClientLevel(); }
void OnAutoAdjustAllFaderLevels() { MainMixerBoard->AutoAdjustAllFaderLevels(); }
Expand Down
2 changes: 1 addition & 1 deletion src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument,
GetIniSetting ( IniXMLDocument, "client", "language", CLocale::FindSysLangTransFileName ( CLocale::GetAvailableTranslations() ).first );

// fader channel sorting
if ( GetNumericIniSet ( IniXMLDocument, "client", "channelsort", 0, 4 /* ST_BY_CITY */, iValue ) )
if ( GetNumericIniSet ( IniXMLDocument, "client", "channelsort", 0, 5 /* ST_BY_SERVER_CHANNEL */, iValue ) )
{
eChannelSortType = static_cast<EChSortType> ( iValue );
}
Expand Down
11 changes: 6 additions & 5 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,12 @@ enum ERecorderState
enum EChSortType
{
// used for settings -> enum values should be fixed
ST_NO_SORT = 0,
ST_BY_NAME = 1,
ST_BY_INSTRUMENT = 2,
ST_BY_GROUPID = 3,
ST_BY_CITY = 4
ST_NO_SORT = 0,
ST_BY_NAME = 1,
ST_BY_INSTRUMENT = 2,
ST_BY_GROUPID = 3,
ST_BY_CITY = 4,
ST_BY_SERVER_CHANNEL = 5
};

// Directory type --------------------------------------------------------------
Expand Down

0 comments on commit aecefc7

Please sign in to comment.