1 /* packet_format_group_box.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 "packet_format_group_box.h"
11 #include <ui_packet_format_group_box.h>
13 #include <epan/print.h>
16 #include <QStyleOption>
18 PacketFormatGroupBox::PacketFormatGroupBox(QWidget
*parent
) :
20 pf_ui_(new Ui::PacketFormatGroupBox
)
22 pf_ui_
->setupUi(this);
25 QStyleOption style_opt
;
26 int cb_label_offset
= pf_ui_
->detailsCheckBox
->style()->subElementRect(QStyle::SE_CheckBoxContents
, &style_opt
).left();
28 // Indent the checkbox under the "Packet summary" checkbox
29 pf_ui_
->includeColumnHeadingsCheckBox
->setStyleSheet(QStringLiteral(
31 " padding-left: %1px;"
33 ).arg(cb_label_offset
));
35 // Indent the radio buttons under the "Packet details" checkbox
36 pf_ui_
->allCollapsedButton
->setStyleSheet(QStringLiteral(
38 " padding-left: %1px;"
40 ).arg(cb_label_offset
));
41 pf_ui_
->asDisplayedButton
->setStyleSheet(QStringLiteral(
43 " padding-left: %1px;"
45 ).arg(cb_label_offset
));
46 pf_ui_
->allExpandedButton
->setStyleSheet(QStringLiteral(
48 " padding-left: %1px;"
50 ).arg(cb_label_offset
));
52 // Indent the checkbox under the "Bytes" checkbox
53 pf_ui_
->includeDataSourcesCheckBox
->setStyleSheet(QStringLiteral(
55 " padding-left: %1px;"
57 ).arg(cb_label_offset
));
59 pf_ui_
->timestampCheckBox
->setStyleSheet(QStringLiteral(
61 " padding-left: %1px;"
63 ).arg(cb_label_offset
));
66 PacketFormatGroupBox::~PacketFormatGroupBox()
71 bool PacketFormatGroupBox::summaryEnabled()
73 return pf_ui_
->summaryCheckBox
->isChecked();
76 bool PacketFormatGroupBox::detailsEnabled()
78 return pf_ui_
->detailsCheckBox
->isChecked();
81 bool PacketFormatGroupBox::bytesEnabled()
83 return pf_ui_
->bytesCheckBox
->isChecked();
86 bool PacketFormatGroupBox::includeColumnHeadingsEnabled()
88 return pf_ui_
->includeColumnHeadingsCheckBox
->isChecked();
91 bool PacketFormatGroupBox::allCollapsedEnabled()
93 return pf_ui_
->allCollapsedButton
->isChecked();
96 bool PacketFormatGroupBox::asDisplayedEnabled()
98 return pf_ui_
->asDisplayedButton
->isChecked();
101 bool PacketFormatGroupBox::allExpandedEnabled()
103 return pf_ui_
->allExpandedButton
->isChecked();
106 uint
PacketFormatGroupBox::getHexdumpOptions()
108 return (pf_ui_
->includeDataSourcesCheckBox
->isChecked() ? HEXDUMP_SOURCE_MULTI
: HEXDUMP_SOURCE_PRIMARY
) | (pf_ui_
->timestampCheckBox
->isChecked() ? HEXDUMP_TIMESTAMP
: HEXDUMP_TIMESTAMP_NONE
);
111 void PacketFormatGroupBox::on_summaryCheckBox_toggled(bool checked
)
113 pf_ui_
->includeColumnHeadingsCheckBox
->setEnabled(checked
);
114 emit
formatChanged();
117 void PacketFormatGroupBox::on_detailsCheckBox_toggled(bool checked
)
119 pf_ui_
->allCollapsedButton
->setEnabled(checked
);
120 pf_ui_
->asDisplayedButton
->setEnabled(checked
);
121 pf_ui_
->allExpandedButton
->setEnabled(checked
);
122 emit
formatChanged();
125 void PacketFormatGroupBox::on_bytesCheckBox_toggled(bool checked
)
127 pf_ui_
->includeDataSourcesCheckBox
->setEnabled(checked
);
128 pf_ui_
->timestampCheckBox
->setEnabled(checked
);
129 emit
formatChanged();
132 void PacketFormatGroupBox::on_includeColumnHeadingsCheckBox_toggled(bool)
134 emit
formatChanged();
137 void PacketFormatGroupBox::on_allCollapsedButton_toggled(bool checked
)
139 if (checked
) emit
formatChanged();
142 void PacketFormatGroupBox::on_asDisplayedButton_toggled(bool checked
)
144 if (checked
) emit
formatChanged();
147 void PacketFormatGroupBox::on_allExpandedButton_toggled(bool checked
)
149 if (checked
) emit
formatChanged();
152 void PacketFormatGroupBox::on_includeDataSourcesCheckBox_toggled(bool)
154 emit
formatChanged();
157 void PacketFormatGroupBox::on_timestampCheckBox_toggled(bool)
159 emit
formatChanged();