Introduce toqstr(char_type) and use it.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22857 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-02-08 08:49:22 +00:00
parent e172898430
commit 46e6cacfe0
2 changed files with 11 additions and 2 deletions

View 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);

View 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