From d003ad909246f4fd0cf41e15c1368ed4e37d0fbe Mon Sep 17 00:00:00 2001 From: Roland Knall Date: Sat, 5 Feb 2022 12:46:31 +0100 Subject: [PATCH] Qt: Display fieldname as tooltip in expert info dialog --- ui/qt/models/expert_info_model.cpp | 84 ++++++++++++++++-------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/ui/qt/models/expert_info_model.cpp b/ui/qt/models/expert_info_model.cpp index 2964406794..b8abcb8483 100644 --- a/ui/qt/models/expert_info_model.cpp +++ b/ui/qt/models/expert_info_model.cpp @@ -239,56 +239,64 @@ Qt::ItemFlags ExpertInfoModel::flags(const QModelIndex &index) const QVariant ExpertInfoModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || role != Qt::DisplayRole) + if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::ToolTipRole)) return QVariant(); ExpertPacketItem* item = static_cast(index.internalPointer()); if (item == NULL) return QVariant(); - switch ((enum ExpertColumn)index.column()) { - case colSeverity: - return QString(val_to_str_const(item->severity(), expert_severity_vals, "Unknown")); - case colSummary: - if (index.parent().isValid()) - { - if (item->severity() == PI_COMMENT) - return item->summary().simplified(); - if (group_by_summary_) - return item->colInfo().simplified(); - - return item->summary().simplified(); - } - else - { - if (group_by_summary_) + if (role == Qt::ToolTipRole) + { + QString filterName = proto_registrar_get_abbrev(item->hfId()); + return filterName; + } + else if (role == Qt::DisplayRole) + { + switch ((enum ExpertColumn)index.column()) { + case colSeverity: + return QString(val_to_str_const(item->severity(), expert_severity_vals, "Unknown")); + case colSummary: + if (index.parent().isValid()) { if (item->severity() == PI_COMMENT) - return "Packet comments listed below."; - if (item->hfId() != -1) { - return proto_registrar_get_name(item->hfId()); - } else { return item->summary().simplified(); + if (group_by_summary_) + return item->colInfo().simplified(); + + return item->summary().simplified(); + } + else + { + if (group_by_summary_) + { + if (item->severity() == PI_COMMENT) + return "Packet comments listed below."; + if (item->hfId() != -1) { + return proto_registrar_get_name(item->hfId()); + } else { + return item->summary().simplified(); + } } } + return QVariant(); + case colGroup: + return QString(val_to_str_const(item->group(), expert_group_vals, "Unknown")); + case colProtocol: + return item->protocol(); + case colCount: + if (!index.parent().isValid()) + { + return item->childCount(); + } + break; + case colPacket: + return item->packetNum(); + case colHf: + return item->hfId(); + default: + break; } - return QVariant(); - case colGroup: - return QString(val_to_str_const(item->group(), expert_group_vals, "Unknown")); - case colProtocol: - return item->protocol(); - case colCount: - if (!index.parent().isValid()) - { - return item->childCount(); - } - break; - case colPacket: - return item->packetNum(); - case colHf: - return item->hfId(); - default: - break; } return QVariant();