qt: add missing initializers (CID 1325722)
[metze/wireshark/wip.git] / ui / qt / packet_format_group_box.cpp
1 /* packet_format_group_box.cpp
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include "packet_format_group_box.h"
23 #include <ui_packet_format_group_box.h>
24
25 #include <QStyle>
26
27 PacketFormatGroupBox::PacketFormatGroupBox(QWidget *parent) :
28     QGroupBox(parent),
29     pf_ui_(new Ui::PacketFormatGroupBox)
30 {
31     pf_ui_->setupUi(this);
32     setFlat(true);
33
34     QStyleOption style_opt;
35     int cb_label_offset =  pf_ui_->detailsCheckBox->style()->subElementRect(QStyle::SE_CheckBoxContents, &style_opt).left();
36     setStyleSheet(QString(
37                       "QRadioButton {"
38                       "  padding-left: %1px;"
39                       "}"
40                       ).arg(cb_label_offset));
41 }
42
43 PacketFormatGroupBox::~PacketFormatGroupBox()
44 {
45     delete pf_ui_;
46 }
47
48 bool PacketFormatGroupBox::summaryEnabled()
49 {
50     return pf_ui_->summaryCheckBox->isChecked();
51 }
52
53 bool PacketFormatGroupBox::detailsEnabled()
54 {
55     return pf_ui_->detailsCheckBox->isChecked();
56 }
57
58 bool PacketFormatGroupBox::bytesEnabled()
59 {
60     return pf_ui_->bytesCheckBox->isChecked();
61 }
62
63 bool PacketFormatGroupBox::allCollapsedEnabled()
64 {
65     return pf_ui_->allCollapsedButton->isChecked();
66 }
67
68 bool PacketFormatGroupBox::asDisplayedEnabled()
69 {
70     return pf_ui_->asDisplayedButton->isChecked();
71 }
72
73 bool PacketFormatGroupBox::allExpandedEnabled()
74 {
75     return pf_ui_->allExpandedButton->isChecked();
76 }
77
78 void PacketFormatGroupBox::on_summaryCheckBox_toggled(bool)
79 {
80     emit formatChanged();
81 }
82
83 void PacketFormatGroupBox::on_detailsCheckBox_toggled(bool checked)
84 {
85     pf_ui_->allCollapsedButton->setEnabled(checked);
86     pf_ui_->asDisplayedButton->setEnabled(checked);
87     pf_ui_->allExpandedButton->setEnabled(checked);
88     emit formatChanged();
89 }
90
91 void PacketFormatGroupBox::on_bytesCheckBox_toggled(bool)
92 {
93     emit formatChanged();
94 }
95
96 void PacketFormatGroupBox::on_allCollapsedButton_toggled(bool checked)
97 {
98     if (checked) emit formatChanged();
99 }
100
101 void PacketFormatGroupBox::on_asDisplayedButton_toggled(bool checked)
102 {
103     if (checked) emit formatChanged();
104 }
105
106 void PacketFormatGroupBox::on_allExpandedButton_toggled(bool checked)
107 {
108     if (checked) emit formatChanged();
109 }