prepared for the combo box functionality for server names

This commit is contained in:
Volker Fischer 2011-04-21 07:04:58 +00:00
parent 899d11fa4b
commit 944639e7ee
4 changed files with 96 additions and 20 deletions

View file

@ -34,10 +34,38 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
// Add help text to controls -----------------------------------------------
// server address
QString strServAddrH = tr ( "<b>Server Address:</b> The IP address or URL "
"of the server running the llcon server software must be set here. "
"A list of the most recent used server URLs is available for "
"selection. If an invalid address was chosen, an error message is "
"shown in the status bar." );
TextLabelServerAddr->setWhatsThis ( strServAddrH );
LineEditServerAddr->setWhatsThis ( strServAddrH );
LineEditServerAddr->setAccessibleName ( tr ( "Server address edit box" ) );
LineEditServerAddr->setAccessibleDescription ( tr ( "Holds the current server "
"URL. It also stores old URLs in the combo box list." ) );
// init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
LineEditServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
LineEditServerAddr->setInsertPolicy ( QComboBox::InsertAtTop );
// load data from ini file
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ )
{
// if ( !pClient->vstrIPAddress[iLEIdx].isEmpty() )
{
// TODO
// LineEditServerAddr->addItem ( pClient->vstrIPAddress[iLEIdx] );
}
}
// set up list view for connected clients
ListViewServers->setColumnWidth ( 0, 170 );
ListViewServers->setColumnWidth ( 1, 130 );
@ -48,6 +76,13 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
// Connections -------------------------------------------------------------
// line edits
QObject::connect ( LineEditServerAddr, SIGNAL ( editTextChanged ( const QString ) ),
this, SLOT ( OnLineEditServerAddrTextChanged ( const QString ) ) );
QObject::connect ( LineEditServerAddr, SIGNAL ( activated ( int ) ),
this, SLOT ( OnLineEditServerAddrActivated ( int ) ) );
// timers
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
this, SLOT ( OnTimerPing() ) );
@ -177,6 +212,26 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr,
TimerPing.start ( PING_UPDATE_TIME_SERVER_LIST_MS );
}
void CConnectDlg::OnLineEditServerAddrTextChanged ( const QString )
{
// if the maximum number of items in the combo box is reached,
// delete the last item so that the new item can be added (first
// in - first out)
if ( LineEditServerAddr->count() == MAX_NUM_SERVER_ADDR_ITEMS )
{
LineEditServerAddr->removeItem ( MAX_NUM_SERVER_ADDR_ITEMS - 1 );
}
}
void CConnectDlg::OnLineEditServerAddrActivated ( int index )
{
// move activated list item to the top
const QString strCurIPAddress = LineEditServerAddr->itemText ( index );
LineEditServerAddr->removeItem ( index );
LineEditServerAddr->insertItem ( 0, strCurIPAddress );
LineEditServerAddr->setCurrentIndex ( 0 );
}
void CConnectDlg::OnTimerPing()
{
// send ping messages to the servers in the list

View file

@ -73,6 +73,8 @@ protected:
bool bServerListReceived;
public slots:
void OnLineEditServerAddrTextChanged ( const QString );
void OnLineEditServerAddrActivated ( int index );
void OnTimerPing();
void OnTimerReRequestServList();

View file

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>584</width>
<height>355</height>
<height>256</height>
</rect>
</property>
<property name="windowTitle" >
@ -54,11 +54,16 @@
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="TextLabelServerAddr" >
<property name="text" >
<string>Server Address</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
@ -68,6 +73,8 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
@ -77,16 +84,26 @@
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
<width>351</width>
<height>25</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton" >
<widget class="QPushButton" name="CancelButton" >
<property name="text" >
<string>PushButton</string>
<string>C&amp;ancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ConnectButton" >
<property name="text" >
<string>&amp;Connect</string>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>

View file

@ -74,9 +74,11 @@ class CLlconClientDlg : public QDialog, private Ui_CLlconClientDlgBase
Q_OBJECT
public:
CLlconClientDlg ( CClient* pNCliP, const bool bNewConnectOnStartup,
CLlconClientDlg ( CClient* pNCliP,
const bool bNewConnectOnStartup,
const bool bNewDisalbeLEDs,
QWidget* parent = 0, Qt::WindowFlags f = 0 );
QWidget* parent = 0,
Qt::WindowFlags f = 0 );
protected:
void SetGUIDesign ( const EGUIDesign eNewDesign );