| 42 | namespace binding { |
| 43 | |
| 44 | DecoderOptions::DecoderOptions(pv::data::DecoderStack* decoder_stack, data::decode::Decoder *decoder) : |
| 45 | Binding(), |
| 46 | _decoder(decoder) |
| 47 | { |
| 48 | assert(_decoder); |
| 49 | (void)decoder_stack; |
| 50 | |
| 51 | const srd_decoder *const dec = _decoder->decoder(); |
| 52 | assert(dec); |
| 53 | |
| 54 | bool bLang = AppConfig::Instance().appOptions.transDecoderDlg; |
| 55 | |
| 56 | if (LangResource::Instance()->is_lang_en()){ |
| 57 | bLang = false; |
| 58 | } |
| 59 | |
| 60 | for (GSList *l = dec->options; l; l = l->next) |
| 61 | { |
| 62 | const srd_decoder_option *const opt = |
| 63 | (srd_decoder_option*)l->data; |
| 64 | |
| 65 | const char *desc_str = NULL; |
| 66 | const char *lang_str = NULL; |
| 67 | |
| 68 | if (opt->idn != NULL && LangResource::Instance()->is_lang_en() == false){ |
| 69 | lang_str = LangResource::Instance()->get_lang_text(STR_PAGE_DECODER, opt->idn, opt->desc); |
| 70 | } |
| 71 | |
| 72 | if (lang_str != NULL && bLang){ |
| 73 | desc_str = lang_str; |
| 74 | } |
| 75 | else{ |
| 76 | desc_str = opt->desc; |
| 77 | } |
| 78 | |
| 79 | const QString name = QString::fromUtf8(desc_str); |
| 80 | |
| 81 | const Property::Getter getter = bind( |
| 82 | &DecoderOptions::getter, this, opt->id); |
| 83 | const Property::Setter setter = bind( |
| 84 | &DecoderOptions::setter, this, opt->id, _1); |
| 85 | |
| 86 | Property *prop = NULL; |
| 87 | |
| 88 | if (opt->values) |
| 89 | prop = bind_enum(name, opt, getter, setter); |
| 90 | else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("d"))) |
| 91 | prop = new Double(name, name, 2, "",none, none, getter, setter); |
| 92 | else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("x"))) |
| 93 | prop = new Int(name, name, "", none, getter, setter); |
| 94 | else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("s"))) |
| 95 | prop = new String(name, name, getter, setter); |
| 96 | else |
| 97 | continue; |
| 98 | |
| 99 | _properties.push_back(prop); |
| 100 | } |
| 101 | } |
nothing calls this directly
no test coverage detected