diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2014-01-26 02:42:37 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-29 23:19:47 +0100 |
commit | b80fcbdba62ec2324fa9ad29cbc5ac1d9a9fe8a2 (patch) | |
tree | 97a78ec35d3e66e0f2539490d8e112322adde7ce /src/corelib/tools | |
parent | b04d87b2263fd5d9b2b57799098a2eb5a3c91dfc (diff) |
Introduce QChar::JoiningType enum and QChar::joiningType() method
This aimed to disctinct joining types "L", "T", and "U" from just "U".
Unicode 6.3.0 has introduced a character with joining type "L" and
Unicode 7.0 will add a few more characters of joining type "L", so
we'll have to deal with it anyways.
[ChangeLog][QtCore][QChar] Added JoiningType enum and joiningType()
method that deprecates the old QChar::Joining enum and joining() method.
Change-Id: I4be3a3f745d944e689feb9b62d4ca86d1cf371b0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qchar.cpp | 63 | ||||
-rw-r--r-- | src/corelib/tools/qchar.h | 28 | ||||
-rw-r--r-- | src/corelib/tools/qstring.h | 12 |
3 files changed, 97 insertions, 6 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index f7f425d594..eb59cc719f 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -127,9 +127,9 @@ QT_BEGIN_NAMESPACE Separator_* or an exceptional code point from Other_Control category). QChar also provides direction(), which indicates the "natural" - writing direction of this character. The joining() function + writing direction of this character. The joiningType() function indicates how the character joins with it's neighbors (needed - mostly for Arabic) and finally hasMirrored(), which indicates + mostly for Arabic or Syriac) and finally hasMirrored(), which indicates whether the character needs to be mirrored when it is printed in it's "unnatural" writing direction. @@ -458,7 +458,29 @@ QT_BEGIN_NAMESPACE */ /*! + \enum QChar::JoiningType + since 5.3 + + This enum type defines the Unicode joining type attributes. See the + \l{http://www.unicode.org/}{Unicode Standard} for a description of the values. + + In order to conform to C/C++ naming conventions "Joining_" is prepended + to the codes used in the Unicode Standard. + + \value Joining_None + \value Joining_Causing + \value Joining_Dual + \value Joining_Right + \value Joining_Left + \value Joining_Transparent + + \sa joiningType() +*/ + +#if QT_DEPRECATED_SINCE(5, 3) +/*! \enum QChar::Joining + \deprecated in 5.3, use JoiningType instead. This enum type defines the Unicode joining attributes. See the \l{http://www.unicode.org/}{Unicode Standard} for a description @@ -471,6 +493,7 @@ QT_BEGIN_NAMESPACE \sa joining() */ +#endif /*! \enum QChar::CombiningClass @@ -1053,7 +1076,32 @@ QChar::Direction QChar::direction(uint ucs4) } /*! + \fn QChar::JoiningType QChar::joiningType() const + \since 5.3 + + Returns information about the joining type attributes of the character + (needed for certain languages such as Arabic or Syriac). +*/ + +/*! + \overload + \since 5.3 + + Returns information about the joining type attributes of the UCS-4-encoded + character specified by \a ucs4 + (needed for certain languages such as Arabic or Syriac). +*/ +QChar::JoiningType QChar::joiningType(uint ucs4) +{ + if (ucs4 > LastValidCodePoint) + return QChar::Joining_None; + return QChar::JoiningType(qGetProp(ucs4)->joining); +} + +#if QT_DEPRECATED_SINCE(5, 3) +/*! \fn QChar::Joining QChar::joining() const + \deprecated in 5.3, use joiningType() instead. Returns information about the joining properties of the character (needed for certain languages such as Arabic). @@ -1061,6 +1109,8 @@ QChar::Direction QChar::direction(uint ucs4) /*! \overload + \deprecated in 5.3, use joiningType() instead. + Returns information about the joining properties of the UCS-4-encoded character specified by \a ucs4 (needed for certain languages such as Arabic). */ @@ -1068,8 +1118,15 @@ QChar::Joining QChar::joining(uint ucs4) { if (ucs4 > LastValidCodePoint) return QChar::OtherJoining; - return (QChar::Joining) qGetProp(ucs4)->joining; + switch (qGetProp(ucs4)->joining) { + case QChar::Joining_Causing: return QChar::Center; + case QChar::Joining_Dual: return QChar::Dual; + case QChar::Joining_Right: return QChar::Right; + default: break; + } + return QChar::OtherJoining; } +#endif /*! \fn bool QChar::hasMirrored() const diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index 82ff337341..266effb66a 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -288,10 +288,21 @@ public: Fraction }; + enum JoiningType { + Joining_None, + Joining_Causing, + Joining_Dual, + Joining_Right, + Joining_Left, + Joining_Transparent + }; + +#if QT_DEPRECATED_SINCE(5, 3) enum Joining { OtherJoining, Dual, Right, Center }; +#endif enum CombiningClass { @@ -340,7 +351,17 @@ public: inline Category category() const { return QChar::category(ucs); } inline Direction direction() const { return QChar::direction(ucs); } - inline Joining joining() const { return QChar::joining(ucs); } + inline JoiningType joiningType() const { return QChar::joiningType(ucs); } +#if QT_DEPRECATED_SINCE(5, 3) + QT_DEPRECATED inline Joining joining() const { + switch (QChar::joiningType(ucs)) { + case QChar::Joining_Causing: return QChar::Center; + case QChar::Joining_Dual: return QChar::Dual; + case QChar::Joining_Right: return QChar::Right; + default: return QChar::OtherJoining; + } + } +#endif inline unsigned char combiningClass() const { return QChar::combiningClass(ucs); } inline QChar mirroredChar() const { return QChar::mirroredChar(ucs); } @@ -427,7 +448,10 @@ public: static Category QT_FASTCALL category(uint ucs4); static Direction QT_FASTCALL direction(uint ucs4); - static Joining QT_FASTCALL joining(uint ucs4); + static JoiningType QT_FASTCALL joiningType(uint ucs4); +#if QT_DEPRECATED_SINCE(5, 3) + QT_DEPRECATED static Joining QT_FASTCALL joining(uint ucs4); +#endif static unsigned char QT_FASTCALL combiningClass(uint ucs4); static uint QT_FASTCALL mirroredChar(uint ucs4); diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 01ddf669f5..4432759b03 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -908,7 +908,17 @@ public: QChar::Category category() const { return QChar(*this).category(); } QChar::Direction direction() const { return QChar(*this).direction(); } - QChar::Joining joining() const { return QChar(*this).joining(); } + QChar::JoiningType joiningType() const { return QChar(*this).joiningType(); } +#if QT_DEPRECATED_SINCE(5, 3) + QT_DEPRECATED QChar::Joining joining() const { + switch (QChar(*this).joiningType()) { + case QChar::Joining_Causing: return QChar::Center; + case QChar::Joining_Dual: return QChar::Dual; + case QChar::Joining_Right: return QChar::Right; + default: return QChar::OtherJoining; + } + } +#endif bool hasMirrored() const { return QChar(*this).hasMirrored(); } QChar mirroredChar() const { return QChar(*this).mirroredChar(); } QString decomposition() const { return QChar(*this).decomposition(); } |