当前位置: 首页>>代码示例>>C++>>正文


C++ QChar::direction方法代码示例

本文整理汇总了C++中QChar::direction方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::direction方法的具体用法?C++ QChar::direction怎么用?C++ QChar::direction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QChar的用法示例。


在下文中一共展示了QChar::direction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: formatCharacter

static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context)
{
    const ushort unicode = qc.unicode();
    str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << uppercasedigits << hex << unicode
        << dec << qSetFieldWidth(0) << ' ';

    const EnumLookup *specialChar = enumLookup(unicode, specialCharactersEnumLookup, sizeof(specialCharactersEnumLookup) / sizeof(EnumLookup));
    if (specialChar)
        str << specialChar->description;
    else
        str << "'" << qc << '\'';

    const int category = qc.category();
    if (category != context.category) {
        str << " category="
            << enumName(category, categoryEnumLookup, sizeof(categoryEnumLookup) / sizeof(EnumLookup));
        context.category = category;
    }
#if QT_VERSION >= 0x050100
    const int script = qc.script();
    if (script != context.script) {
        str << " script="
            << enumName(script, scriptEnumLookup, sizeof(scriptEnumLookup) / sizeof(EnumLookup))
            << '(' << script << ')';
        context.script = script;
    }
#endif // Qt 5
    const int direction = qc.direction();
    if (direction != context.direction) {
        str << " direction="
            << enumName(direction, directionEnumLookup, sizeof(directionEnumLookup) / sizeof(EnumLookup));
        context.direction = direction;
    }
#if QT_VERSION >= 0x050000
    const int joiningType = qc.joiningType();
    if (joiningType != context.joiningType) {
        str << " joiningType="
            << enumName(joiningType, joiningTypeEnumLookup, sizeof(joiningTypeEnumLookup) / sizeof(EnumLookup));
        context.joiningType = joiningType;
    }
#endif // Qt 5QWidget
    const int decompositionTag = qc.decompositionTag();
    if (decompositionTag != context.decompositionTag) {
        str << " decomposition="
            << enumName(decompositionTag, decompositionEnumLookup, sizeof(decompositionEnumLookup) / sizeof(EnumLookup));
        context.decompositionTag = decompositionTag;
    }
    const int unicodeVersion = qc.unicodeVersion();
    if (unicodeVersion != context.unicodeVersion) {
        str << " version="
        << enumName(unicodeVersion, unicodeVersionEnumLookup, sizeof(unicodeVersionEnumLookup) / sizeof(EnumLookup));
        context.unicodeVersion = unicodeVersion;
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:54,代码来源:textdump.cpp

示例2: containsOnlyWhitespace

// FIXME: should be a cached flag maybe.
bool DOMStringImpl::containsOnlyWhitespace() const
{
    if (!s)
        return true;

    for (uint i = 0; i < l; i++) {
        QChar c = s[i];
        if (c.unicode() <= 0x7F) {
            if (c.unicode() > ' ')
                return false;
        } else {
            if (c.direction() != QChar::DirWS)
                return false;
        }
    }
    return true;
}
开发者ID:vasi,项目名称:kdelibs,代码行数:18,代码来源:dom_stringimpl.cpp

示例3: text

void RTFGenParser::text(const QString &text)
{
    if (m_res_size)
        return;
    unsigned size = res.length();
    if (size > m_max_size){
        textPos = start_pos;
        m_res_size = size;
        return;
    }
    for (int i = 0; i < (int)(text.length()); i++){
        QChar c = text[i];
        if (c.isSpace()){
            unsigned size = res.length();
            if (size > m_max_size){
                textPos = start_pos + i;
                m_res_size = size;
                return;
            }
        }
        // In Qt, unless you force the paragraph direction with (Left/Right)
        // Ctrl-Shift (also known as Key_Direction_L and Key_Direction_R),
        // the P tag won't have a DIR attribute at all. In such cases, unlike
        // HTML, Qt will render the paragraph LTR or RTL according to the
        // first strong character (as Unicode TR#9 defines). Thus, if the
        // direction isn't known yet, we check each character till we find
        // a strong one.
        if ((m_lastParagraphPos != 0) && (m_paragraphDir == DirUnknown))
        {
            switch(c.direction())
            {
            case QChar::DirL:
                res.insert(m_lastParagraphPos, "\\ltrpar");
                m_paragraphDir = DirLTR;
                break;
            case QChar::DirR:
                res.insert(m_lastParagraphPos, "\\rtlpar");
                m_paragraphDir = DirRTL;
                break;
            default: // to avoid warnings
                break;
            }
        }

        unsigned short u = c.unicode();
        if (c == '\r' || c == '\n')
            continue;
        if ((c == '{') || (c == '}') || (c == '\\')){
            char b[5];
            snprintf(b, sizeof(b), "\\\'%02x", u & 0xFF);
            res += b;
            m_bSpace = false;
            continue;
        }
        if (u < 0x80){
            if (m_bSpace)
                res += ' ';
            res += (char)u;
            m_bSpace = false;
            continue;
        }
        QString s;
        s += c;
        if (m_codec){
            string plain;
            plain = static_cast<string>(m_codec->fromUnicode(s));
            if ((plain.length() == 1) && (m_codec->toUnicode(plain.c_str()) == s)){
                char b[5];
                snprintf(b, sizeof(b), "\\\'%02x", plain[0] & 0xFF);
                res += b;
                m_bSpace = false;
                continue;
            }
        }
        res += "\\u";
        res += number(s[0].unicode());
        res += "?";
        m_bSpace = false;
    }
}
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:80,代码来源:rtfgen.cpp


注:本文中的QChar::direction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。