Add unread message indicator for room . #6
This commit is contained in:
parent
c5a55654a0
commit
9c7defba16
|
@ -37,7 +37,7 @@ Item {
|
||||||
bottomPadding: 0
|
bottomPadding: 0
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
background: Item {
|
background: Item {
|
||||||
Row {
|
Row {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
@ -142,6 +142,13 @@ Item {
|
||||||
ToolTip.visible: mini && hovered
|
ToolTip.visible: mini && hovered
|
||||||
ToolTip.text: name
|
ToolTip.text: name
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 4
|
||||||
|
height: parent.height
|
||||||
|
color: Qt.tint(Material.accent, "#20FFFFFF")
|
||||||
|
visible: unreadCount > 0
|
||||||
|
}
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 16
|
anchors.margins: 16
|
||||||
|
|
|
@ -159,6 +159,9 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const {
|
||||||
if (room->highlightCount() > 0) return QBrush(QColor("orange"));
|
if (room->highlightCount() > 0) return QBrush(QColor("orange"));
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
if (role == UnreadCountRole) {
|
||||||
|
return room->unreadCount();
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,5 +192,6 @@ QHash<int, QByteArray> RoomListModel::roleNames() const {
|
||||||
roles[TopicRole] = "topic";
|
roles[TopicRole] = "topic";
|
||||||
roles[CategoryRole] = "category";
|
roles[CategoryRole] = "category";
|
||||||
roles[HighlightRole] = "highlight";
|
roles[HighlightRole] = "highlight";
|
||||||
|
roles[UnreadCountRole] = "unreadCount";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ class RoomListModel : public QAbstractListModel {
|
||||||
TopicRole,
|
TopicRole,
|
||||||
CategoryRole,
|
CategoryRole,
|
||||||
HighlightRole,
|
HighlightRole,
|
||||||
|
UnreadCountRole,
|
||||||
};
|
};
|
||||||
|
|
||||||
RoomListModel(QObject* parent = 0);
|
RoomListModel(QObject* parent = 0);
|
||||||
|
|
Loading…
Reference in New Issue