finished: show the names of the connected clients in the server list

This commit is contained in:
Volker Fischer 2015-12-09 17:11:16 +00:00
parent 6163b5e282
commit 2ad6eb1600
6 changed files with 35 additions and 95 deletions

View File

@ -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

View File

@ -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<double> ( 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 *

View File

@ -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;

View File

@ -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<QTreeWidgetItem*> 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

View File

@ -29,7 +29,6 @@
#include <QTimer>
#include <QMutex>
#include <QLocale>
#include <QMenu>
#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();

View File

@ -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,