Sort rooms by last event, not unread count.
This commit is contained in:
parent
86ea5d02c1
commit
0361432c3d
|
@ -73,7 +73,7 @@ Item {
|
||||||
RoleSorter { roleName: "category" },
|
RoleSorter { roleName: "category" },
|
||||||
RoleSorter {
|
RoleSorter {
|
||||||
enabled: MSettings.rearrangeByActivity
|
enabled: MSettings.rearrangeByActivity
|
||||||
roleName: "unreadCount"
|
roleName: "lastActiveTime"
|
||||||
sortOrder: Qt.DescendingOrder
|
sortOrder: Qt.DescendingOrder
|
||||||
},
|
},
|
||||||
StringSorter { roleName: "name" }
|
StringSorter { roleName: "name" }
|
||||||
|
|
|
@ -163,6 +163,7 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const {
|
||||||
if (role == UnreadCountRole) return room->unreadCount();
|
if (role == UnreadCountRole) return room->unreadCount();
|
||||||
if (role == HighlightCountRole) return room->highlightCount();
|
if (role == HighlightCountRole) return room->highlightCount();
|
||||||
if (role == LastEventRole) return room->lastEvent();
|
if (role == LastEventRole) return room->lastEvent();
|
||||||
|
if (role == LastActiveTimeRole) return room->lastActiveTime();
|
||||||
if (role == CurrentRoomRole) return QVariant::fromValue(room);
|
if (role == CurrentRoomRole) return QVariant::fromValue(room);
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -196,6 +197,7 @@ QHash<int, QByteArray> RoomListModel::roleNames() const {
|
||||||
roles[UnreadCountRole] = "unreadCount";
|
roles[UnreadCountRole] = "unreadCount";
|
||||||
roles[HighlightCountRole] = "highlightCount";
|
roles[HighlightCountRole] = "highlightCount";
|
||||||
roles[LastEventRole] = "lastEvent";
|
roles[LastEventRole] = "lastEvent";
|
||||||
|
roles[LastActiveTimeRole] = "lastActiveTime";
|
||||||
roles[CurrentRoomRole] = "currentRoom";
|
roles[CurrentRoomRole] = "currentRoom";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "events/roomevent.h"
|
#include "events/roomevent.h"
|
||||||
#include "spectralroom.h"
|
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
|
#include "spectralroom.h"
|
||||||
|
|
||||||
#include <QtCore/QAbstractListModel>
|
#include <QtCore/QAbstractListModel>
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ class RoomListModel : public QAbstractListModel {
|
||||||
UnreadCountRole,
|
UnreadCountRole,
|
||||||
HighlightCountRole,
|
HighlightCountRole,
|
||||||
LastEventRole,
|
LastEventRole,
|
||||||
|
LastActiveTimeRole,
|
||||||
CurrentRoomRole,
|
CurrentRoomRole,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -140,3 +140,8 @@ void SpectralRoom::sendReply(QString userId, QString eventId,
|
||||||
"</blockquote></mx-reply>" + sendContent}};
|
"</blockquote></mx-reply>" + sendContent}};
|
||||||
postJson("m.room.message", json);
|
postJson("m.room.message", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDateTime SpectralRoom::lastActiveTime() {
|
||||||
|
if (timelineSize() == 0) return QDateTime();
|
||||||
|
return messageEvents().rbegin()->get()->timestamp();
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ class SpectralRoom : public Room {
|
||||||
QString lastEvent();
|
QString lastEvent();
|
||||||
bool isEventHighlighted(const QMatrixClient::RoomEvent* e) const;
|
bool isEventHighlighted(const QMatrixClient::RoomEvent* e) const;
|
||||||
|
|
||||||
|
QDateTime lastActiveTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_cachedInput;
|
QString m_cachedInput;
|
||||||
QSet<const QMatrixClient::RoomEvent*> highlights;
|
QSet<const QMatrixClient::RoomEvent*> highlights;
|
||||||
|
@ -59,7 +61,8 @@ class SpectralRoom : public Room {
|
||||||
void acceptInvitation();
|
void acceptInvitation();
|
||||||
void forget();
|
void forget();
|
||||||
void sendTypingNotification(bool isTyping);
|
void sendTypingNotification(bool isTyping);
|
||||||
void sendReply(QString userId, QString eventId, QString replyContent, QString sendContent);
|
void sendReply(QString userId, QString eventId, QString replyContent,
|
||||||
|
QString sendContent);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SpectralRoom_H
|
#endif // SpectralRoom_H
|
||||||
|
|
Loading…
Reference in New Issue