From 2ad6eb160025f6019a02c87241a87052b40fe3c2 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 9 Dec 2015 17:11:16 +0000 Subject: [PATCH] finished: show the names of the connected clients in the server list --- ChangeLog | 4 +-- src/audiomixerboard.cpp | 21 +----------- src/audiomixerboard.h | 9 +++-- src/connectdlg.cpp | 73 ++++++----------------------------------- src/connectdlg.h | 4 --- src/util.h | 19 +++++++++++ 6 files changed, 35 insertions(+), 95 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a3896ae..59104e65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,9 +2,7 @@ 3.4.0 - -TODO: (close Ticket on Sourceforge if finished!) - - on request show the names of the connected clients in the server list +- show the names of the connected clients in the server list diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 346f0b39..cbc16d4f 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -308,7 +308,7 @@ void CChannelFader::SetText ( const CChannelInfo& ChanInfo ) // break text at predefined position const int iBreakPos = MAX_LEN_FADER_TAG / 2; - QString strModText = GenFaderText ( ChanInfo ); + QString strModText = ChanInfo.GenNameForDisplay(); if ( strModText.length() > iBreakPos ) { @@ -459,25 +459,6 @@ double CChannelFader::CalcFaderGain ( const int value ) return static_cast ( value ) / AUD_MIX_FADER_MAX; } -QString CChannelFader::GenFaderText ( const CChannelInfo& ChanInfo ) -{ - // if text is empty, show IP address instead - if ( ChanInfo.strName.isEmpty() ) - { - // convert IP address to text and show it (use dummy port number - // since it is not used here) - const CHostAddress TempAddr = - CHostAddress ( QHostAddress ( ChanInfo.iIpAddr ), 0 ); - - return TempAddr.toString ( CHostAddress::SM_IP_NO_LAST_BYTE ); - } - else - { - // show name of channel - return ChanInfo.strName; - } -} - /******************************************************************************\ * CAudioMixerBoard * diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index d3082b53..4593473c 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -62,11 +62,10 @@ public: void Reset(); protected: - double CalcFaderGain ( const int value ); - void SetMute ( const bool bState ); - QString GenFaderText ( const CChannelInfo& ChanInfo ); - void SendFaderLevelToServer ( const int iLevel ); - void SetupFaderTag ( const ESkillLevel eSkillLevel ); + double CalcFaderGain ( const int value ); + void SetMute ( const bool bState ); + void SendFaderLevelToServer ( const int iLevel ); + void SetupFaderTag ( const ESkillLevel eSkillLevel ); QFrame* pFrame; QGroupBox* pLabelInstBox; diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 05df3db3..0e11d4c7 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -93,17 +93,9 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList, lvwServers->setColumnCount ( 5 ); lvwServers->hideColumn ( 4 ); - // setup the server list context menu - lvwServers->setContextMenuPolicy ( Qt::CustomContextMenu ); - // per default the root shall not be decorated (to save space) lvwServers->setRootIsDecorated ( false ); - pServerListContextMenu = new QMenu ( this ); - - pServerListContextMenu->addAction ( tr ( "&Query Musicians Names" ), this, - SLOT ( OnServerListContextMenuNames() ) ); - // make sure the connect button has the focus butConnect->setFocus(); @@ -127,10 +119,6 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList, SIGNAL ( activated ( QModelIndex ) ), this, SLOT ( OnConnectClicked() ) ); - QObject::connect ( lvwServers, - SIGNAL ( customContextMenuRequested ( const QPoint& ) ), - this, SLOT ( OnCustomContextMenuRequested ( const QPoint& ) ) ); - // combo boxes QObject::connect ( cbxServerAddr, SIGNAL ( editTextChanged ( const QString& ) ), this, SLOT ( OnServerAddrEditTextChanged ( const QString& ) ) ); @@ -344,15 +332,14 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, pNewChildListViewItem->setFirstColumnSpanned ( true ); // set the clients name - pNewChildListViewItem->setText ( 0, vecChanInfo[i].strName ); + pNewChildListViewItem->setText ( 0, vecChanInfo[i].GenNameForDisplay() ); // add the new child to the corresponding server item pCurListViewItem->addChild ( pNewChildListViewItem ); // at least one server has childs now, show decoration to be able - // to show the childs and also expand to see the new childs + // to show the childs lvwServers->setRootIsDecorated ( true ); - lvwServers->expandItem ( pCurListViewItem ); } } } @@ -387,24 +374,6 @@ void CConnectDlg::OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, } } -void CConnectDlg::OnCustomContextMenuRequested ( const QPoint& Position ) -{ - // get the item to which the context menu is assigned to based on the given - // mouse position - QTreeWidgetItem* Item = lvwServers->itemAt ( Position ); - - // first check if the item is valid - if ( Item != 0 ) - { - // only show the context menu if there is at least von conntected client - if ( Item->text ( 2 ).toInt() > 0 ) - { - // use the given position for the position of the context menu - pServerListContextMenu->exec ( lvwServers->mapToGlobal ( Position ) ); - } - } -} - void CConnectDlg::OnServerAddrEditTextChanged ( const QString& ) { // in the server address combo box, a text was changed, remove selection @@ -444,28 +413,6 @@ void CConnectDlg::OnConnectClicked() done ( QDialog::Accepted ); } -void CConnectDlg::OnServerListContextMenuNames() -{ - // get the current selected item(s) - QList CurSelListItemList = lvwServers->selectedItems(); - - if ( CurSelListItemList.count() > 0 ) - { - CHostAddress CurServerAddress; - - // try to parse host address string which is stored as user data - // in the server list item GUI control element - if ( NetworkUtil().ParseNetworkAddress ( - CurSelListItemList[0]-> - data ( 0, Qt::UserRole ).toString(), - CurServerAddress ) ) - { - // if address is valid, send connected clients list request - emit CreateCLServerListReqConnClientsListMes ( CurServerAddress ); - } - } -} - void CConnectDlg::OnTimerPing() { // send ping messages to the servers in the list @@ -488,6 +435,14 @@ void CConnectDlg::OnTimerPing() #else emit CreateCLServerListPingMes ( CurServerAddress ); #endif + + // check if the number of child list items matches the number of + // connected clients, if not then request the client names + if ( lvwServers->topLevelItem ( iIdx )->text ( 2 ).toInt() != + lvwServers->topLevelItem ( iIdx )->childCount() ) + { + emit CreateCLServerListReqConnClientsListMes ( CurServerAddress ); + } } } } @@ -557,14 +512,6 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& // item since the topLevelItem ( iIdx ) is then no longer valid. lvwServers->sortByColumn ( 4, Qt::AscendingOrder ); } - - // check if the current number of clients is the same as the number - // of child items, if not, we remove all child items - if ( iNumClients != pCurListViewItem->childCount() ) - { - // delete all childs - DeleteAllListViewItemChilds ( pCurListViewItem ); - } } // if no server item has childs, do not show decoration diff --git a/src/connectdlg.h b/src/connectdlg.h index 46213910..4b33c16f 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -29,7 +29,6 @@ #include #include #include -#include #include "global.h" #include "client.h" #include "multicolorled.h" @@ -84,7 +83,6 @@ protected: QTreeWidgetItem* GetParentListViewItem ( QTreeWidgetItem* pItem ); void DeleteAllListViewItemChilds ( QTreeWidgetItem* pItem ); - QMenu* pServerListContextMenu; QTimer TimerPing; QTimer TimerReRequestServList; QString strCentralServerAddress; @@ -99,8 +97,6 @@ protected: public slots: void OnServerListItemSelectionChanged(); void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int ); - void OnCustomContextMenuRequested ( const QPoint& Position ); - void OnServerListContextMenuNames(); void OnServerAddrEditTextChanged ( const QString& ); void OnConnectClicked(); void OnTimerPing(); diff --git a/src/util.h b/src/util.h index 062ed8f8..2190451f 100755 --- a/src/util.h +++ b/src/util.h @@ -810,6 +810,25 @@ public: iChanID ( NiID ), iIpAddr ( NiIP ) {} + QString GenNameForDisplay() const + { + // if text is empty, show IP address instead + if ( strName.isEmpty() ) + { + // convert IP address to text and show it (use dummy port number + // since it is not used here) + const CHostAddress TempAddr = + CHostAddress ( QHostAddress ( iIpAddr ), 0 ); + + return TempAddr.toString ( CHostAddress::SM_IP_NO_LAST_BYTE ); + } + else + { + // show name of channel + return strName; + } + } + // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### CChannelInfo ( const int NiID,