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
10 #include "conversation_colorize_action.h"
14 #include "epan/conversation_filter.h"
18 #include <ui/qt/utils/qt_ui_utils.h>
20 ConversationAction::ConversationAction(QObject
*parent
, conversation_filter_s
*conv_filter
) :
24 conv_filter_
= conv_filter
;
26 setText(conv_filter_
->display_name
);
30 void ConversationAction::setPacketInfo(struct _packet_info
*pinfo
)
33 if (conv_filter_
&& pinfo
) {
34 enable
= conv_filter_
->is_filter_valid(pinfo
, conv_filter_
->user_data
);
36 filter_ba_
= gchar_free_to_qbytearray(conv_filter_
->build_filter_string(pinfo
, conv_filter_
->user_data
));
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
)
56 if (conv_filter_
&& pinfo
) {
57 valid
= conv_filter_
->is_filter_valid(pinfo
, conv_filter_
->user_data
);