From 46e6cacfe0bcfad2f221bb84b642d21b9468a45f Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 8 Feb 2008 08:49:22 +0000 Subject: [PATCH] Introduce toqstr(char_type) and use it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22857 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiSymbols.cpp | 3 +-- src/support/qstring_helpers.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiSymbols.cpp b/src/frontends/qt4/GuiSymbols.cpp index ef1d27d038..1a691bf33b 100644 --- a/src/frontends/qt4/GuiSymbols.cpp +++ b/src/frontends/qt4/GuiSymbols.cpp @@ -294,8 +294,7 @@ void GuiSymbols::updateSymbolList() // we do not want control or space characters if (cat == QChar::Other_Control || cat == QChar::Separator_Space) continue; - QListWidgetItem * lwi = new QListWidgetItem( - QString::fromUcs4((uint const *) &c, 1)); + QListWidgetItem * lwi = new QListWidgetItem(toqstr(c)); if (show_all || c >= range_start && c <= range_end) { lwi->setTextAlignment(Qt::AlignCenter); symbolsLW->addItem(lwi); diff --git a/src/support/qstring_helpers.h b/src/support/qstring_helpers.h index 87b77ccd10..9028fad707 100644 --- a/src/support/qstring_helpers.h +++ b/src/support/qstring_helpers.h @@ -64,6 +64,16 @@ inline QString const toqstr(docstring const & ucs4) return QString::fromUcs4(reinterpret_cast(ucs4.data()), ucs4.length()); } +/** + * toqstr - convert a UCS4 encoded character into a QString + * + * This is the preferred method of converting anything that possibly + * contains non-ASCII stuff to QString. + */ +inline QString const toqstr(char_type ucs4) +{ + return QString::fromUcs4(reinterpret_cast(&ucs4), 1); +} /** * qstring_to_ucs4 - convert a QString into a UCS4 encoded docstring -- 2.39.2