4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #include "lyxlength.h"
16 #include "support/docstring.h"
31 std::string makeFontName(std::string const & family, std::string const & foundry);
33 std::pair<std::string,std::string> parseFontName(std::string const & name);
35 /// method to get a LyXLength from widgets (LengthCombo)
36 std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
37 /// method to get a LyXLength from widgets (QComboBox)
38 LyXLength widgetsToLength(QLineEdit const * input, QComboBox const * combo);
40 /// method to set widgets from a LyXLength
41 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
42 std::string const & len, LyXLength::UNIT default_unit);
44 /// format a string to the given width
45 docstring const formatted(docstring const & text, int w = 80);
48 * toqstr - convert char * into Qt's unicode (UTF16)
50 * Use this whenever there's a user-visible string that is encoded
51 * for the locale (menus, dialogs etc.)
53 inline QString const toqstr(char const * str)
55 return QString::fromUtf8(str);
60 * toqstr - convert string into unicode
62 * Use this whenever there's a user-visible string that is encoded
63 * for the locale (menus, dialogs etc.)
65 inline QString const toqstr(std::string const & str)
67 return toqstr(str.c_str());
72 * toqstr - convert ucs4 into QString
74 * QString uses utf16 internally.
76 inline char_type const qchar_to_ucs4(QChar const & qchar) {
77 return static_cast<char_type>(qchar.unicode());
80 inline QChar const ucs4_to_qchar(char_type const ucs4) {
81 return QChar(static_cast<unsigned short>(ucs4));
84 QString const toqstr(docstring const & ucs4);
86 void ucs4_to_qstring(docstring const & str, QString & s);
88 inline void ucs4_to_qstring(char_type const * str, size_t ls, QString & s)
90 int i = static_cast<int>(ls);
93 s[i] = ucs4_to_qchar(str[i]);
97 QString ucs4_to_qstring(docstring const & str);
99 docstring const qstring_to_ucs4(QString const & qstr);
101 void qstring_to_ucs4(QString const & qstr, std::vector<char_type> & ucs4);
104 * qt_ - i18nize string and convert to unicode
106 * Use this in qt4/ instead of qt_()
108 QString const qt_(char const * str, const char * comment);
112 * qt_ - i18nize string and convert to unicode
114 * Use this in qt4/ instead of qt_()
116 QString const qt_(std::string const & str);
120 * fromqstr - convert QString into std::string in locale
122 * Return the QString encoded in the locale
124 std::string const fromqstr(QString const & str);
129 #endif // QTHELPERS_H