Qt: Add GeoIP latitude and longitude to Endpoints table

Fix #17049
This commit is contained in:
John Thacker 2022-11-08 21:17:24 -05:00 committed by Gerald Combs
parent 1e6f26adb6
commit 91279eb90e
2 changed files with 16 additions and 0 deletions

View File

@ -359,6 +359,10 @@ QVariant EndpointDataModel::headerData(int section, Qt::Orientation orientation,
return tr("Country"); break;
case ENDP_COLUMN_GEO_CITY:
return tr("City"); break;
case ENDP_COLUMN_GEO_LATITUDE:
return tr("Latitude"); break;
case ENDP_COLUMN_GEO_LONGITUDE:
return tr("Longitude"); break;
case ENDP_COLUMN_GEO_AS_NUM:
return tr("AS Number"); break;
case ENDP_COLUMN_GEO_AS_ORG:
@ -465,6 +469,16 @@ QVariant EndpointDataModel::data(const QModelIndex &idx, int role) const
return QVariant(mmdb_lookup->city);
}
return QVariant();
case ENDP_COLUMN_GEO_LATITUDE:
if (mmdb_lookup && mmdb_lookup->found && mmdb_lookup->latitude >= -90.0 && mmdb_lookup->latitude <= 90.0) {
return role == Qt::DisplayRole ? QString("%L1" UTF8_DEGREE_SIGN).arg(mmdb_lookup->latitude) : QVariant(mmdb_lookup->latitude);
}
return QVariant();
case ENDP_COLUMN_GEO_LONGITUDE:
if (mmdb_lookup && mmdb_lookup->found && mmdb_lookup->longitude >= -180.0 && mmdb_lookup->longitude <= 180.0) {
return role == Qt::DisplayRole ? QString("%L1" UTF8_DEGREE_SIGN).arg(mmdb_lookup->longitude) : QVariant(mmdb_lookup->longitude);
}
return QVariant();
case ENDP_COLUMN_GEO_AS_NUM:
if (mmdb_lookup && mmdb_lookup->found && mmdb_lookup->as_number) {
return QVariant(mmdb_lookup->as_number);

View File

@ -261,6 +261,8 @@ public:
ENDP_NUM_COLUMNS,
ENDP_COLUMN_GEO_COUNTRY = ENDP_NUM_COLUMNS,
ENDP_COLUMN_GEO_CITY,
ENDP_COLUMN_GEO_LATITUDE,
ENDP_COLUMN_GEO_LONGITUDE,
ENDP_COLUMN_GEO_AS_NUM,
ENDP_COLUMN_GEO_AS_ORG,
ENDP_NUM_GEO_COLUMNS