added support for filter the server list

This commit is contained in:
Volker Fischer 2020-04-14 16:51:44 +02:00
parent 9cbcbb1471
commit 514bd25fee
5 changed files with 106 additions and 11 deletions

View file

@ -6,6 +6,8 @@
* added support for 64 samples OPUS packets in the client (if a sound card buffer size * added support for 64 samples OPUS packets in the client (if a sound card buffer size
larger or equal than 128 samples is chosen, the legacy 128 samples OPUS packets are used) larger or equal than 128 samples is chosen, the legacy 128 samples OPUS packets are used)
* added a filter for the server list to, e.g., filter a specific country or search for a musician
* refresh server list if the Central Server address type is changed * refresh server list if the Central Server address type is changed
* the unit of the mixer faders is now dB using the range -50 dB to 0 dB * the unit of the mixer faders is now dB using the range -50 dB to 0 dB

View file

@ -35,7 +35,8 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList,
strSelectedServerName ( "" ), strSelectedServerName ( "" ),
bShowCompleteRegList ( bNewShowCompleteRegList ), bShowCompleteRegList ( bNewShowCompleteRegList ),
bServerListReceived ( false ), bServerListReceived ( false ),
bServerListItemWasChosen ( false ) bServerListItemWasChosen ( false ),
bListFilterWasActive ( false )
{ {
setupUi ( this ); setupUi ( this );
@ -142,6 +143,10 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList,
SIGNAL ( activated ( QModelIndex ) ), SIGNAL ( activated ( QModelIndex ) ),
this, SLOT ( OnConnectClicked() ) ); this, SLOT ( OnConnectClicked() ) );
// line edit
QObject::connect ( edtFilter, SIGNAL ( textEdited ( const QString& ) ),
this, SLOT ( OnFilterTextEdited ( const QString& ) ) );
// combo boxes // combo boxes
QObject::connect ( cbxServerAddr, SIGNAL ( editTextChanged ( const QString& ) ), QObject::connect ( cbxServerAddr, SIGNAL ( editTextChanged ( const QString& ) ),
this, SLOT ( OnServerAddrEditTextChanged ( const QString& ) ) ); this, SLOT ( OnServerAddrEditTextChanged ( const QString& ) ) );
@ -188,6 +193,7 @@ void CConnectDlg::RequestServerList()
// reset flags // reset flags
bServerListReceived = false; bServerListReceived = false;
bServerListItemWasChosen = false; bServerListItemWasChosen = false;
bListFilterWasActive = false;
// clear current address and name // clear current address and name
strSelectedAddress = ""; strSelectedAddress = "";
@ -196,6 +202,9 @@ void CConnectDlg::RequestServerList()
// clear server list view // clear server list view
lvwServers->clear(); lvwServers->clear();
// clear filter edit box
edtFilter->setText ( "" );
// get the IP address of the central server (using the ParseNetworAddress // get the IP address of the central server (using the ParseNetworAddress
// function) when the connect dialog is opened, this seems to be the correct // function) when the connect dialog is opened, this seems to be the correct
// time to do it // time to do it
@ -485,6 +494,66 @@ void CConnectDlg::OnServerAddrEditTextChanged ( const QString& )
lvwServers->clearSelection(); lvwServers->clearSelection();
} }
void CConnectDlg::UpdateListFilter()
{
const QString sFilterText = edtFilter->text();
if ( !sFilterText.isEmpty() )
{
bListFilterWasActive = true;
const int iServerListLen = lvwServers->topLevelItemCount();
for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ )
{
bool bFilterFound = false;
// search server name
if ( lvwServers->topLevelItem ( iIdx )->text ( 0 ).indexOf ( sFilterText, 0, Qt::CaseInsensitive ) >= 0 )
{
bFilterFound = true;
}
// search location
if ( lvwServers->topLevelItem ( iIdx )->text ( 3 ).indexOf ( sFilterText, 0, Qt::CaseInsensitive ) >= 0 )
{
bFilterFound = true;
}
// search childs
for ( int iCCnt = 0; iCCnt < lvwServers->topLevelItem ( iIdx )->childCount(); iCCnt++ )
{
if ( lvwServers->topLevelItem ( iIdx )->child ( iCCnt )->text ( 0 ).indexOf ( sFilterText, 0, Qt::CaseInsensitive ) >= 0 )
{
bFilterFound = true;
}
}
// only update Hide state if ping time was received
if ( !lvwServers->topLevelItem ( iIdx )->text ( 1 ).isEmpty() )
{
lvwServers->topLevelItem ( iIdx )->setHidden ( !bFilterFound );
}
}
}
else
{
// if the filter was active but is now disabled, we have to update all list
// view items for the "ping received" hide state
if ( bListFilterWasActive )
{
const int iServerListLen = lvwServers->topLevelItemCount();
for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ )
{
// if ping time is empty, hide item
lvwServers->topLevelItem ( iIdx )->setHidden ( lvwServers->topLevelItem ( iIdx )->text ( 1 ).isEmpty() );
}
bListFilterWasActive = false;
}
}
}
void CConnectDlg::OnConnectClicked() void CConnectDlg::OnConnectClicked()
{ {
// get the IP address to be used according to the following definitions: // get the IP address to be used according to the following definitions:
@ -561,6 +630,9 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress&
if ( pCurListViewItem ) if ( pCurListViewItem )
{ {
// check if this is the first time a ping time is set
const bool bIsFirstPing = pCurListViewItem->text ( 1 ).isEmpty();
// update the color of the ping time font // update the color of the ping time font
switch ( ePingTimeLEDColor ) switch ( ePingTimeLEDColor )
{ {
@ -604,11 +676,8 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress&
// update number of clients value (hidden) // update number of clients value (hidden)
pCurListViewItem->setText ( 6, QString().setNum ( iNumClients ) ); pCurListViewItem->setText ( 6, QString().setNum ( iNumClients ) );
// a ping time was received, set item to visible (note that we have // this is the first time a ping time was received, set item to visible
// to check if the item is hidden, otherwise we get a lot of CPU if ( bIsFirstPing )
// usage by calling "setHidden(false)" even if the item was already
// visible)
if ( pCurListViewItem->isHidden() )
{ {
pCurListViewItem->setHidden ( false ); pCurListViewItem->setHidden ( false );
} }
@ -649,6 +718,10 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress&
{ {
lvwServers->setRootIsDecorated ( false ); lvwServers->setRootIsDecorated ( false );
} }
// we may have changed the Hidden state for some items, if a filter was active, we now
// have to update it to void lines appear which do not satisfy the filter criteria
UpdateListFilter();
} }
QTreeWidgetItem* CConnectDlg::FindListViewItem ( const CHostAddress& InetAddr ) QTreeWidgetItem* CConnectDlg::FindListViewItem ( const CHostAddress& InetAddr )

View file

@ -83,6 +83,7 @@ protected:
QTreeWidgetItem* FindListViewItem ( const CHostAddress& InetAddr ); QTreeWidgetItem* FindListViewItem ( const CHostAddress& InetAddr );
QTreeWidgetItem* GetParentListViewItem ( QTreeWidgetItem* pItem ); QTreeWidgetItem* GetParentListViewItem ( QTreeWidgetItem* pItem );
void DeleteAllListViewItemChilds ( QTreeWidgetItem* pItem ); void DeleteAllListViewItemChilds ( QTreeWidgetItem* pItem );
void UpdateListFilter();
QTimer TimerPing; QTimer TimerPing;
QTimer TimerReRequestServList; QTimer TimerReRequestServList;
@ -93,11 +94,13 @@ protected:
bool bShowCompleteRegList; bool bShowCompleteRegList;
bool bServerListReceived; bool bServerListReceived;
bool bServerListItemWasChosen; bool bServerListItemWasChosen;
bool bListFilterWasActive;
public slots: public slots:
void OnServerListItemSelectionChanged(); void OnServerListItemSelectionChanged();
void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int ); void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int );
void OnServerAddrEditTextChanged ( const QString& ); void OnServerAddrEditTextChanged ( const QString& );
void OnFilterTextEdited ( const QString& ) { UpdateListFilter(); }
void OnConnectClicked(); void OnConnectClicked();
void OnTimerPing(); void OnTimerPing();
void OnTimerReRequestServList(); void OnTimerReRequestServList();

View file

@ -24,6 +24,23 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edtFilter"/>
</item>
</layout>
</item>
<item> <item>
<widget class="QTreeWidget" name="lvwServers"> <widget class="QTreeWidget" name="lvwServers">
<property name="editTriggers"> <property name="editTriggers">

View file

@ -174,11 +174,11 @@ timing jitter. If the Auto check is enabled, the jitter buffer size faders are d
![Audio channels](audiochannels.png) ![Audio channels](audiochannels.png)
Select the number of audio channels to be used. There are three modes available. The mono and stereo modes use one Select the number of audio channels to be used for communication between client and server. There are three modes
and two audio channels respectively. In the mono-in/stereo-out mode the audio signal which is sent to the server is available. The mono and stereo modes use one and two audio channels respectively. In the mono-in/stereo-out mode
mono but the return signal is stereo. This is useful for the case that the sound card puts the instrument on one the audio signal which is sent to the server is mono but the return signal is stereo. This is useful for the case
input channel and the microphone on the other channel. In that case the two input signals can be mixed to one mono that the sound card puts the instrument on one input channel and the microphone on the other channel. In that case
channel but the server mix can be heard in stereo. the two input signals can be mixed to one mono channel but the server mix can be heard in stereo.
Enabling the stereo streaming mode will increase the stream data rate. Make sure that the current upload rate does Enabling the stereo streaming mode will increase the stream data rate. Make sure that the current upload rate does
not exceed the available bandwidth of your internet connection. not exceed the available bandwidth of your internet connection.