Пример #1
0
    MessageCompleterModel(const CWizBizUserDataArray& arrayUser, QObject* parent = 0)
        : QAbstractListModel(parent)
    {
        CWizBizUserDataArray::const_iterator it = arrayUser.begin();
        for (; it != arrayUser.end(); it++) {
            const WIZBIZUSER& user = *it;

            wchar_t name[user.alias.size()];
            user.alias.toWCharArray(name);
            QString py;
            WizToolsChinese2PinYin(name, WIZ_C2P_POLYPHONE, py); // FIXME

            if (py.isEmpty()) {
                py = user.alias; // not chinese
            } else {
                py = py.split("\n").at(0);
                py = py.replace(",", "");
            }

            m_users.insert(0, UserItem());
            m_users[0].strUserId = user.userId;
            m_users[0].strAlias = user.alias;
            m_users[0].strPinyin = py;
        }
    }
Пример #2
0
MessageCompleterModel::MessageCompleterModel(const CWizBizUserDataArray& arrayUser, QObject* parent)
    : QAbstractListModel(parent)
{
    CWizBizUserDataArray::const_iterator it = arrayUser.begin();
    for (; it != arrayUser.end(); it++) {
        const WIZBIZUSER& user = *it;

        QString part1 = user.alias;

        QString part2;
        WizToolsChinese2PinYin(user.alias, WIZ_C2P_POLYPHONE, part2); // FIXME
        if (!part2.isEmpty())
        {
            part2 = part2.replace(",", "");
        }
        //
#if QT_VERSION >= 0x050200
        QString part3;
        WizToolsChinese2PinYin(user.alias, WIZ_C2P_FIRST_LETTER_ONLY | WIZ_C2P_POLYPHONE, part3);
        if (!part3.isEmpty())
        {
            part3 = part3.replace(",", "");
        }
#endif
        //
#if QT_VERSION >= 0x050200
        QString matchText = part1 + "\n" + part2 + "\n" + part3;
#else
        QString matchText;
        if (part2.isEmpty())
        {
            matchText = part1;
        }
        else
        {
            matchText = part2;
        }
#endif

        m_users.insert(0, UserItem());
        m_users[0].strUserId = user.userId;
        m_users[0].strAlias = user.alias;
        m_users[0].strPinyin = matchText;
    }
    if (!m_users.isEmpty())
    {
        qSort(m_users.begin(), m_users.end(), caseInsensitiveLessThan);
        m_users.insert(0, UserItem());
        m_users[0].strUserId = QString();
        m_users[0].strAlias = tr("all");
        m_users[0].strPinyin = "all";
    }
}
Пример #3
0
bool CWizIndexBase::SQLToBizUserDataArray(const QString& strSQL,
                                          CWizBizUserDataArray& arrayUser)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        while (!query.eof())
        {
            WIZBIZUSER data;
            data.bizGUID = query.getStringField(userBIZ_GUID);
            data.userId = query.getStringField(userUSER_ID);
            data.userGUID = query.getStringField(userUSER_GUID);
            data.alias = query.getStringField(userUSER_ALIAS);
            data.pinyin = query.getStringField(userUSER_PINYIN);

            arrayUser.push_back(data);
            query.nextRow();
        }

        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
Пример #4
0
bool CWizDatabase::updateBizUsers(const CWizBizUserDataArray& arrayUser)
{
    // TODO: delete users not exist on remote
    if (arrayUser.empty())
        return false;

    bool bHasError = false;
    CWizBizUserDataArray::const_iterator it;
    for (it = arrayUser.begin(); it != arrayUser.end(); it++)
    {
        const WIZBIZUSER& user = *it;
        if (!updateBizUser(user)) {
            bHasError = true;
        }
    }

    return !bHasError;
}
Пример #5
0
bool CWizIndexBase::userFromGUID(const QString& bizGUID,
                                 const QString& userGUID,
                                 WIZBIZUSER& user)
{
    CString strWhere = "BIZ_GUID=%1 AND USER_GUID=%2";
    strWhere = strWhere.arg(STR2SQL(bizGUID)).arg(STR2SQL(userGUID));

    CString strSQL = FormatQuerySQL(TABLE_NAME_WIZ_USER,
                                    FIELD_LIST_WIZ_USER,
                                    strWhere);

    CWizBizUserDataArray arrayUser;
    if (!SQLToBizUserDataArray(strSQL, arrayUser)) {
        TOLOG("[userFromGUID] failed to get user by user guid");
        return false;
    }

    if (arrayUser.empty())
        return false;

    user = arrayUser[0];
    return true;
}
Пример #6
0
bool CWizIndexBase::userFromGUID(const QString& strUserGUID,
                                 CWizBizUserDataArray& arrayUser)
{
    CString strWhere;
    strWhere.Format("USER_GUID=%s", STR2SQL(strUserGUID).utf16());

    CString strSQL = FormatQuerySQL(TABLE_NAME_WIZ_USER,
                                    FIELD_LIST_WIZ_USER,
                                    strWhere);

    if (!SQLToBizUserDataArray(strSQL, arrayUser)) {
        TOLOG("[userFromGUID] failed to get user by user guid");
        return false;
    }

    if (arrayUser.empty())
        return false;

    return true;
}