| 40 | namespace dialogs { |
| 41 | |
| 42 | ProtocolList::ProtocolList(QWidget *parent, SigSession *session) : |
| 43 | DSDialog(parent), |
| 44 | _session(session), |
| 45 | _button_box(QDialogButtonBox::Ok, |
| 46 | Qt::Horizontal, this) |
| 47 | { |
| 48 | pv::data::DecoderModel* decoder_model = _session->get_decoder_model(); |
| 49 | |
| 50 | _map_zoom_combobox = new DsComboBox(this); |
| 51 | _map_zoom_combobox->addItem(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_FIT_TO_WINDOW), "Fit to Window")); |
| 52 | _map_zoom_combobox->addItem(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_FIXED), "Fixed")); |
| 53 | int cur_map_zoom = _session->get_map_zoom(); |
| 54 | |
| 55 | if (cur_map_zoom >= _map_zoom_combobox->count()) |
| 56 | _map_zoom_combobox->setCurrentIndex(0); |
| 57 | else |
| 58 | _map_zoom_combobox->setCurrentIndex(cur_map_zoom); |
| 59 | |
| 60 | connect(_map_zoom_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_set_map_zoom(int))); |
| 61 | |
| 62 | _protocol_combobox = new DsComboBox(this); |
| 63 | auto &decode_sigs = _session->get_decode_signals(); |
| 64 | int index = 0; |
| 65 | |
| 66 | for(auto d : decode_sigs) { |
| 67 | _protocol_combobox->addItem(d->get_name()); |
| 68 | if (decoder_model->getDecoderStack() == d->decoder()) |
| 69 | _protocol_combobox->setCurrentIndex(index); |
| 70 | index++; |
| 71 | } |
| 72 | _protocol_combobox->addItem("", QVariant::fromValue(NULL)); |
| 73 | if (decoder_model->getDecoderStack() == NULL) |
| 74 | _protocol_combobox->setCurrentIndex(index); |
| 75 | |
| 76 | _flayout = new QFormLayout(); |
| 77 | _flayout->setVerticalSpacing(5); |
| 78 | _flayout->setFormAlignment(Qt::AlignLeft); |
| 79 | _flayout->setLabelAlignment(Qt::AlignLeft); |
| 80 | _flayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); |
| 81 | _flayout->addRow(new QLabel(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_MAP_ZOOM), "Map Zoom: "), this), _map_zoom_combobox); |
| 82 | _flayout->addRow(new QLabel(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DECODED_PROTOCOLS), "Decoded Protocols: "), this), _protocol_combobox); |
| 83 | |
| 84 | _layout = new QVBoxLayout(); |
| 85 | _layout->addLayout(_flayout); |
| 86 | _layout->addWidget(&_button_box); |
| 87 | |
| 88 | setMinimumWidth(300); |
| 89 | layout()->addLayout(_layout); |
| 90 | setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_PROTOCOL_LIST_VIEWER), "Protocol List Viewer")); |
| 91 | |
| 92 | connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept())); |
| 93 | connect(_protocol_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(set_protocol(int))); |
| 94 | set_protocol(_protocol_combobox->currentIndex()); |
| 95 | connect(_session->device_event_object(), SIGNAL(device_updated()), this, SLOT(reject())); |
| 96 | |
| 97 | } |
| 98 | |
| 99 | void ProtocolList::accept() |
nothing calls this directly
no test coverage detected