mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
* qt_helpers:
- ucs4_to_qchar() and qchar_to_ucs4() have been inlined. - ucs4_to_qstring(): pass a QString to avoid a copy. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15266 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
00edcc582f
commit
a21259dd02
@ -137,7 +137,8 @@ int GuiFontMetrics::width(char_type const * s, size_t ls) const
|
||||
if (!lyx_gui::use_gui)
|
||||
return ls;
|
||||
|
||||
QString ucs2 = ucs4_to_qstring(s, ls);
|
||||
QString ucs2;
|
||||
ucs4_to_qstring(s, ls, ucs2);
|
||||
|
||||
if (smallcaps_shape_)
|
||||
return smallcapsWidth(ucs2);
|
||||
|
@ -231,14 +231,8 @@ void QLPainter::text(int x, int y, char_type const * s, size_t ls,
|
||||
encoding = encodings.symbol_encoding();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
QString str;
|
||||
str.setLength(ls);
|
||||
for (unsigned int i = 0; i < ls; ++i)
|
||||
str[i] = QChar(encoding->ucs(s[i]));
|
||||
#else
|
||||
QString str = ucs4_to_qstring(s, ls);
|
||||
#endif
|
||||
ucs4_to_qstring(s, ls, str);
|
||||
|
||||
#if 0
|
||||
// HACK: QT3 refuses to show single compose characters
|
||||
|
@ -120,15 +120,12 @@ QString const toqstr(string const & str)
|
||||
}
|
||||
|
||||
|
||||
QString const ucs4_to_qstring(char_type const * str, size_t ls)
|
||||
void ucs4_to_qstring(char_type const * str, size_t ls, QString & s)
|
||||
{
|
||||
QString s;
|
||||
s.reserve(ls);
|
||||
|
||||
for (size_t i = 0; i < ls; ++i)
|
||||
s.append(ucs4_to_qchar(str[i]));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@ -164,18 +161,6 @@ void qstring_to_ucs4(QString const & qstr, vector<char_type> & ucs4)
|
||||
}
|
||||
|
||||
|
||||
char_type const qchar_to_ucs4(QChar const & qchar)
|
||||
{
|
||||
return static_cast<lyx::char_type>(qchar.unicode());
|
||||
}
|
||||
|
||||
|
||||
QChar const ucs4_to_qchar(char_type const & ucs4)
|
||||
{
|
||||
return QChar(static_cast<unsigned short>(ucs4));
|
||||
}
|
||||
|
||||
|
||||
QString const qt_(char const * str)
|
||||
{
|
||||
return toqstr(_(str));
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <QChar>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class LengthCombo;
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QString;
|
||||
class QChar;
|
||||
|
||||
std::string makeFontName(std::string const & family, std::string const & foundry);
|
||||
|
||||
@ -68,16 +69,19 @@ QString const toqstr(std::string const & str);
|
||||
*/
|
||||
QString const toqstr(lyx::docstring const & ucs4);
|
||||
|
||||
QString const ucs4_to_qstring(lyx::char_type const * str, size_t ls);
|
||||
void ucs4_to_qstring(lyx::char_type const * str, size_t ls, QString & s);
|
||||
|
||||
lyx::docstring const qstring_to_ucs4(QString const & qstr);
|
||||
|
||||
void qstring_to_ucs4(QString const & qstr, std::vector<lyx::char_type> & ucs4);
|
||||
|
||||
lyx::char_type const qchar_to_ucs4(QChar const & qchar);
|
||||
|
||||
QChar const ucs4_to_qchar(lyx::char_type const & ucs4);
|
||||
inline lyx::char_type const qchar_to_ucs4(QChar const & qchar) {
|
||||
return static_cast<lyx::char_type>(qchar.unicode());
|
||||
}
|
||||
|
||||
inline QChar const ucs4_to_qchar(lyx::char_type const ucs4) {
|
||||
return QChar(static_cast<unsigned short>(ucs4));
|
||||
}
|
||||
|
||||
/**
|
||||
* qt_ - i18nize string and convert to unicode
|
||||
|
Loading…
Reference in New Issue
Block a user