Minor fixes to various models
This commit is contained in:
committed by
Tobias Fella
parent
45cee495a5
commit
96d24f5c3a
@@ -28,7 +28,7 @@ public:
|
|||||||
* @brief Defines the model roles.
|
* @brief Defines the model roles.
|
||||||
*/
|
*/
|
||||||
enum Roles {
|
enum Roles {
|
||||||
TypeRole = 0, /**< The type of the state event. */
|
TypeRole = Qt::UserRole, /**< The type of the state event. */
|
||||||
EventCountRole, /**< Number of events of this type. */
|
EventCountRole, /**< Number of events of this type. */
|
||||||
StateKeyRole, /**<State key. Only valid if there's exactly one event of this type. */
|
StateKeyRole, /**<State key. Only valid if there's exactly one event of this type. */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
NeoChatRoom *room = m_rooms.at(index.row());
|
NeoChatRoom *room = m_rooms.at(index.row());
|
||||||
if (role == DisplayNameRole) {
|
if (role == DisplayNameRole || role == Qt::DisplayRole) {
|
||||||
return room->displayName();
|
return room->displayName();
|
||||||
}
|
}
|
||||||
if (role == EscapedDisplayNameRole) {
|
if (role == EscapedDisplayNameRole) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
* @brief Defines the model roles.
|
* @brief Defines the model roles.
|
||||||
*/
|
*/
|
||||||
enum EventRoles {
|
enum EventRoles {
|
||||||
DisplayNameRole = Qt::DisplayRole, /**< The display name of the room. */
|
DisplayNameRole = Qt::UserRole, /**< The display name of the room. */
|
||||||
EscapedDisplayNameRole, /**< HTML-Escaped display name of the room. */
|
EscapedDisplayNameRole, /**< HTML-Escaped display name of the room. */
|
||||||
AvatarRole, /**< The source URL for the room's avatar. */
|
AvatarRole, /**< The source URL for the room's avatar. */
|
||||||
CanonicalAliasRole, /**< The room canonical alias. */
|
CanonicalAliasRole, /**< The room canonical alias. */
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ QVariant PermissionsModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto permission = m_permissions.value(index.row());
|
const auto permission = m_permissions.value(index.row());
|
||||||
if (role == NameRole) {
|
if (role == NameRole || role == Qt::DisplayRole) {
|
||||||
if (permissionNames.keys().contains(permission)) {
|
if (permissionNames.keys().contains(permission)) {
|
||||||
return permissionNames.value(permission).toString();
|
return permissionNames.value(permission).toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
* @brief Defines the model roles.
|
* @brief Defines the model roles.
|
||||||
*/
|
*/
|
||||||
enum Roles {
|
enum Roles {
|
||||||
NameRole = Qt::DisplayRole, /**< The permission name. */
|
NameRole = Qt::UserRole, /**< The permission name. */
|
||||||
SubtitleRole, /**< The description of the permission. */
|
SubtitleRole, /**< The description of the permission. */
|
||||||
TypeRole, /**< The base type of the permission, normally the event type id except for ban, kick, etc. */
|
TypeRole, /**< The base type of the permission, normally the event type id except for ban, kick, etc. */
|
||||||
LevelRole, /**< The current power level for the permission. */
|
LevelRole, /**< The current power level for the permission. */
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ QVariant MediaMessageFilterModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
QHash<int, QByteArray> MediaMessageFilterModel::roleNames() const
|
QHash<int, QByteArray> MediaMessageFilterModel::roleNames() const
|
||||||
{
|
{
|
||||||
auto roles = sourceModel()->roleNames();
|
auto roles = sourceModel() ? sourceModel()->roleNames() : QHash<int, QByteArray>();
|
||||||
roles[SourceRole] = "source";
|
roles[SourceRole] = "source";
|
||||||
roles[TempSourceRole] = "tempSource";
|
roles[TempSourceRole] = "tempSource";
|
||||||
roles[TypeRole] = "type";
|
roles[TypeRole] = "type";
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ void SearchModel::setSearchText(const QString &searchText)
|
|||||||
|
|
||||||
void SearchModel::search()
|
void SearchModel::search()
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_room);
|
if (!m_room) {
|
||||||
|
qWarning() << "SearchModel: No room";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_job) {
|
if (m_job) {
|
||||||
m_job->abandon();
|
m_job->abandon();
|
||||||
|
|||||||
Reference in New Issue
Block a user