support for connect on double click a list item

This commit is contained in:
Volker Fischer 2011-04-23 20:41:52 +00:00
parent 7392762f6c
commit 356ecff831
2 changed files with 24 additions and 4 deletions

View file

@ -42,8 +42,8 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
"A list of the most recent used server URLs is available for "
"selection." );
TextLabelServerAddr->setWhatsThis ( strServAddrH );
LineEditServerAddr->setWhatsThis ( strServAddrH );
TextLabelServerAddr->setWhatsThis ( strServAddrH );
LineEditServerAddr->setWhatsThis ( strServAddrH );
LineEditServerAddr->setAccessibleName ( tr ( "Server address edit box" ) );
LineEditServerAddr->setAccessibleDescription ( tr ( "Holds the current server "
@ -51,7 +51,7 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
// init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
LineEditServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
LineEditServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
LineEditServerAddr->setInsertPolicy ( QComboBox::NoInsert );
// set up list view for connected clients
@ -64,6 +64,11 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
// Connections -------------------------------------------------------------
// list view
QObject::connect ( ListViewServers,
SIGNAL ( itemDoubleClicked ( QTreeWidgetItem*, int ) ),
this, SLOT ( OnServerListItemDoubleClicked ( QTreeWidgetItem*, int ) ) );
// buttons
QObject::connect ( CancelButton, SIGNAL ( clicked() ),
this, SLOT ( OnCancelButtonClicked() ) );
@ -101,6 +106,9 @@ void CConnectDlg::showEvent ( QShowEvent* )
// clear current address
strSelectedAddress = "";
// clear server list view
ListViewServers->clear();
// TEST
QString strNAddr = "llcon.dyndns.org:22122";
@ -157,8 +165,9 @@ void CConnectDlg::OnTimerReRequestServList()
void CConnectDlg::SetServerList ( const CHostAddress& InetAddr,
const CVector<CServerInfo>& vecServerInfo )
{
// set flag
// set flag and disable timer for resend server list request
bServerListReceived = true;
TimerReRequestServList.stop();
// first clear list
ListViewServers->clear();
@ -232,6 +241,16 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr,
TimerPing.start ( PING_UPDATE_TIME_SERVER_LIST_MS );
}
void CConnectDlg::OnServerListItemDoubleClicked ( QTreeWidgetItem* Item,
int )
{
// if a server list item was double clicked, close dialog and connect
if ( Item != 0 )
{
close();
}
}
void CConnectDlg::OnCancelButtonClicked()
{
// set cancel flag

View file

@ -81,6 +81,7 @@ protected:
bool bCancelPressed;
public slots:
void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int );
void OnCancelButtonClicked();
void OnTimerPing();
void OnTimerReRequestServList();