FEATURE: Optimized and improved the peer country resolution code

FEATURE: Optimized and improved the locale preferences code
COSMETIC: Use country flags by Mark James (Thanks to Dmytro Pukha)
This commit is contained in:
Christophe Dumez 2010-11-20 15:59:17 +00:00
parent f5cf5c2176
commit c77eb35f5b
314 changed files with 604 additions and 411 deletions

View file

@ -33,7 +33,7 @@
#include "reverseresolution.h"
#include "preferences.h"
#include "propertieswidget.h"
#include "geoip.h"
#include "geoipmanager.h"
#include "peeraddition.h"
#include "speedlimitdlg.h"
#include <QStandardItemModel>
@ -355,11 +355,10 @@ QStandardItem* PeerListWidget::addPeer(QString ip, peer_info peer) {
if(resolver && host.isNull())
resolver->resolve(peer.ip);
if(display_flags) {
QString country_name;
const QIcon ico = GeoIP::CountryISOCodeToIcon(peer.country, country_name);
const QIcon ico = GeoIPManager::CountryISOCodeToIcon(peer.country);
if(!ico.isNull()) {
listModel->setData(listModel->index(row, IP), ico, Qt::DecorationRole);
Q_ASSERT(!country_name.isEmpty());
const QString country_name = GeoIPManager::CountryISOCodeToName(peer.country);
listModel->setData(listModel->index(row, IP), country_name, Qt::ToolTipRole);
} else {
missingFlags.insert(ip);
@ -378,11 +377,10 @@ void PeerListWidget::updatePeer(QString ip, peer_info peer) {
QStandardItem *item = peerItems.value(ip);
int row = item->row();
if(display_flags) {
QString country_name;
const QIcon ico = GeoIP::CountryISOCodeToIcon(peer.country, country_name);
const QIcon ico = GeoIPManager::CountryISOCodeToIcon(peer.country);
if(!ico.isNull()) {
listModel->setData(listModel->index(row, IP), ico, Qt::DecorationRole);
Q_ASSERT(!country_name.isEmpty());
const QString country_name = GeoIPManager::CountryISOCodeToName(peer.country);
listModel->setData(listModel->index(row, IP), country_name, Qt::ToolTipRole);
missingFlags.remove(ip);
}