enlarge connection dialog, sort the list by the minimum ping time of a server
This commit is contained in:
parent
e0dc85a5f1
commit
40d22e6220
2 changed files with 26 additions and 4 deletions
|
@ -72,13 +72,17 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f )
|
||||||
cbxServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
|
cbxServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
|
||||||
cbxServerAddr->setInsertPolicy ( QComboBox::NoInsert );
|
cbxServerAddr->setInsertPolicy ( QComboBox::NoInsert );
|
||||||
|
|
||||||
// set up list view for connected clients
|
// set up list view for connected clients (note that the last column size
|
||||||
|
// must not be specified since this column takes all the remaining space)
|
||||||
lvwServers->setColumnWidth ( 0, 170 );
|
lvwServers->setColumnWidth ( 0, 170 );
|
||||||
lvwServers->setColumnWidth ( 1, 65 );
|
lvwServers->setColumnWidth ( 1, 65 );
|
||||||
lvwServers->setColumnWidth ( 2, 55 );
|
lvwServers->setColumnWidth ( 2, 55 );
|
||||||
lvwServers->setColumnWidth ( 3, 130 );
|
|
||||||
lvwServers->clear();
|
lvwServers->clear();
|
||||||
|
|
||||||
|
// add invisible column which is used for sorting the list
|
||||||
|
lvwServers->setColumnCount ( 5 );
|
||||||
|
lvwServers->hideColumn ( 4 );
|
||||||
|
|
||||||
// make sure the connect button has the focus
|
// make sure the connect button has the focus
|
||||||
butConnect->setFocus();
|
butConnect->setFocus();
|
||||||
|
|
||||||
|
@ -282,6 +286,10 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr,
|
||||||
|
|
||||||
pNewListViewItem->setText ( 3, strLocation );
|
pNewListViewItem->setText ( 3, strLocation );
|
||||||
|
|
||||||
|
// init the minimum ping time with a large number (note that this number
|
||||||
|
// must fit in an integer type)
|
||||||
|
pNewListViewItem->setText ( 4, "99999999" );
|
||||||
|
|
||||||
// store host address
|
// store host address
|
||||||
pNewListViewItem->setData ( 0, Qt::UserRole,
|
pNewListViewItem->setData ( 0, Qt::UserRole,
|
||||||
CurHostAddress.toString() );
|
CurHostAddress.toString() );
|
||||||
|
@ -411,6 +419,20 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
|
||||||
lvwServers->topLevelItem ( iIdx )->
|
lvwServers->topLevelItem ( iIdx )->
|
||||||
setText ( 2, QString().setNum ( iNumClients ) );
|
setText ( 2, QString().setNum ( iNumClients ) );
|
||||||
|
|
||||||
|
// update minimum ping time column (invisible, used for sorting) if
|
||||||
|
// the new value is smaller than the old value
|
||||||
|
if ( lvwServers->topLevelItem ( iIdx )->text ( 4 ).toInt() > iPingTime )
|
||||||
|
{
|
||||||
|
// we pad to a total of 8 characters with zeros to make sure the
|
||||||
|
// sorting is done correctly
|
||||||
|
lvwServers->topLevelItem ( iIdx )->
|
||||||
|
setText ( 4, QString ( "%1" ).arg (
|
||||||
|
iPingTime, 8, 10, QLatin1Char( '0' ) ) );
|
||||||
|
|
||||||
|
// update the sorting (lowest number on top)
|
||||||
|
lvwServers->sortByColumn ( 4, Qt::AscendingOrder );
|
||||||
|
}
|
||||||
|
|
||||||
// a ping time was received, set item to visible
|
// a ping time was received, set item to visible
|
||||||
lvwServers->topLevelItem ( iIdx )->setHidden ( false );
|
lvwServers->topLevelItem ( iIdx )->setHidden ( false );
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>464</width>
|
<width>521</width>
|
||||||
<height>255</height>
|
<height>294</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
|
|
Loading…
Reference in a new issue