From b2b76c2baefc9a483de83cbcb810d9a609e948f0 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 18 Oct 2022 13:59:49 -0700 Subject: [PATCH] Qt: Add geolocation columns back to the Endpoints dialog. Add geolocation columns back to the Endpoints dialog. Fix our geolocation column alignments as well. Fixes #18320. --- ui/qt/models/atap_data_model.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ui/qt/models/atap_data_model.cpp b/ui/qt/models/atap_data_model.cpp index 47bdb6c821..6ca21b89e7 100644 --- a/ui/qt/models/atap_data_model.cpp +++ b/ui/qt/models/atap_data_model.cpp @@ -318,6 +318,13 @@ EndpointDataModel::EndpointDataModel(int protoId, QString filter, QObject *paren int EndpointDataModel::columnCount(const QModelIndex &) const { +#ifdef HAVE_MAXMINDDB + int proto_ipv4 = proto_get_id_by_filter_name("ip"); + int proto_ipv6 = proto_get_id_by_filter_name("ipv6"); + if (protoId() == proto_ipv4 || protoId() == proto_ipv6) { + return ENDP_NUM_GEO_COLUMNS; + } +#endif return ENDP_NUM_COLUMNS; } @@ -358,8 +365,15 @@ QVariant EndpointDataModel::headerData(int section, Qt::Orientation orientation, return tr("AS Organization"); break; } } else if (role == Qt::TextAlignmentRole) { - if (section == ENDP_COLUMN_ADDR) + switch (section) { + case ENDP_COLUMN_ADDR: + case ENDP_COLUMN_GEO_COUNTRY: + case ENDP_COLUMN_GEO_CITY: + case ENDP_COLUMN_GEO_AS_ORG: return Qt::AlignLeft; + default: + break; + } return Qt::AlignRight; } @@ -465,8 +479,15 @@ QVariant EndpointDataModel::data(const QModelIndex &idx, int role) const return QVariant(); } } else if (role == Qt::TextAlignmentRole) { - if (idx.column() == ENDP_COLUMN_ADDR) + switch (idx.column()) { + case ENDP_COLUMN_ADDR: + case ENDP_COLUMN_GEO_COUNTRY: + case ENDP_COLUMN_GEO_CITY: + case ENDP_COLUMN_GEO_AS_ORG: return Qt::AlignLeft; + default: + break; + } return Qt::AlignRight; } else if (role == ATapDataModel::DISPLAY_FILTER) { return QString(get_endpoint_filter(item));