update epan/dissectors/pidl/drsuapi/drsuapi.idl from samba
[wireshark-sm.git] / ui / qt / conversation_colorize_action.cpp
blobcb35847205afecf861edbe4268681cf6f992f3b8
1 /* conversation_colorize_action.cpp
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #include "conversation_colorize_action.h"
12 #include <config.h>
14 #include "epan/conversation_filter.h"
16 #include <QMenu>
18 #include <ui/qt/utils/qt_ui_utils.h>
20 ConversationAction::ConversationAction(QObject *parent, conversation_filter_s *conv_filter) :
21 QAction(parent),
22 color_number_(-1)
24 conv_filter_ = conv_filter;
25 if (conv_filter_) {
26 setText(conv_filter_->display_name);
30 void ConversationAction::setPacketInfo(struct _packet_info *pinfo)
32 bool enable = false;
33 if (conv_filter_ && pinfo) {
34 enable = conv_filter_->is_filter_valid(pinfo, conv_filter_->user_data);
35 if (enable) {
36 filter_ba_ = gchar_free_to_qbytearray(conv_filter_->build_filter_string(pinfo, conv_filter_->user_data));
39 setEnabled(enable);
41 // If we're the "New Coloring Rule" item, enable or disable our parent menu.
42 QMenu *parent_submenu = qobject_cast<QMenu *>(parent());
43 if (color_number_ < 0 || !parent_submenu) return;
44 parent_submenu->setEnabled(enable);
47 void ConversationAction::setFieldFilter(const QByteArray field_filter)
49 filter_ba_ = field_filter;
50 setEnabled(!filter_ba_.isEmpty());
53 bool ConversationAction::isFilterValid(struct _packet_info *pinfo)
55 bool valid = false;
56 if (conv_filter_ && pinfo) {
57 valid = conv_filter_->is_filter_valid(pinfo, conv_filter_->user_data);
59 return valid;