Switch to release branch.
This commit is contained in:
parent
d83d00f967
commit
d6b5cba61f
|
@ -1 +1 @@
|
||||||
Subproject commit c4acd8ece12622164caf396c06bd0f22ab3589f7
|
Subproject commit fe4bedeb349ed867feba7cb3c996a97f726d2083
|
|
@ -31,15 +31,16 @@ void MessageEventModel::setRoom(QMatrixClient::Room* room)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
if(m_currentRoom)
|
if( m_currentRoom )
|
||||||
{
|
{
|
||||||
m_currentRoom->disconnect(this);
|
m_currentRoom->disconnect( this );
|
||||||
qDebug() << "Disconnected from" << m_currentRoom->id();
|
qDebug() << "Disconnected from" << m_currentRoom->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentRoom = room;
|
m_currentRoom = room;
|
||||||
if(room)
|
if( room )
|
||||||
{
|
{
|
||||||
|
lastReadEventId = room->readMarkerEventId();
|
||||||
using namespace QMatrixClient;
|
using namespace QMatrixClient;
|
||||||
connect(m_currentRoom, &Room::aboutToAddNewMessages, this,
|
connect(m_currentRoom, &Room::aboutToAddNewMessages, this,
|
||||||
[=](RoomEventsRange events)
|
[=](RoomEventsRange events)
|
||||||
|
@ -49,11 +50,21 @@ void MessageEventModel::setRoom(QMatrixClient::Room* room)
|
||||||
connect(m_currentRoom, &Room::aboutToAddHistoricalMessages, this,
|
connect(m_currentRoom, &Room::aboutToAddHistoricalMessages, this,
|
||||||
[=](RoomEventsRange events)
|
[=](RoomEventsRange events)
|
||||||
{
|
{
|
||||||
|
if (rowCount() > 0)
|
||||||
|
nextNewerRow = rowCount() - 1;
|
||||||
beginInsertRows(QModelIndex(), rowCount(),
|
beginInsertRows(QModelIndex(), rowCount(),
|
||||||
rowCount() + int(events.size()) - 1);
|
rowCount() + int(events.size()) - 1);
|
||||||
});
|
});
|
||||||
connect(m_currentRoom, &Room::addedMessages,
|
connect(m_currentRoom, &Room::addedMessages, this,
|
||||||
this, &MessageEventModel::endInsertRows);
|
[=] {
|
||||||
|
if (nextNewerRow > -1)
|
||||||
|
{
|
||||||
|
const auto idx = index(nextNewerRow);
|
||||||
|
emit dataChanged(idx, idx);
|
||||||
|
nextNewerRow = -1;
|
||||||
|
}
|
||||||
|
endInsertRows();
|
||||||
|
});
|
||||||
connect(m_currentRoom, &Room::readMarkerMoved, this, [this] {
|
connect(m_currentRoom, &Room::readMarkerMoved, this, [this] {
|
||||||
refreshEventRoles(
|
refreshEventRoles(
|
||||||
std::exchange(lastReadEventId,
|
std::exchange(lastReadEventId,
|
||||||
|
@ -75,8 +86,8 @@ void MessageEventModel::setRoom(QMatrixClient::Room* room)
|
||||||
this, &MessageEventModel::refreshEvent);
|
this, &MessageEventModel::refreshEvent);
|
||||||
qDebug() << "Connected to room" << room->id()
|
qDebug() << "Connected to room" << room->id()
|
||||||
<< "as" << room->localUser()->id();
|
<< "as" << room->localUser()->id();
|
||||||
}
|
} else
|
||||||
lastReadEventId = room ? room->readMarkerEventId() : "";
|
lastReadEventId.clear();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
emit roomChanged();
|
emit roomChanged();
|
||||||
}
|
}
|
||||||
|
@ -153,255 +164,268 @@ int MessageEventModel::rowCount(const QModelIndex& parent) const
|
||||||
QVariant MessageEventModel::data(const QModelIndex& index, int role) const
|
QVariant MessageEventModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
if( !m_currentRoom ||
|
if( !m_currentRoom ||
|
||||||
index.row() < 0 || index.row() >= m_currentRoom->timelineSize())
|
index.row() < 0 || index.row() >= m_currentRoom->timelineSize())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
const auto timelineIt = m_currentRoom->messageEvents().rbegin() + index.row();
|
const auto timelineIt = m_currentRoom->messageEvents().rbegin() + index.row();
|
||||||
const auto& ti = *timelineIt;
|
const auto& ti = *timelineIt;
|
||||||
|
|
||||||
using namespace QMatrixClient;
|
using namespace QMatrixClient;
|
||||||
if( role == Qt::DisplayRole )
|
if( role == Qt::DisplayRole )
|
||||||
{
|
{
|
||||||
if (ti->isRedacted())
|
if (ti->isRedacted())
|
||||||
{
|
{
|
||||||
auto reason = ti->redactedBecause()->reason();
|
auto reason = ti->redactedBecause()->reason();
|
||||||
if (reason.isEmpty())
|
if (reason.isEmpty())
|
||||||
return tr("Redacted");
|
return tr("Redacted");
|
||||||
|
else
|
||||||
|
return tr("Redacted: %1")
|
||||||
|
.arg(ti->redactedBecause()->reason());
|
||||||
|
}
|
||||||
|
|
||||||
return tr("Redacted: %1")
|
if( ti->type() == EventType::RoomMessage )
|
||||||
.arg(ti->redactedBecause()->reason());
|
{
|
||||||
}
|
using namespace MessageEventContent;
|
||||||
|
|
||||||
return visit(*ti
|
auto* e = ti.viewAs<RoomMessageEvent>();
|
||||||
, [this] (const RoomMessageEvent& e) -> QVariant {
|
if (e->hasTextContent() && e->mimeType().name() != "text/plain")
|
||||||
using namespace MessageEventContent;
|
return static_cast<const TextContent*>(e->content())->body;
|
||||||
|
if (e->hasFileContent())
|
||||||
|
{
|
||||||
|
auto fileCaption = e->content()->fileInfo()->originalName;
|
||||||
|
if (fileCaption.isEmpty())
|
||||||
|
fileCaption = m_currentRoom->prettyPrint(e->plainBody());
|
||||||
|
if (fileCaption.isEmpty())
|
||||||
|
return tr("a file");
|
||||||
|
}
|
||||||
|
return m_currentRoom->prettyPrint(e->plainBody());
|
||||||
|
}
|
||||||
|
if( ti->type() == EventType::RoomMember )
|
||||||
|
{
|
||||||
|
auto* e = ti.viewAs<RoomMemberEvent>();
|
||||||
|
// FIXME: Rewind to the name that was at the time of this event
|
||||||
|
QString subjectName = m_currentRoom->roomMembername(e->userId());
|
||||||
|
// The below code assumes senderName output in AuthorRole
|
||||||
|
switch( e->membership() )
|
||||||
|
{
|
||||||
|
case MembershipType::Invite:
|
||||||
|
if (e->repeatsState())
|
||||||
|
return tr("reinvited %1 to the room").arg(subjectName);
|
||||||
|
// [[fallthrough]]
|
||||||
|
case MembershipType::Join:
|
||||||
|
{
|
||||||
|
if (e->repeatsState())
|
||||||
|
return tr("joined the room (repeated)");
|
||||||
|
if (!e->prev_content() ||
|
||||||
|
e->membership() != e->prev_content()->membership)
|
||||||
|
{
|
||||||
|
return e->membership() == MembershipType::Invite
|
||||||
|
? tr("invited %1 to the room").arg(subjectName)
|
||||||
|
: tr("joined the room");
|
||||||
|
}
|
||||||
|
QString text {};
|
||||||
|
if (e->displayName() != e->prev_content()->displayName)
|
||||||
|
{
|
||||||
|
if (e->displayName().isEmpty())
|
||||||
|
text = tr("cleared the display name");
|
||||||
|
else
|
||||||
|
text = tr("changed the display name to %1")
|
||||||
|
.arg(e->displayName());
|
||||||
|
}
|
||||||
|
if (e->avatarUrl() != e->prev_content()->avatarUrl)
|
||||||
|
{
|
||||||
|
if (!text.isEmpty())
|
||||||
|
text += " and ";
|
||||||
|
if (e->avatarUrl().isEmpty())
|
||||||
|
text += tr("cleared the avatar");
|
||||||
|
else
|
||||||
|
text += tr("updated the avatar");
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case MembershipType::Leave:
|
||||||
|
if (e->prev_content() &&
|
||||||
|
e->prev_content()->membership == MembershipType::Ban)
|
||||||
|
{
|
||||||
|
if (e->senderId() != e->userId())
|
||||||
|
return tr("unbanned %1").arg(subjectName);
|
||||||
|
else
|
||||||
|
return tr("self-unbanned");
|
||||||
|
}
|
||||||
|
if (e->senderId() != e->userId())
|
||||||
|
return tr("has put %1 out of the room").arg(subjectName);
|
||||||
|
else
|
||||||
|
return tr("left the room");
|
||||||
|
case MembershipType::Ban:
|
||||||
|
if (e->senderId() != e->userId())
|
||||||
|
return tr("banned %1 from the room").arg(subjectName);
|
||||||
|
else
|
||||||
|
return tr("self-banned from the room");
|
||||||
|
case MembershipType::Knock:
|
||||||
|
return tr("knocked");
|
||||||
|
case MembershipType::Undefined:
|
||||||
|
return tr("made something unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( ti->type() == EventType::RoomAliases )
|
||||||
|
{
|
||||||
|
auto* e = ti.viewAs<RoomAliasesEvent>();
|
||||||
|
return tr("set aliases to: %1").arg(e->aliases().join(", "));
|
||||||
|
}
|
||||||
|
if( ti->type() == EventType::RoomCanonicalAlias )
|
||||||
|
{
|
||||||
|
auto* e = ti.viewAs<RoomCanonicalAliasEvent>();
|
||||||
|
if (e->alias().isEmpty())
|
||||||
|
return tr("cleared the room main alias");
|
||||||
|
else
|
||||||
|
return tr("set the room main alias to: %1").arg(e->alias());
|
||||||
|
}
|
||||||
|
if( ti->type() == EventType::RoomName )
|
||||||
|
{
|
||||||
|
auto* e = ti.viewAs<RoomNameEvent>();
|
||||||
|
if (e->name().isEmpty())
|
||||||
|
return tr("cleared the room name");
|
||||||
|
else
|
||||||
|
return tr("set the room name to: %1").arg(e->name());
|
||||||
|
}
|
||||||
|
if( ti->type() == EventType::RoomTopic )
|
||||||
|
{
|
||||||
|
auto* e = ti.viewAs<RoomTopicEvent>();
|
||||||
|
if (e->topic().isEmpty())
|
||||||
|
return tr("cleared the topic");
|
||||||
|
else
|
||||||
|
return tr("set the topic to: %1").arg(e->topic());
|
||||||
|
}
|
||||||
|
if( ti->type() == EventType::RoomAvatar )
|
||||||
|
{
|
||||||
|
return tr("changed the room avatar");
|
||||||
|
}
|
||||||
|
if( ti->type() == EventType::RoomEncryption )
|
||||||
|
{
|
||||||
|
return tr("activated End-to-End Encryption");
|
||||||
|
}
|
||||||
|
return tr("Unknown Event");
|
||||||
|
}
|
||||||
|
|
||||||
if (e.hasTextContent() && e.mimeType().name() != "text/plain")
|
if( role == Qt::ToolTipRole )
|
||||||
return static_cast<const TextContent*>(e.content())->body;
|
{
|
||||||
if (e.hasFileContent())
|
return ti->originalJson();
|
||||||
{
|
}
|
||||||
auto fileCaption = e.content()->fileInfo()->originalName;
|
|
||||||
if (fileCaption.isEmpty())
|
|
||||||
fileCaption = m_currentRoom->prettyPrint(e.plainBody());
|
|
||||||
if (fileCaption.isEmpty())
|
|
||||||
return tr("a file");
|
|
||||||
}
|
|
||||||
return m_currentRoom->prettyPrint(e.plainBody());
|
|
||||||
}
|
|
||||||
, [this] (const RoomMemberEvent& e) -> QVariant {
|
|
||||||
// FIXME: Rewind to the name that was at the time of this event
|
|
||||||
QString subjectName = m_currentRoom->roomMembername(e.userId());
|
|
||||||
// The below code assumes senderName output in AuthorRole
|
|
||||||
switch( e.membership() )
|
|
||||||
{
|
|
||||||
case MembershipType::Invite:
|
|
||||||
if (e.repeatsState())
|
|
||||||
return tr("reinvited %1 to the room").arg(subjectName);
|
|
||||||
FALLTHROUGH;
|
|
||||||
case MembershipType::Join:
|
|
||||||
{
|
|
||||||
if (e.repeatsState())
|
|
||||||
return tr("joined the room (repeated)");
|
|
||||||
if (!e.prevContent() ||
|
|
||||||
e.membership() != e.prevContent()->membership)
|
|
||||||
{
|
|
||||||
return e.membership() == MembershipType::Invite
|
|
||||||
? tr("invited %1 to the room").arg(subjectName)
|
|
||||||
: tr("joined the room");
|
|
||||||
}
|
|
||||||
QString text {};
|
|
||||||
if (e.displayName() != e.prevContent()->displayName)
|
|
||||||
{
|
|
||||||
if (e.displayName().isEmpty())
|
|
||||||
text = tr("cleared the display name");
|
|
||||||
else
|
|
||||||
text = tr("changed the display name to %1")
|
|
||||||
.arg(e.displayName());
|
|
||||||
}
|
|
||||||
if (e.avatarUrl() != e.prevContent()->avatarUrl)
|
|
||||||
{
|
|
||||||
if (!text.isEmpty())
|
|
||||||
text += " and ";
|
|
||||||
if (e.avatarUrl().isEmpty())
|
|
||||||
text += tr("cleared the avatar");
|
|
||||||
else
|
|
||||||
text += tr("updated the avatar");
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
case MembershipType::Leave:
|
|
||||||
if (e.prevContent() &&
|
|
||||||
e.prevContent()->membership == MembershipType::Ban)
|
|
||||||
{
|
|
||||||
return (e.senderId() != e.userId())
|
|
||||||
? tr("unbanned %1").arg(subjectName)
|
|
||||||
: tr("self-unbanned");
|
|
||||||
}
|
|
||||||
return (e.senderId() != e.userId())
|
|
||||||
? tr("has put %1 out of the room").arg(subjectName)
|
|
||||||
: tr("left the room");
|
|
||||||
case MembershipType::Ban:
|
|
||||||
return (e.senderId() != e.userId())
|
|
||||||
? tr("banned %1 from the room").arg(subjectName)
|
|
||||||
: tr("self-banned from the room");
|
|
||||||
case MembershipType::Knock:
|
|
||||||
return tr("knocked");
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
return tr("made something unknown");
|
|
||||||
}
|
|
||||||
, [] (const RoomAliasesEvent& e) -> QVariant {
|
|
||||||
return tr("set aliases to: %1").arg(e.aliases().join(", "));
|
|
||||||
}
|
|
||||||
, [] (const RoomCanonicalAliasEvent& e) -> QVariant {
|
|
||||||
return (e.alias().isEmpty())
|
|
||||||
? tr("cleared the room main alias")
|
|
||||||
: tr("set the room main alias to: %1").arg(e.alias());
|
|
||||||
}
|
|
||||||
, [] (const RoomNameEvent& e) -> QVariant {
|
|
||||||
return (e.name().isEmpty())
|
|
||||||
? tr("cleared the room name")
|
|
||||||
: tr("set the room name to: %1").arg(e.name());
|
|
||||||
}
|
|
||||||
, [] (const RoomTopicEvent& e) -> QVariant {
|
|
||||||
return (e.topic().isEmpty())
|
|
||||||
? tr("cleared the topic")
|
|
||||||
: tr("set the topic to: %1").arg(e.topic());
|
|
||||||
}
|
|
||||||
, [] (const RoomAvatarEvent&) -> QVariant {
|
|
||||||
return tr("changed the room avatar");
|
|
||||||
}
|
|
||||||
, [] (const EncryptionEvent&) -> QVariant {
|
|
||||||
return tr("activated End-to-End Encryption");
|
|
||||||
}
|
|
||||||
, tr("Unknown Event")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( role == Qt::ToolTipRole )
|
if( role == EventTypeRole )
|
||||||
{
|
{
|
||||||
return ti->originalJson();
|
if (ti->isStateEvent())
|
||||||
}
|
return "state";
|
||||||
|
|
||||||
if( role == EventTypeRole )
|
if (ti->type() == EventType::RoomMessage)
|
||||||
{
|
{
|
||||||
if (ti->isStateEvent())
|
switch (ti.viewAs<RoomMessageEvent>()->msgtype())
|
||||||
return "state";
|
{
|
||||||
|
case MessageEventType::Emote:
|
||||||
|
return "emote";
|
||||||
|
case MessageEventType::Notice:
|
||||||
|
return "notice";
|
||||||
|
case MessageEventType::Image:
|
||||||
|
return "image";
|
||||||
|
case MessageEventType::File:
|
||||||
|
case MessageEventType::Audio:
|
||||||
|
case MessageEventType::Video:
|
||||||
|
return "file";
|
||||||
|
default:
|
||||||
|
return "message";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (auto e = ti.viewAs<RoomMessageEvent>())
|
return "other";
|
||||||
{
|
}
|
||||||
switch (e->msgtype())
|
|
||||||
{
|
|
||||||
case MessageEventType::Emote:
|
|
||||||
return "emote";
|
|
||||||
case MessageEventType::Notice:
|
|
||||||
return "notice";
|
|
||||||
case MessageEventType::Image:
|
|
||||||
return "image";
|
|
||||||
case MessageEventType::File:
|
|
||||||
case MessageEventType::Audio:
|
|
||||||
case MessageEventType::Video:
|
|
||||||
return "file";
|
|
||||||
default:
|
|
||||||
return "message";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "other";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role == EventResolvedTypeRole)
|
if( role == TimeRole )
|
||||||
return EventTypeRegistry::getMatrixType(ti->type());
|
return makeMessageTimestamp(timelineIt);
|
||||||
|
|
||||||
if( role == TimeRole )
|
if( role == SectionRole )
|
||||||
return makeMessageTimestamp(timelineIt);
|
return makeDateString(timelineIt); // FIXME: move date rendering to QML
|
||||||
|
|
||||||
if( role == SectionRole )
|
if( role == AuthorRole )
|
||||||
return makeDateString(timelineIt); // FIXME: move date rendering to QML
|
{
|
||||||
|
auto userId = ti->senderId();
|
||||||
|
// FIXME: It shouldn't be User, it should be its state "as of event"
|
||||||
|
return QVariant::fromValue(m_currentRoom->user(userId));
|
||||||
|
}
|
||||||
|
|
||||||
if( role == AuthorRole )
|
if (role == ContentTypeRole)
|
||||||
{
|
{
|
||||||
auto userId = ti->senderId();
|
if (ti->type() == EventType::RoomMessage)
|
||||||
// FIXME: It shouldn't be User, it should be its state "as of event"
|
{
|
||||||
return QVariant::fromValue(m_currentRoom->user(userId));
|
const auto& contentType =
|
||||||
}
|
ti.viewAs<RoomMessageEvent>()->mimeType().name();
|
||||||
|
return contentType == "text/plain" ? "text/html" : contentType;
|
||||||
|
}
|
||||||
|
return "text/plain";
|
||||||
|
}
|
||||||
|
|
||||||
if (role == ContentTypeRole)
|
if (role == ContentRole)
|
||||||
{
|
{
|
||||||
if (is<RoomMessageEvent>(*ti))
|
if (ti->isRedacted())
|
||||||
{
|
{
|
||||||
const auto& contentType =
|
auto reason = ti->redactedBecause()->reason();
|
||||||
ti.viewAs<RoomMessageEvent>()->mimeType().name();
|
if (reason.isEmpty())
|
||||||
return contentType == "text/plain" ? "text/html" : contentType;
|
return tr("Redacted");
|
||||||
}
|
else
|
||||||
return "text/plain";
|
return tr("Redacted: %1")
|
||||||
}
|
.arg(ti->redactedBecause()->reason());
|
||||||
|
}
|
||||||
|
|
||||||
if (role == ContentRole)
|
if( ti->type() == EventType::RoomMessage )
|
||||||
{
|
{
|
||||||
if (ti->isRedacted())
|
using namespace MessageEventContent;
|
||||||
{
|
|
||||||
auto reason = ti->redactedBecause()->reason();
|
|
||||||
return (reason.isEmpty())
|
|
||||||
? tr("Redacted")
|
|
||||||
: tr("Redacted: %1").arg(ti->redactedBecause()->reason());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is<RoomMessageEvent>(*ti))
|
auto* e = ti.viewAs<RoomMessageEvent>();
|
||||||
{
|
switch (e->msgtype())
|
||||||
using namespace MessageEventContent;
|
{
|
||||||
|
case MessageEventType::Image:
|
||||||
|
case MessageEventType::File:
|
||||||
|
case MessageEventType::Audio:
|
||||||
|
case MessageEventType::Video:
|
||||||
|
return QVariant::fromValue(e->content()->originalJson);
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto* e = ti.viewAs<RoomMessageEvent>();
|
if( role == ReadMarkerRole )
|
||||||
switch (e->msgtype())
|
return ti->id() == lastReadEventId;
|
||||||
{
|
|
||||||
case MessageEventType::Image:
|
|
||||||
case MessageEventType::File:
|
|
||||||
case MessageEventType::Audio:
|
|
||||||
case MessageEventType::Video:
|
|
||||||
return QVariant::fromValue(e->content()->originalJson);
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( role == HighlightRole )
|
if( role == SpecialMarksRole )
|
||||||
return QVariant();
|
{
|
||||||
|
if (ti->isStateEvent() && ti.viewAs<StateEventBase>()->repeatsState())
|
||||||
|
return "hidden";
|
||||||
|
return ti->isRedacted() ? "redacted" : "";
|
||||||
|
}
|
||||||
|
|
||||||
if( role == ReadMarkerRole )
|
if( role == EventIdRole )
|
||||||
return ti->id() == lastReadEventId;
|
return ti->id();
|
||||||
|
|
||||||
if( role == SpecialMarksRole )
|
if( role == LongOperationRole )
|
||||||
{
|
{
|
||||||
if (auto e = ti.viewAs<StateEventBase>())
|
if (ti->type() == EventType::RoomMessage &&
|
||||||
if (e->repeatsState())
|
ti.viewAs<RoomMessageEvent>()->hasFileContent())
|
||||||
return "hidden";
|
{
|
||||||
return ti->isRedacted() ? "redacted" : "";
|
auto info = m_currentRoom->fileTransferInfo(ti->id());
|
||||||
}
|
return QVariant::fromValue(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( role == EventIdRole )
|
auto aboveEventIt = timelineIt + 1; // FIXME: shouldn't be here, because #312
|
||||||
return ti->id();
|
if (aboveEventIt != m_currentRoom->timelineEdge())
|
||||||
|
{
|
||||||
|
if( role == AboveSectionRole )
|
||||||
|
return makeDateString(aboveEventIt);
|
||||||
|
|
||||||
if( role == LongOperationRole )
|
if( role == AboveAuthorRole )
|
||||||
{
|
return QVariant::fromValue(
|
||||||
if (is<RoomMessageEvent>(*ti) &&
|
m_currentRoom->user((*aboveEventIt)->senderId()));
|
||||||
ti.viewAs<RoomMessageEvent>()->hasFileContent())
|
}
|
||||||
{
|
|
||||||
auto info = m_currentRoom->fileTransferInfo(ti->id());
|
|
||||||
return QVariant::fromValue(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto aboveEventIt = timelineIt + 1; // FIXME: shouldn't be here, because #312
|
|
||||||
if (aboveEventIt != m_currentRoom->timelineEdge())
|
|
||||||
{
|
|
||||||
if( role == AboveSectionRole )
|
|
||||||
return makeDateString(aboveEventIt);
|
|
||||||
|
|
||||||
if( role == AboveAuthorRole )
|
|
||||||
return QVariant::fromValue(
|
|
||||||
m_currentRoom->user((*aboveEventIt)->senderId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -424,5 +448,5 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
|
||||||
roles[SpecialMarksRole] = "marks";
|
roles[SpecialMarksRole] = "marks";
|
||||||
roles[LongOperationRole] = "progressInfo";
|
roles[LongOperationRole] = "progressInfo";
|
||||||
roles[EventResolvedTypeRole] = "eventResolvedType";
|
roles[EventResolvedTypeRole] = "eventResolvedType";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ class MessageEventModel: public QAbstractListModel
|
||||||
private:
|
private:
|
||||||
QMatrixClient::Room* m_currentRoom = nullptr;
|
QMatrixClient::Room* m_currentRoom = nullptr;
|
||||||
QString lastReadEventId;
|
QString lastReadEventId;
|
||||||
|
int nextNewerRow = -1;
|
||||||
|
|
||||||
QDateTime makeMessageTimestamp(QMatrixClient::Room::rev_iter_t baseIt) const;
|
QDateTime makeMessageTimestamp(QMatrixClient::Room::rev_iter_t baseIt) const;
|
||||||
QString makeDateString(QMatrixClient::Room::rev_iter_t baseIt) const;
|
QString makeDateString(QMatrixClient::Room::rev_iter_t baseIt) const;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import QtQuick 2.10
|
import QtQuick 2.11
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import Matrique 0.1
|
import Matrique 0.1
|
||||||
|
|
|
@ -180,6 +180,8 @@ Item {
|
||||||
}
|
}
|
||||||
highlightMoveDuration: 250
|
highlightMoveDuration: 250
|
||||||
|
|
||||||
|
currentIndex: -1
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar { id: scrollBar }
|
ScrollBar.vertical: ScrollBar { id: scrollBar }
|
||||||
|
|
||||||
model: delegateModel
|
model: delegateModel
|
||||||
|
|
|
@ -16,7 +16,7 @@ Item {
|
||||||
|
|
||||||
background: Item {
|
background: Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: currentRoom === null
|
visible: currentRoom == null
|
||||||
Pane {
|
Pane {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
visible: currentRoom !== null
|
visible: currentRoom != null
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
z: 10
|
z: 10
|
||||||
|
@ -61,7 +61,7 @@ Item {
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: currentRoom !== null ? currentRoom.displayName : ""
|
text: currentRoom != null ? currentRoom.displayName : ""
|
||||||
font.pointSize: 16
|
font.pointSize: 16
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
|
@ -69,7 +69,7 @@ Item {
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: currentRoom !== null ? currentRoom.topic : ""
|
text: currentRoom != null ? currentRoom.topic : ""
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,8 @@ Item {
|
||||||
model: MessageEventModel{
|
model: MessageEventModel{
|
||||||
id: messageEventModel
|
id: messageEventModel
|
||||||
room: currentRoom
|
room: currentRoom
|
||||||
|
|
||||||
|
onModelReset: currentRoom.getPreviousContent(50)
|
||||||
}
|
}
|
||||||
delegate: Row {
|
delegate: Row {
|
||||||
readonly property bool sentByMe: author === currentRoom.localUser
|
readonly property bool sentByMe: author === currentRoom.localUser
|
||||||
|
@ -127,6 +129,10 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar { /*anchors.left: messageListView.right*/ }
|
ScrollBar.vertical: ScrollBar { /*anchors.left: messageListView.right*/ }
|
||||||
|
|
||||||
|
onAtYBeginningChanged: {
|
||||||
|
if(currentRoom && atYBeginning) currentRoom.getPreviousContent(50)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
|
|
Loading…
Reference in New Issue