]> git.lyx.org Git - features.git/commitdiff
Introduce toqstr(char_type) and use it.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 8 Feb 2008 08:49:22 +0000 (08:49 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 8 Feb 2008 08:49:22 +0000 (08:49 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22857 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiSymbols.cpp
src/support/qstring_helpers.h

index ef1d27d03814cf1b65139201ad8157f021864cc7..1a691bf33bdd94a1538e80107f538989a082e72a 100644 (file)
@@ -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);
index 87b77ccd107b5c73d27fadd8c6037695d08aeb3d..9028fad7075ef3d7e3d37fde9904cb12f34e8921 100644 (file)
@@ -64,6 +64,16 @@ inline QString const toqstr(docstring const & ucs4)
        return QString::fromUcs4(reinterpret_cast<uint const *>(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<uint const *>(&ucs4), 1);
+}
 
 /**
  * qstring_to_ucs4 - convert a QString into a UCS4 encoded docstring