Skip to content

Commit

Permalink
Qt: Add GeoIP latitude and longitude to Endpoints table
Browse files Browse the repository at this point in the history
Fix #17049
  • Loading branch information
johnthacker authored and geraldcombs committed Nov 10, 2022
1 parent 1e6f26a commit 91279eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ui/qt/models/atap_data_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions ui/qt/models/atap_data_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ class EndpointDataModel : public ATapDataModel
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
Expand Down

0 comments on commit 91279eb

Please sign in to comment.