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; } }
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"; } }
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; }