move country flag function in new class CLocale

This commit is contained in:
Volker Fischer 2020-04-11 10:31:26 +02:00
parent 339457298c
commit 1d4342bb7c
5 changed files with 23 additions and 20 deletions

View File

@ -403,8 +403,7 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo )
if ( cChanInfo.eCountry != QLocale::AnyCountry ) if ( cChanInfo.eCountry != QLocale::AnyCountry )
{ {
// try to load the country flag icon // try to load the country flag icon
QPixmap CountryFlagPixmap ( QPixmap CountryFlagPixmap ( CLocale::GetCountryFlagIconsResourceReference ( cChanInfo.eCountry ) );
CCountyFlagIcons::GetResourceReference ( cChanInfo.eCountry ) );
// first check if resource reference was valid // first check if resource reference was valid
if ( CountryFlagPixmap.isNull() ) if ( CountryFlagPixmap.isNull() )

View File

@ -330,7 +330,7 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
static_cast<QLocale::Country> ( iCurCntry ); static_cast<QLocale::Country> ( iCurCntry );
// get resource file name // get resource file name
CurFlagIcon.addFile ( CCountyFlagIcons::GetResourceReference ( eCountry ) ); CurFlagIcon.addFile ( CLocale::GetCountryFlagIconsResourceReference ( eCountry ) );
// get the country name // get the country name
sCurCountryName = QLocale::countryToString ( eCountry ); sCurCountryName = QLocale::countryToString ( eCountry );

View File

@ -371,7 +371,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr,
{ {
// try to load the country flag icon // try to load the country flag icon
QPixmap CountryFlagPixmap ( QPixmap CountryFlagPixmap (
CCountyFlagIcons::GetResourceReference ( vecChanInfo[i].eCountry ) ); CLocale::GetCountryFlagIconsResourceReference ( vecChanInfo[i].eCountry ) );
// first check if resource reference was valid // first check if resource reference was valid
if ( !CountryFlagPixmap.isNull() ) if ( !CountryFlagPixmap.isNull() )

View File

@ -612,7 +612,7 @@ CMusProfDlg::CMusProfDlg ( CClient* pNCliP,
// try to load icon from resource file name // try to load icon from resource file name
QIcon CurFlagIcon; QIcon CurFlagIcon;
CurFlagIcon.addFile ( CCountyFlagIcons::GetResourceReference ( eCountry ) ); CurFlagIcon.addFile ( CLocale::GetCountryFlagIconsResourceReference ( eCountry ) );
// only add the entry if a flag is available // only add the entry if a flag is available
if ( !CurFlagIcon.isNull() ) if ( !CurFlagIcon.isNull() )
@ -889,21 +889,26 @@ bool NetworkUtil::ParseNetworkAddress ( QString strAddress,
return true; return true;
} }
CHostAddress NetworkUtil::GetLocalAddress() CHostAddress NetworkUtil::GetLocalAddress()
{ {
QTcpSocket socket; QTcpSocket socket;
socket.connectToHost ( WELL_KNOWN_HOST, WELL_KNOWN_PORT ); socket.connectToHost ( WELL_KNOWN_HOST, WELL_KNOWN_PORT );
if (socket.waitForConnected( IP_LOOKUP_TIMEOUT )) {
if ( socket.waitForConnected ( IP_LOOKUP_TIMEOUT ) )
{
return CHostAddress ( socket.localAddress(), 0 ); return CHostAddress ( socket.localAddress(), 0 );
} else { }
qWarning() else
<< "could not determine local IPv4 address:" {
qWarning() << "could not determine local IPv4 address:"
<< socket.errorString() << socket.errorString()
<< "- using localhost"; << "- using localhost";
return CHostAddress( QHostAddress::LocalHost, 0 ); return CHostAddress( QHostAddress::LocalHost, 0 );
} }
} }
// Instrument picture data base ------------------------------------------------ // Instrument picture data base ------------------------------------------------
CVector<CInstPictures::CInstPictProps>& CInstPictures::GetTable() CVector<CInstPictures::CInstPictProps>& CInstPictures::GetTable()
{ {
@ -988,7 +993,7 @@ QString CInstPictures::GetName ( const int iInstrument )
// Country flag icon data base ------------------------------------------------- // Country flag icon data base -------------------------------------------------
QString CCountyFlagIcons::GetResourceReference ( const QLocale::Country eCountry ) QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry )
{ {
QString strReturn = ""; QString strReturn = "";

View File

@ -734,12 +734,11 @@ protected:
}; };
// Country flag icon data base ------------------------------------------------- // Locale management class -----------------------------------------------------
// this is a pure static class class CLocale
class CCountyFlagIcons
{ {
public: public:
static QString GetResourceReference ( const QLocale::Country eCountry ); static QString GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry );
}; };