From: Joel Holdsworth Date: Sat, 28 Dec 2013 14:36:19 +0000 (+0100) Subject: Handle C-strings as UTF-8 X-Git-Tag: pulseview-0.2.0~180 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=27e8df221014d1a8c7769866773e8dbb0486eea8;p=pulseview.git Handle C-strings as UTF-8 --- diff --git a/pv/data/decode/annotation.cpp b/pv/data/decode/annotation.cpp index 6a30921e..e17dcb51 100644 --- a/pv/data/decode/annotation.cpp +++ b/pv/data/decode/annotation.cpp @@ -43,7 +43,7 @@ Annotation::Annotation(const srd_proto_data *const pdata) : const char *const *annotations = (char**)pda->ann_text; while(*annotations) { - _annotations.push_back(QString(*annotations)); + _annotations.push_back(QString::fromUtf8(*annotations)); annotations++; } } diff --git a/pv/dialogs/about.cpp b/pv/dialogs/about.cpp index 806dc4c5..8484e47b 100644 --- a/pv/dialogs/about.cpp +++ b/pv/dialogs/about.cpp @@ -65,8 +65,8 @@ About::About(QWidget *parent) : drivers = sr_driver_list(); for (int i = 0; drivers[i]; ++i) { s.append(QString("%1%2") - .arg(QString(drivers[i]->name)) - .arg(QString(drivers[i]->longname))); + .arg(QString::fromUtf8(drivers[i]->name)) + .arg(QString::fromUtf8(drivers[i]->longname))); } s.append("" + @@ -75,8 +75,8 @@ About::About(QWidget *parent) : inputs = sr_input_list(); for (int i = 0; inputs[i]; ++i) { s.append(QString("%1%2") - .arg(QString(inputs[i]->id)) - .arg(QString(inputs[i]->description))); + .arg(QString::fromUtf8(inputs[i]->id)) + .arg(QString::fromUtf8(inputs[i]->description))); } s.append("" + @@ -85,8 +85,8 @@ About::About(QWidget *parent) : outputs = sr_output_list(); for (int i = 0; outputs[i]; ++i) { s.append(QString("%1%2") - .arg(QString(outputs[i]->id)) - .arg(QString(outputs[i]->description))); + .arg(QString::fromUtf8(outputs[i]->id)) + .arg(QString::fromUtf8(outputs[i]->description))); } s.append("" + @@ -95,8 +95,8 @@ About::About(QWidget *parent) : for (const GSList *l = srd_decoder_list(); l; l = l->next) { dec = (struct srd_decoder *)l->data; s.append(QString("%1%2") - .arg(QString(dec->id)) - .arg(QString(dec->longname))); + .arg(QString::fromUtf8(dec->id)) + .arg(QString::fromUtf8(dec->longname))); } s.append(""); diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index f8fbe67f..b7efe4f3 100644 --- a/pv/dialogs/connect.cpp +++ b/pv/dialogs/connect.cpp @@ -163,7 +163,7 @@ void Connect::scan_pressed() BOOST_FOREACH(sr_dev_inst *const sdi, devices) { const string title = DeviceManager::format_device_title(sdi); - QString text(title.c_str()); + QString text = QString::fromUtf8(title.c_str()); if (sdi->probes) { text += QString(" with %1 probes").arg( g_slist_length(sdi->probes)); diff --git a/pv/prop/binding/deviceoptions.cpp b/pv/prop/binding/deviceoptions.cpp index e8ae002b..ff7be104 100644 --- a/pv/prop/binding/deviceoptions.cpp +++ b/pv/prop/binding/deviceoptions.cpp @@ -66,7 +66,7 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) : if (sr_config_list(_sdi->driver, _sdi, NULL, key, &gvar_list) != SR_OK) gvar_list = NULL; - const QString name(info->name); + const QString name = QString::fromUtf8(info->name); switch(key) { @@ -169,11 +169,11 @@ QString DeviceOptions::print_gvariant(GVariant *const gvar) QString s; if (g_variant_is_of_type(gvar, G_VARIANT_TYPE("s"))) - s = QString(g_variant_get_string(gvar, NULL)); + s = QString::fromUtf8(g_variant_get_string(gvar, NULL)); else { gchar *const text = g_variant_print(gvar, FALSE); - s = QString(text); + s = QString::fromUtf8(text); g_free(text); } @@ -184,14 +184,14 @@ QString DeviceOptions::print_timebase(GVariant *const gvar) { uint64_t p, q; g_variant_get(gvar, "(tt)", &p, &q); - return QString(sr_period_string(p * q)); + return QString::fromUtf8(sr_period_string(p * q)); } QString DeviceOptions::print_vdiv(GVariant *const gvar) { uint64_t p, q; g_variant_get(gvar, "(tt)", &p, &q); - return QString(sr_voltage_string(p, q)); + return QString::fromUtf8(sr_voltage_string(p, q)); } QString DeviceOptions::print_voltage_threshold(GVariant *const gvar) @@ -200,7 +200,7 @@ QString DeviceOptions::print_voltage_threshold(GVariant *const gvar) char buf[64]; g_variant_get(gvar, "(dd)", &lo, &hi); snprintf(buf, sizeof(buf), "L<%.1fV H>%.1fV", lo, hi); - return QString(buf); + return QString::fromUtf8(buf); } } // binding diff --git a/pv/prop/string.cpp b/pv/prop/string.cpp index c2b2c67c..4921129e 100644 --- a/pv/prop/string.cpp +++ b/pv/prop/string.cpp @@ -48,7 +48,7 @@ QWidget* String::get_widget(QWidget *parent, bool auto_commit) GVariant *const value = _getter ? _getter() : NULL; if (value) { - _line_edit->setText(QString( + _line_edit->setText(QString::fromUtf8( g_variant_get_string(value, NULL))); g_variant_unref(value); } diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 3213758e..2e7be37f 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -223,7 +223,8 @@ bool SigSession::add_decoder(srd_decoder *const dec) { shared_ptr l = dynamic_pointer_cast(s); - if (l && QString(probe->name).toLower().contains( + if (l && QString::fromUtf8(probe->name). + toLower().contains( l->get_name().toLower())) probes[probe] = l; } diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index db7e8e0b..3bd2cb39 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -92,7 +92,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : { const uint64_t &l = RecordLengths[i]; char *const text = sr_si_string_u64(l, " samples"); - _record_length_selector.addItem(QString(text), + _record_length_selector.addItem(QString::fromUtf8(text), qVariantFromValue(l)); g_free(text); @@ -219,7 +219,7 @@ void SamplingBar::update_sample_rate_selector() for (unsigned int i = 0; i < num_elements; i++) { char *const s = sr_samplerate_string(elements[i]); - _sample_rate_list.addItem(QString(s), + _sample_rate_list.addItem(QString::fromUtf8(s), qVariantFromValue(elements[i])); g_free(s); } diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index e275a112..cf5cd2ee 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -78,7 +78,8 @@ const QColor DecodeTrace::Colours[7] = { DecodeTrace::DecodeTrace(pv::SigSession &session, boost::shared_ptr decoder_stack, int index) : - Trace(session, QString(decoder_stack->stack().front()->decoder()->name)), + Trace(session, QString::fromUtf8( + decoder_stack->stack().front()->decoder()->name)), _decoder_stack(decoder_stack), _delete_mapper(this) { @@ -403,7 +404,8 @@ void DecodeTrace::create_decoder_form(int index, assert(decoder); pv::widgets::DecoderGroupBox *const group = - new pv::widgets::DecoderGroupBox(decoder->name); + new pv::widgets::DecoderGroupBox( + QString::fromUtf8(decoder->name)); _delete_mapper.setMapping(group, index); connect(group, SIGNAL(delete_decoder()), &_delete_mapper, SLOT(map())); diff --git a/pv/widgets/decodermenu.cpp b/pv/widgets/decodermenu.cpp index 68fc4781..3273123e 100644 --- a/pv/widgets/decodermenu.cpp +++ b/pv/widgets/decodermenu.cpp @@ -33,7 +33,7 @@ DecoderMenu::DecoderMenu(QWidget *parent) : (GSList*)srd_decoder_list()), decoder_name_cmp); for(; l; l = l->next) { - QAction *const action = addAction(QString( + QAction *const action = addAction(QString::fromUtf8( ((srd_decoder*)l->data)->name)); action->setData(qVariantFromValue(l->data)); _mapper.setMapping(action, action);