Rename NameRole to DisplayNameRole in UserListModel
This commit is contained in:
@@ -54,7 +54,7 @@ QVariant CompletionModel::data(const QModelIndex &index, int role) const
|
|||||||
auto filterIndex = m_filterModel->index(index.row(), 0);
|
auto filterIndex = m_filterModel->index(index.row(), 0);
|
||||||
if (m_autoCompletionType == User) {
|
if (m_autoCompletionType == User) {
|
||||||
if (role == Text) {
|
if (role == Text) {
|
||||||
return m_filterModel->data(filterIndex, UserListModel::NameRole);
|
return m_filterModel->data(filterIndex, UserListModel::DisplayNameRole);
|
||||||
}
|
}
|
||||||
if (role == Subtitle) {
|
if (role == Subtitle) {
|
||||||
return m_filterModel->data(filterIndex, UserListModel::UserIdRole);
|
return m_filterModel->data(filterIndex, UserListModel::UserIdRole);
|
||||||
@@ -123,7 +123,7 @@ void CompletionModel::updateCompletion()
|
|||||||
if (text().startsWith(QLatin1Char('@'))) {
|
if (text().startsWith(QLatin1Char('@'))) {
|
||||||
m_filterModel->setSourceModel(m_userListModel);
|
m_filterModel->setSourceModel(m_userListModel);
|
||||||
m_filterModel->setFilterRole(UserListModel::UserIdRole);
|
m_filterModel->setFilterRole(UserListModel::UserIdRole);
|
||||||
m_filterModel->setSecondaryFilterRole(UserListModel::NameRole);
|
m_filterModel->setSecondaryFilterRole(UserListModel::DisplayNameRole);
|
||||||
m_filterModel->setFullText(m_fullText);
|
m_filterModel->setFullText(m_fullText);
|
||||||
m_filterModel->setFilterText(m_text);
|
m_filterModel->setFilterText(m_text);
|
||||||
m_autoCompletionType = User;
|
m_autoCompletionType = User;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ bool UserFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
|
|||||||
if (m_filterText.length() < 1) {
|
if (m_filterText.length() < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return sourceModel()->data(sourceModel()->index(sourceRow, 0), UserListModel::NameRole).toString().contains(m_filterText, Qt::CaseInsensitive)
|
return sourceModel()->data(sourceModel()->index(sourceRow, 0), UserListModel::DisplayNameRole).toString().contains(m_filterText, Qt::CaseInsensitive)
|
||||||
|| sourceModel()->data(sourceModel()->index(sourceRow, 0), UserListModel::UserIdRole).toString().contains(m_filterText, Qt::CaseInsensitive);
|
|| sourceModel()->data(sourceModel()->index(sourceRow, 0), UserListModel::UserIdRole).toString().contains(m_filterText, Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
auto user = m_users.at(index.row());
|
auto user = m_users.at(index.row());
|
||||||
if (role == NameRole) {
|
if (role == DisplayNameRole) {
|
||||||
return user->displayname(m_currentRoom);
|
return user->displayname(m_currentRoom);
|
||||||
}
|
}
|
||||||
if (role == UserIdRole) {
|
if (role == UserIdRole) {
|
||||||
@@ -204,7 +204,7 @@ QHash<int, QByteArray> UserListModel::roleNames() const
|
|||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
|
||||||
roles[NameRole] = "name";
|
roles[DisplayNameRole] = "name";
|
||||||
roles[UserIdRole] = "userId";
|
roles[UserIdRole] = "userId";
|
||||||
roles[AvatarRole] = "avatar";
|
roles[AvatarRole] = "avatar";
|
||||||
roles[ObjectRole] = "user";
|
roles[ObjectRole] = "user";
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
* @brief Defines the model roles.
|
* @brief Defines the model roles.
|
||||||
*/
|
*/
|
||||||
enum EventRoles {
|
enum EventRoles {
|
||||||
NameRole = Qt::UserRole + 1, /**< The user's display name in the current room. */
|
DisplayNameRole = Qt::DisplayRole, /**< The user's display name in the current room. */
|
||||||
UserIdRole, /**< Matrix ID of the user. */
|
UserIdRole, /**< Matrix ID of the user. */
|
||||||
AvatarRole, /**< The source URL for the user's avatar in the current room. */
|
AvatarRole, /**< The source URL for the user's avatar in the current room. */
|
||||||
ObjectRole, /**< The QObject for the user. */
|
ObjectRole, /**< The QObject for the user. */
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @sa QAbstractItemModel::data
|
* @sa QAbstractItemModel::data
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role = NameRole) const override;
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Number of rows in the model.
|
* @brief Number of rows in the model.
|
||||||
|
|||||||
Reference in New Issue
Block a user