Add usermarker.
This commit is contained in:
parent
3ef1744b5c
commit
29624c5f59
|
@ -3,20 +3,13 @@ import QtQuick.Controls 2.2
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import Matrique.Settings 0.1
|
import Matrique.Settings 0.1
|
||||||
|
|
||||||
Item {
|
Text {
|
||||||
property alias icon: iconText.text
|
property alias icon: materialLabel.text
|
||||||
property var color: MSettings.darkTheme ? "white" : "black"
|
|
||||||
|
|
||||||
id: item
|
id: materialLabel
|
||||||
|
|
||||||
Text {
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
id: iconText
|
|
||||||
font.pointSize: 16
|
font.pointSize: 16
|
||||||
font.family: materialFont.name
|
font.family: materialFont.name
|
||||||
color: item.color
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,14 +93,30 @@ RowLayout {
|
||||||
active: eventType === "image" || eventType === "file" || eventType === "audio"
|
active: eventType === "image" || eventType === "file" || eventType === "audio"
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoLabel {
|
Row {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
|
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
|
AutoLabel {
|
||||||
|
id: timeLabel
|
||||||
|
|
||||||
visible: Math.abs(time - aboveTime) > 600000 || index == 0
|
visible: Math.abs(time - aboveTime) > 600000 || index == 0
|
||||||
text: Qt.formatTime(time, "hh:mm")
|
text: Qt.formatTime(time, "hh:mm")
|
||||||
coloredBackground: highlighted
|
coloredBackground: highlighted
|
||||||
Material.foreground: "grey"
|
Material.foreground: "grey"
|
||||||
font.pointSize: 8
|
font.pointSize: 8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
height: timeLabel.height
|
||||||
|
|
||||||
|
visible: userMarker.length > 0
|
||||||
|
icon: "\ue5ca"
|
||||||
|
color: highlighted ? "white": Material.foreground
|
||||||
|
font.pointSize: 12
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
|
|
|
@ -32,6 +32,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const {
|
||||||
roles[AnnotationRole] = "annotation";
|
roles[AnnotationRole] = "annotation";
|
||||||
roles[EventResolvedTypeRole] = "eventResolvedType";
|
roles[EventResolvedTypeRole] = "eventResolvedType";
|
||||||
roles[PlainTextRole] = "plainText";
|
roles[PlainTextRole] = "plainText";
|
||||||
|
roles[UserMarkerRole] = "userMarker";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +138,11 @@ void MessageEventModel::setRoom(MatriqueRoom* room) {
|
||||||
&MessageEventModel::refreshEvent);
|
&MessageEventModel::refreshEvent);
|
||||||
connect(m_currentRoom, &Room::fileTransferCancelled, this,
|
connect(m_currentRoom, &Room::fileTransferCancelled, this,
|
||||||
&MessageEventModel::refreshEvent);
|
&MessageEventModel::refreshEvent);
|
||||||
|
connect(m_currentRoom, &Room::readMarkerForUserMoved, this,
|
||||||
|
[=](User* user, QString fromEventId, QString toEventId) {
|
||||||
|
refreshEventRoles(fromEventId, {UserMarkerRole});
|
||||||
|
refreshEventRoles(toEventId, {UserMarkerRole});
|
||||||
|
});
|
||||||
qDebug() << "Connected to room" << room->id() << "as"
|
qDebug() << "Connected to room" << room->id() << "as"
|
||||||
<< room->localUser()->id();
|
<< room->localUser()->id();
|
||||||
} else
|
} else
|
||||||
|
@ -624,6 +630,15 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
return role == TimeRole ? QVariant(ts) : renderDate(ts);
|
return role == TimeRole ? QVariant(ts) : renderDate(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (role == UserMarkerRole) {
|
||||||
|
QVariantList variantList;
|
||||||
|
for (User* user : m_currentRoom->usersAtEventId(evt.id())) {
|
||||||
|
if (user == m_currentRoom->localUser()) continue;
|
||||||
|
variantList.append(QVariant::fromValue(user));
|
||||||
|
}
|
||||||
|
return variantList;
|
||||||
|
}
|
||||||
|
|
||||||
if (role == AboveEventTypeRole || role == AboveSectionRole ||
|
if (role == AboveEventTypeRole || role == AboveSectionRole ||
|
||||||
role == AboveAuthorRole || role == AboveTimeRole)
|
role == AboveAuthorRole || role == AboveTimeRole)
|
||||||
for (auto r = row + 1; r < rowCount(); ++r) {
|
for (auto r = row + 1; r < rowCount(); ++r) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ class MessageEventModel : public QAbstractListModel {
|
||||||
LongOperationRole,
|
LongOperationRole,
|
||||||
AnnotationRole,
|
AnnotationRole,
|
||||||
PlainTextRole,
|
PlainTextRole,
|
||||||
|
UserMarkerRole,
|
||||||
// For debugging
|
// For debugging
|
||||||
EventResolvedTypeRole,
|
EventResolvedTypeRole,
|
||||||
};
|
};
|
||||||
|
@ -42,7 +43,7 @@ class MessageEventModel : public QAbstractListModel {
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex& index,
|
QVariant data(const QModelIndex& index,
|
||||||
int role = Qt::DisplayRole) const override;
|
int role = Qt::DisplayRole) const override;
|
||||||
QHash<int, QByteArray> roleNames() const;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
int refreshEvent(const QString& eventId);
|
int refreshEvent(const QString& eventId);
|
||||||
|
|
Loading…
Reference in New Issue