From 1d4342bb7c19f7072a9f8ae9a9f80dc45fcfbaf8 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 11 Apr 2020 10:31:26 +0200 Subject: [PATCH] move country flag function in new class CLocale --- src/audiomixerboard.cpp | 3 +-- src/clientdlg.cpp | 2 +- src/connectdlg.cpp | 2 +- src/util.cpp | 29 +++++++++++++++++------------ src/util.h | 7 +++---- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 20b98e58..53ef2279 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -403,8 +403,7 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) if ( cChanInfo.eCountry != QLocale::AnyCountry ) { // try to load the country flag icon - QPixmap CountryFlagPixmap ( - CCountyFlagIcons::GetResourceReference ( cChanInfo.eCountry ) ); + QPixmap CountryFlagPixmap ( CLocale::GetCountryFlagIconsResourceReference ( cChanInfo.eCountry ) ); // first check if resource reference was valid if ( CountryFlagPixmap.isNull() ) diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 802484bd..3196e99e 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -330,7 +330,7 @@ CClientDlg::CClientDlg ( CClient* pNCliP, static_cast ( iCurCntry ); // get resource file name - CurFlagIcon.addFile ( CCountyFlagIcons::GetResourceReference ( eCountry ) ); + CurFlagIcon.addFile ( CLocale::GetCountryFlagIconsResourceReference ( eCountry ) ); // get the country name sCurCountryName = QLocale::countryToString ( eCountry ); diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index cadcd160..e7a480cd 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -371,7 +371,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, { // try to load the country flag icon QPixmap CountryFlagPixmap ( - CCountyFlagIcons::GetResourceReference ( vecChanInfo[i].eCountry ) ); + CLocale::GetCountryFlagIconsResourceReference ( vecChanInfo[i].eCountry ) ); // first check if resource reference was valid if ( !CountryFlagPixmap.isNull() ) diff --git a/src/util.cpp b/src/util.cpp index 7066401e..d43dbe55 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -612,7 +612,7 @@ CMusProfDlg::CMusProfDlg ( CClient* pNCliP, // try to load icon from resource file name QIcon CurFlagIcon; - CurFlagIcon.addFile ( CCountyFlagIcons::GetResourceReference ( eCountry ) ); + CurFlagIcon.addFile ( CLocale::GetCountryFlagIconsResourceReference ( eCountry ) ); // only add the entry if a flag is available if ( !CurFlagIcon.isNull() ) @@ -889,21 +889,26 @@ bool NetworkUtil::ParseNetworkAddress ( QString strAddress, return true; } - CHostAddress NetworkUtil::GetLocalAddress() { QTcpSocket socket; - socket.connectToHost( WELL_KNOWN_HOST, WELL_KNOWN_PORT ); - if (socket.waitForConnected( IP_LOOKUP_TIMEOUT )) { - return CHostAddress( socket.localAddress(), 0 ); - } else { - qWarning() - << "could not determine local IPv4 address:" - << socket.errorString() - << "- using localhost"; - return CHostAddress( QHostAddress::LocalHost, 0 ); + socket.connectToHost ( WELL_KNOWN_HOST, WELL_KNOWN_PORT ); + + if ( socket.waitForConnected ( IP_LOOKUP_TIMEOUT ) ) + { + return CHostAddress ( socket.localAddress(), 0 ); + } + else + { + qWarning() << "could not determine local IPv4 address:" + << socket.errorString() + << "- using localhost"; + + return CHostAddress( QHostAddress::LocalHost, 0 ); } } + + // Instrument picture data base ------------------------------------------------ CVector& CInstPictures::GetTable() { @@ -988,7 +993,7 @@ QString CInstPictures::GetName ( const int iInstrument ) // Country flag icon data base ------------------------------------------------- -QString CCountyFlagIcons::GetResourceReference ( const QLocale::Country eCountry ) +QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry ) { QString strReturn = ""; diff --git a/src/util.h b/src/util.h index f4805666..12800ef0 100755 --- a/src/util.h +++ b/src/util.h @@ -734,12 +734,11 @@ protected: }; -// Country flag icon data base ------------------------------------------------- -// this is a pure static class -class CCountyFlagIcons +// Locale management class ----------------------------------------------------- +class CLocale { public: - static QString GetResourceReference ( const QLocale::Country eCountry ); + static QString GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry ); };