From 6b1dac7ac80ab6a512c01ccf4540df74438ffb64 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 19 Apr 2020 09:39:58 +0200 Subject: [PATCH] bug fix for server list filter, reported by pljones --- ChangeLog | 10 ++++------ src/connectdlg.cpp | 49 +++++++++++++++++++++++++++++----------------- src/connectdlg.h | 4 +++- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04a6f372..6c4d5e89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,18 +3,16 @@ 3.5.2git -TODO offer the Jamulus ASIO settingspanel in case of an ASIO ERROR to fix, e.g., incorrect sample rate (https://sourceforge.net/p/llcon/discussion/533517/thread/777663cf94/#035f) +TODO store Show All Musicians setting in the ini-file -TODO try to find a way to catch Windows exceptions in case a 64 bit Jamulus tries to load a 32 bit Jack Audio ASIO dll +TODO if you select server list filter all text and delete, the filter is not updated TODO improve audio drop out behaviour with OPUS64 by tuning the coding rate (it seems that for some coding rates we get loud artifacts on audio drop outs whereas for slightly different rates the behavior is much more pleasent) -TODO store Show All Musicians setting in the ini-file +TODO offer the Jamulus ASIO settingspanel in case of an ASIO ERROR to fix, e.g., incorrect sample rate (https://sourceforge.net/p/llcon/discussion/533517/thread/777663cf94/#035f) -TODO bug fix: "Start up the new version with the Connection Setup showing. "Show all musicians" is on (as I say). Switch it off before the list is displayed. The - checkbox is off - but the list displays all musicians! You need to turn it on and off again to get it to do its thing. (If you wait a little, it's fine - - i.e. before it's populated the musicians but after it's displayed the list, turn it off.)", see https://github.com/corrados/jamulus/issues/78 +TODO try to find a way to catch Windows exceptions in case a 64 bit Jamulus tries to load a 32 bit Jack Audio ASIO dll TODO the server list filter seems not to work if --showallservers is used diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index f6aa0943..f993c835 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -36,7 +36,8 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList, bShowCompleteRegList ( bNewShowCompleteRegList ), bServerListReceived ( false ), bServerListItemWasChosen ( false ), - bListFilterWasActive ( false ) + bListFilterWasActive ( false ), + bShowAllMusicians ( true ) { setupUi ( this ); @@ -219,11 +220,8 @@ void CConnectDlg::RequestServerList() // clear filter edit box edtFilter->setText ( "" ); - // per default we expand all list items (not for the show all servers mode) - if ( !bShowCompleteRegList ) - { - chbExpandAll->setCheckState ( Qt::Checked ); - } + // update Show All Musicians check box (this will call ShowAllMusicians()) + chbExpandAll->setCheckState ( bShowAllMusicians ? Qt::Checked : Qt::Unchecked ); // get the IP address of the central server (using the ParseNetworAddress // function) when the connect dialog is opened, this seems to be the correct @@ -385,7 +383,7 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, pNewListViewItem->setData ( 0, Qt::UserRole, CurHostAddress.toString() ); // per default expand the list item (if not "show all servers") - if ( !bShowCompleteRegList ) + if ( bShowAllMusicians ) { lvwServers->expandItem ( pNewListViewItem ); } @@ -514,9 +512,11 @@ void CConnectDlg::OnServerAddrEditTextChanged ( const QString& ) lvwServers->clearSelection(); } -void CConnectDlg::OnExpandAllStateChanged ( int value ) +void CConnectDlg::ShowAllMusicians ( const bool bState ) { - if ( value == Qt::Checked ) + bShowAllMusicians = bState; + + if ( bState ) { lvwServers->expandAll(); } @@ -537,33 +537,41 @@ void CConnectDlg::UpdateListFilter() for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ ) { - bool bFilterFound = false; + QTreeWidgetItem* pCurListViewItem = lvwServers->topLevelItem ( iIdx ); + bool bFilterFound = false; // search server name - if ( lvwServers->topLevelItem ( iIdx )->text ( 0 ).indexOf ( sFilterText, 0, Qt::CaseInsensitive ) >= 0 ) + if ( pCurListViewItem->text ( 0 ).indexOf ( sFilterText, 0, Qt::CaseInsensitive ) >= 0 ) { bFilterFound = true; } // search location - if ( lvwServers->topLevelItem ( iIdx )->text ( 3 ).indexOf ( sFilterText, 0, Qt::CaseInsensitive ) >= 0 ) + if ( pCurListViewItem->text ( 3 ).indexOf ( sFilterText, 0, Qt::CaseInsensitive ) >= 0 ) { bFilterFound = true; } // search childs - for ( int iCCnt = 0; iCCnt < lvwServers->topLevelItem ( iIdx )->childCount(); iCCnt++ ) + for ( int iCCnt = 0; iCCnt < pCurListViewItem->childCount(); iCCnt++ ) { - if ( lvwServers->topLevelItem ( iIdx )->child ( iCCnt )->text ( 0 ).indexOf ( sFilterText, 0, Qt::CaseInsensitive ) >= 0 ) + if ( pCurListViewItem->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() ) + if ( !pCurListViewItem->text ( 1 ).isEmpty() ) { - lvwServers->topLevelItem ( iIdx )->setHidden ( !bFilterFound ); + // only update hide and expand status if the hide state has to be changed to + // preserve if user clicked on expand icon manually + if ( ( pCurListViewItem->isHidden() && bFilterFound ) || + ( !pCurListViewItem->isHidden() && !bFilterFound ) ) + { + pCurListViewItem->setHidden ( !bFilterFound ); + pCurListViewItem->setExpanded ( bShowAllMusicians ); + } } } } @@ -577,8 +585,13 @@ void CConnectDlg::UpdateListFilter() for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ ) { - // if ping time is empty, hide item - lvwServers->topLevelItem ( iIdx )->setHidden ( lvwServers->topLevelItem ( iIdx )->text ( 1 ).isEmpty() ); + QTreeWidgetItem* pCurListViewItem = lvwServers->topLevelItem ( iIdx ); + + // if ping time is empty, hide item (if not already hidden) + if ( pCurListViewItem->text ( 1 ).isEmpty() && !pCurListViewItem->isHidden() ) + { + pCurListViewItem->setHidden ( true ); + } } bListFilterWasActive = false; diff --git a/src/connectdlg.h b/src/connectdlg.h index 9b376e0f..39db1853 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -83,6 +83,7 @@ protected: QTreeWidgetItem* GetParentListViewItem ( QTreeWidgetItem* pItem ); void DeleteAllListViewItemChilds ( QTreeWidgetItem* pItem ); void UpdateListFilter(); + void ShowAllMusicians ( const bool bState ); QTimer TimerPing; QTimer TimerReRequestServList; @@ -94,13 +95,14 @@ protected: bool bServerListReceived; bool bServerListItemWasChosen; bool bListFilterWasActive; + bool bShowAllMusicians; public slots: void OnServerListItemSelectionChanged(); void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int ); void OnServerAddrEditTextChanged ( const QString& ); void OnFilterTextEdited ( const QString& ) { UpdateListFilter(); } - void OnExpandAllStateChanged ( int value ); + void OnExpandAllStateChanged ( int value ) { ShowAllMusicians ( value == Qt::Checked ); } void OnConnectClicked(); void OnTimerPing(); void OnTimerReRequestServList();