Make the author line in the bubble and reply be part of the content model
This commit is contained in:
@@ -33,6 +33,7 @@ public:
|
|||||||
* a room message.
|
* a room message.
|
||||||
*/
|
*/
|
||||||
enum Type {
|
enum Type {
|
||||||
|
Author, /**< The message sender and time. */
|
||||||
Text, /**< A text message. */
|
Text, /**< A text message. */
|
||||||
Image, /**< A message that is an image. */
|
Image, /**< A message that is an image. */
|
||||||
Audio, /**< A message that is an audio recording. */
|
Audio, /**< A message that is an audio recording. */
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <Quotient/events/roommessageevent.h>
|
#include <Quotient/events/roommessageevent.h>
|
||||||
#include <Quotient/room.h>
|
#include <Quotient/room.h>
|
||||||
|
|
||||||
|
#include "messagecontentmodel.h"
|
||||||
#include "messageeventmodel.h"
|
#include "messageeventmodel.h"
|
||||||
#include "messagefiltermodel.h"
|
#include "messagefiltermodel.h"
|
||||||
|
|
||||||
@@ -70,6 +71,14 @@ QVariant MediaMessageFilterModel::data(const QModelIndex &index, int role) const
|
|||||||
const auto previousEventDay = mapToSource(this->index(index.row() + 1, 0)).data(MessageEventModel::TimeRole).toDateTime().toLocalTime().date();
|
const auto previousEventDay = mapToSource(this->index(index.row() + 1, 0)).data(MessageEventModel::TimeRole).toDateTime().toLocalTime().date();
|
||||||
return day != previousEventDay;
|
return day != previousEventDay;
|
||||||
}
|
}
|
||||||
|
// Catch and force the author to be shown for all rows
|
||||||
|
if (role == MessageEventModel::ContentModelRole) {
|
||||||
|
const auto model = qvariant_cast<MessageContentModel *>(mapToSource(index).data(MessageEventModel::ContentModelRole));
|
||||||
|
if (model != nullptr) {
|
||||||
|
model->setShowAuthor(true);
|
||||||
|
}
|
||||||
|
return QVariant::fromValue<MessageContentModel *>(model);
|
||||||
|
}
|
||||||
|
|
||||||
return sourceModel()->data(mapToSource(index), role);
|
return sourceModel()->data(mapToSource(index), role);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,14 @@
|
|||||||
|
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
|
|
||||||
|
#include <Quotient/eventitem.h>
|
||||||
#include <Quotient/events/redactionevent.h>
|
#include <Quotient/events/redactionevent.h>
|
||||||
#include <Quotient/events/roommessageevent.h>
|
#include <Quotient/events/roommessageevent.h>
|
||||||
#include <Quotient/events/stickerevent.h>
|
#include <Quotient/events/stickerevent.h>
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <Quotient/qt_connection_util.h>
|
#include <Quotient/qt_connection_util.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef Q_OS_ANDROID
|
||||||
#include <KSyntaxHighlighting/Definition>
|
#include <KSyntaxHighlighting/Definition>
|
||||||
@@ -30,20 +32,22 @@
|
|||||||
|
|
||||||
using namespace Quotient;
|
using namespace Quotient;
|
||||||
|
|
||||||
MessageContentModel::MessageContentModel(NeoChatRoom *room, const Quotient::RoomEvent *event, bool isReply)
|
MessageContentModel::MessageContentModel(NeoChatRoom *room, const Quotient::RoomEvent *event, bool isReply, bool isPending)
|
||||||
: QAbstractListModel(nullptr)
|
: QAbstractListModel(nullptr)
|
||||||
, m_room(room)
|
, m_room(room)
|
||||||
, m_eventId(event != nullptr ? event->id() : QString())
|
, m_eventId(event != nullptr ? event->id() : QString())
|
||||||
, m_event(event)
|
, m_event(event)
|
||||||
|
, m_isPending(isPending)
|
||||||
, m_isReply(isReply)
|
, m_isReply(isReply)
|
||||||
{
|
{
|
||||||
initializeModel();
|
initializeModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageContentModel::MessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply)
|
MessageContentModel::MessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply, bool isPending)
|
||||||
: QAbstractListModel(nullptr)
|
: QAbstractListModel(nullptr)
|
||||||
, m_room(room)
|
, m_room(room)
|
||||||
, m_eventId(eventId)
|
, m_eventId(eventId)
|
||||||
|
, m_isPending(isPending)
|
||||||
, m_isReply(isReply)
|
, m_isReply(isReply)
|
||||||
{
|
{
|
||||||
initializeModel();
|
initializeModel();
|
||||||
@@ -77,6 +81,7 @@ void MessageContentModel::initializeModel()
|
|||||||
if (m_room != nullptr && m_event != nullptr) {
|
if (m_room != nullptr && m_event != nullptr) {
|
||||||
if (m_event->id() == serverEvent->id()) {
|
if (m_event->id() == serverEvent->id()) {
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
m_isPending = false;
|
||||||
m_event = serverEvent;
|
m_event = serverEvent;
|
||||||
Q_EMIT eventUpdated();
|
Q_EMIT eventUpdated();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
@@ -165,6 +170,22 @@ void MessageContentModel::initializeModel()
|
|||||||
updateComponents();
|
updateComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessageContentModel::showAuthor() const
|
||||||
|
{
|
||||||
|
return m_showAuthor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageContentModel::setShowAuthor(bool showAuthor)
|
||||||
|
{
|
||||||
|
if (showAuthor == m_showAuthor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_showAuthor = showAuthor;
|
||||||
|
Q_EMIT showAuthorChanged();
|
||||||
|
updateComponents();
|
||||||
|
}
|
||||||
|
|
||||||
static LinkPreviewer *emptyLinkPreview = new LinkPreviewer;
|
static LinkPreviewer *emptyLinkPreview = new LinkPreviewer;
|
||||||
|
|
||||||
QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
||||||
@@ -207,8 +228,24 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
|
|||||||
if (role == EventIdRole) {
|
if (role == EventIdRole) {
|
||||||
return eventHandler.getId();
|
return eventHandler.getId();
|
||||||
}
|
}
|
||||||
|
if (role == TimeRole) {
|
||||||
|
const auto pendingIt = std::find_if(m_room->pendingEvents().cbegin(), m_room->pendingEvents().cend(), [this](const PendingEventItem &pendingEvent) {
|
||||||
|
return m_event->transactionId() == pendingEvent->transactionId();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto lastUpdated = pendingIt == m_room->pendingEvents().cend() ? QDateTime() : pendingIt->lastUpdated();
|
||||||
|
return eventHandler.getTime(m_isPending, lastUpdated);
|
||||||
|
}
|
||||||
|
if (role == TimeStringRole) {
|
||||||
|
const auto pendingIt = std::find_if(m_room->pendingEvents().cbegin(), m_room->pendingEvents().cend(), [this](const PendingEventItem &pendingEvent) {
|
||||||
|
return m_event->transactionId() == pendingEvent->transactionId();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto lastUpdated = pendingIt == m_room->pendingEvents().cend() ? QDateTime() : pendingIt->lastUpdated();
|
||||||
|
return eventHandler.getTimeString(false, QLocale::ShortFormat, m_isPending, lastUpdated);
|
||||||
|
}
|
||||||
if (role == AuthorRole) {
|
if (role == AuthorRole) {
|
||||||
return QVariant::fromValue(eventHandler.getAuthor(false));
|
return QVariant::fromValue(eventHandler.getAuthor(m_isPending));
|
||||||
}
|
}
|
||||||
if (role == MediaInfoRole) {
|
if (role == MediaInfoRole) {
|
||||||
return eventHandler.getMediaInfo();
|
return eventHandler.getMediaInfo();
|
||||||
@@ -268,6 +305,8 @@ QHash<int, QByteArray> MessageContentModel::roleNames() const
|
|||||||
roles[ComponentTypeRole] = "componentType";
|
roles[ComponentTypeRole] = "componentType";
|
||||||
roles[ComponentAttributesRole] = "componentAttributes";
|
roles[ComponentAttributesRole] = "componentAttributes";
|
||||||
roles[EventIdRole] = "eventId";
|
roles[EventIdRole] = "eventId";
|
||||||
|
roles[TimeRole] = "time";
|
||||||
|
roles[TimeStringRole] = "timeString";
|
||||||
roles[AuthorRole] = "author";
|
roles[AuthorRole] = "author";
|
||||||
roles[MediaInfoRole] = "mediaInfo";
|
roles[MediaInfoRole] = "mediaInfo";
|
||||||
roles[FileTransferInfoRole] = "fileTransferInfo";
|
roles[FileTransferInfoRole] = "fileTransferInfo";
|
||||||
@@ -295,6 +334,10 @@ void MessageContentModel::updateComponents(bool isEditing)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_showAuthor) {
|
||||||
|
m_components += MessageComponent{MessageComponentType::Author, QString(), {}};
|
||||||
|
}
|
||||||
|
|
||||||
if (eventCast<const Quotient::RoomMessageEvent>(m_event)
|
if (eventCast<const Quotient::RoomMessageEvent>(m_event)
|
||||||
&& eventCast<const Quotient::RoomMessageEvent>(m_event)->rawMsgtype() == QStringLiteral("m.key.verification.request")) {
|
&& eventCast<const Quotient::RoomMessageEvent>(m_event)->rawMsgtype() == QStringLiteral("m.key.verification.request")) {
|
||||||
m_components += MessageComponent{MessageComponentType::Verification, QString(), {}};
|
m_components += MessageComponent{MessageComponentType::Verification, QString(), {}};
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ class MessageContentModel : public QAbstractListModel
|
|||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
QML_UNCREATABLE("")
|
QML_UNCREATABLE("")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether the author component is being shown.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(bool showAuthor READ showAuthor WRITE setShowAuthor NOTIFY showAuthorChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Defines the model roles.
|
* @brief Defines the model roles.
|
||||||
@@ -48,6 +53,8 @@ public:
|
|||||||
ComponentTypeRole, /**< The type of component to visualise the message. */
|
ComponentTypeRole, /**< The type of component to visualise the message. */
|
||||||
ComponentAttributesRole, /**< The attributes of the component. */
|
ComponentAttributesRole, /**< The attributes of the component. */
|
||||||
EventIdRole, /**< The matrix event ID of the event. */
|
EventIdRole, /**< The matrix event ID of the event. */
|
||||||
|
TimeRole, /**< The timestamp for when the event was sent (as a QDateTime). */
|
||||||
|
TimeStringRole, /**< The timestamp for when the event was sent as a string (in QLocale::ShortFormat). */
|
||||||
AuthorRole, /**< The author of the event. */
|
AuthorRole, /**< The author of the event. */
|
||||||
MediaInfoRole, /**< The media info for the event. */
|
MediaInfoRole, /**< The media info for the event. */
|
||||||
FileTransferInfoRole, /**< FileTransferInfo for any downloading files. */
|
FileTransferInfoRole, /**< FileTransferInfo for any downloading files. */
|
||||||
@@ -66,8 +73,11 @@ public:
|
|||||||
};
|
};
|
||||||
Q_ENUM(Roles)
|
Q_ENUM(Roles)
|
||||||
|
|
||||||
explicit MessageContentModel(NeoChatRoom *room, const Quotient::RoomEvent *event, bool isReply = false);
|
explicit MessageContentModel(NeoChatRoom *room, const Quotient::RoomEvent *event, bool isReply = false, bool isPending = false);
|
||||||
MessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply = false);
|
MessageContentModel(NeoChatRoom *room, const QString &eventId, bool isReply = false, bool isPending = false);
|
||||||
|
|
||||||
|
bool showAuthor() const;
|
||||||
|
void setShowAuthor(bool showAuthor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the given role value at the given index.
|
* @brief Get the given role value at the given index.
|
||||||
@@ -98,6 +108,7 @@ public:
|
|||||||
Q_INVOKABLE void closeLinkPreview(int row);
|
Q_INVOKABLE void closeLinkPreview(int row);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
void showAuthorChanged();
|
||||||
void eventUpdated();
|
void eventUpdated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -105,6 +116,8 @@ private:
|
|||||||
QString m_eventId;
|
QString m_eventId;
|
||||||
const Quotient::RoomEvent *m_event = nullptr;
|
const Quotient::RoomEvent *m_event = nullptr;
|
||||||
|
|
||||||
|
bool m_isPending;
|
||||||
|
bool m_showAuthor = true;
|
||||||
bool m_isReply;
|
bool m_isReply;
|
||||||
|
|
||||||
void initializeModel();
|
void initializeModel();
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
|
|||||||
roles[DelegateTypeRole] = "delegateType";
|
roles[DelegateTypeRole] = "delegateType";
|
||||||
roles[EventIdRole] = "eventId";
|
roles[EventIdRole] = "eventId";
|
||||||
roles[TimeRole] = "time";
|
roles[TimeRole] = "time";
|
||||||
roles[TimeStringRole] = "timeString";
|
|
||||||
roles[SectionRole] = "section";
|
roles[SectionRole] = "section";
|
||||||
roles[AuthorRole] = "author";
|
roles[AuthorRole] = "author";
|
||||||
roles[HighlightRole] = "isHighlighted";
|
roles[HighlightRole] = "isHighlighted";
|
||||||
@@ -153,7 +152,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
|||||||
}
|
}
|
||||||
if (biggest < m_currentRoom->maxTimelineIndex()) {
|
if (biggest < m_currentRoom->maxTimelineIndex()) {
|
||||||
auto rowBelowInserted = m_currentRoom->maxTimelineIndex() - biggest + timelineBaseIndex() - 1;
|
auto rowBelowInserted = m_currentRoom->maxTimelineIndex() - biggest + timelineBaseIndex() - 1;
|
||||||
refreshEventRoles(rowBelowInserted, {MessageFilterModel::ShowAuthorRole});
|
refreshEventRoles(rowBelowInserted, {ContentModelRole});
|
||||||
}
|
}
|
||||||
for (auto i = m_currentRoom->maxTimelineIndex() - biggest; i <= m_currentRoom->maxTimelineIndex() - lowest; ++i) {
|
for (auto i = m_currentRoom->maxTimelineIndex() - biggest; i <= m_currentRoom->maxTimelineIndex() - lowest; ++i) {
|
||||||
refreshLastUserEvents(i);
|
refreshLastUserEvents(i);
|
||||||
@@ -183,7 +182,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
|||||||
refreshRow(timelineBaseIndex()); // Refresh the looks
|
refreshRow(timelineBaseIndex()); // Refresh the looks
|
||||||
refreshLastUserEvents(0);
|
refreshLastUserEvents(0);
|
||||||
if (timelineBaseIndex() > 0) { // Refresh below, see #312
|
if (timelineBaseIndex() > 0) { // Refresh below, see #312
|
||||||
refreshEventRoles(timelineBaseIndex() - 1, {MessageFilterModel::ShowAuthorRole});
|
refreshEventRoles(timelineBaseIndex() - 1, {ContentModelRole});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(m_currentRoom, &Room::pendingEventChanged, this, &MessageEventModel::refreshRow);
|
connect(m_currentRoom, &Room::pendingEventChanged, this, &MessageEventModel::refreshRow);
|
||||||
@@ -525,11 +524,6 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
|||||||
return eventHandler.getTime(isPending, lastUpdated);
|
return eventHandler.getTime(isPending, lastUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == TimeStringRole) {
|
|
||||||
auto lastUpdated = isPending ? pendingIt->lastUpdated() : QDateTime();
|
|
||||||
return eventHandler.getTimeString(false, QLocale::ShortFormat, isPending, lastUpdated);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role == SectionRole) {
|
if (role == SectionRole) {
|
||||||
auto lastUpdated = isPending ? pendingIt->lastUpdated() : QDateTime();
|
auto lastUpdated = isPending ? pendingIt->lastUpdated() : QDateTime();
|
||||||
return eventHandler.getTimeString(true, QLocale::ShortFormat, isPending, lastUpdated);
|
return eventHandler.getTimeString(true, QLocale::ShortFormat, isPending, lastUpdated);
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public:
|
|||||||
DelegateTypeRole = Qt::UserRole + 1, /**< The delegate type of the message. */
|
DelegateTypeRole = Qt::UserRole + 1, /**< The delegate type of the message. */
|
||||||
EventIdRole, /**< The matrix event ID of the event. */
|
EventIdRole, /**< The matrix event ID of the event. */
|
||||||
TimeRole, /**< The timestamp for when the event was sent (as a QDateTime). */
|
TimeRole, /**< The timestamp for when the event was sent (as a QDateTime). */
|
||||||
TimeStringRole, /**< The timestamp for when the event was sent as a string (in QLocale::ShortFormat). */
|
|
||||||
SectionRole, /**< The date of the event as a string. */
|
SectionRole, /**< The date of the event as a string. */
|
||||||
AuthorRole, /**< The author of the event. */
|
AuthorRole, /**< The author of the event. */
|
||||||
HighlightRole, /**< Whether the event should be highlighted. */
|
HighlightRole, /**< Whether the event should be highlighted. */
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
#include "enums/delegatetype.h"
|
#include "enums/delegatetype.h"
|
||||||
|
#include "messagecontentmodel.h"
|
||||||
#include "messageeventmodel.h"
|
#include "messageeventmodel.h"
|
||||||
#include "neochatconfig.h"
|
#include "neochatconfig.h"
|
||||||
#include "timelinemodel.h"
|
#include "timelinemodel.h"
|
||||||
@@ -91,22 +92,12 @@ QVariant MessageFilterModel::data(const QModelIndex &index, int role) const
|
|||||||
return authorList(mapToSource(index).row());
|
return authorList(mapToSource(index).row());
|
||||||
} else if (role == ExcessAuthorsRole) {
|
} else if (role == ExcessAuthorsRole) {
|
||||||
return excessAuthors(mapToSource(index).row());
|
return excessAuthors(mapToSource(index).row());
|
||||||
} else if (role == ShowAuthorRole) {
|
} else if (role == MessageEventModel::ContentModelRole) {
|
||||||
for (auto r = index.row() + 1; r < rowCount(); ++r) {
|
const auto model = qvariant_cast<MessageContentModel *>(mapToSource(index).data(MessageEventModel::ContentModelRole));
|
||||||
auto i = this->index(r, 0);
|
if (model != nullptr && !showAuthor(index)) {
|
||||||
// Note !itemData(i).empty() is a check for instances where rows have been removed, e.g. when the read marker is moved.
|
model->setShowAuthor(false);
|
||||||
// While the row is removed the subsequent row indexes are not changed so we need to skip over the removed index.
|
|
||||||
// See - https://doc.qt.io/qt-5/qabstractitemmodel.html#beginRemoveRows
|
|
||||||
if (data(i, MessageEventModel::SpecialMarksRole) != EventStatus::Hidden && !itemData(i).empty()) {
|
|
||||||
return data(i, MessageEventModel::AuthorRole) != data(index, MessageEventModel::AuthorRole)
|
|
||||||
|| data(i, MessageEventModel::DelegateTypeRole) == DelegateType::State
|
|
||||||
|| data(i, MessageEventModel::TimeRole).toDateTime().msecsTo(data(index, MessageEventModel::TimeRole).toDateTime()) > 600000
|
|
||||||
|| data(i, MessageEventModel::TimeRole).toDateTime().toLocalTime().date().day()
|
|
||||||
!= data(index, MessageEventModel::TimeRole).toDateTime().toLocalTime().date().day();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return QVariant::fromValue<MessageContentModel *>(model);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return QSortFilterProxyModel::data(index, role);
|
return QSortFilterProxyModel::data(index, role);
|
||||||
}
|
}
|
||||||
@@ -118,10 +109,28 @@ QHash<int, QByteArray> MessageFilterModel::roleNames() const
|
|||||||
roles[StateEventsRole] = "stateEvents";
|
roles[StateEventsRole] = "stateEvents";
|
||||||
roles[AuthorListRole] = "authorList";
|
roles[AuthorListRole] = "authorList";
|
||||||
roles[ExcessAuthorsRole] = "excessAuthors";
|
roles[ExcessAuthorsRole] = "excessAuthors";
|
||||||
roles[ShowAuthorRole] = "showAuthor";
|
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessageFilterModel::showAuthor(QModelIndex index) const
|
||||||
|
{
|
||||||
|
for (auto r = index.row() + 1; r < rowCount(); ++r) {
|
||||||
|
auto i = this->index(r, 0);
|
||||||
|
// Note !itemData(i).empty() is a check for instances where rows have been removed, e.g. when the read marker is moved.
|
||||||
|
// While the row is removed the subsequent row indexes are not changed so we need to skip over the removed index.
|
||||||
|
// See - https://doc.qt.io/qt-5/qabstractitemmodel.html#beginRemoveRows
|
||||||
|
if (data(i, MessageEventModel::SpecialMarksRole) != EventStatus::Hidden && !itemData(i).empty()) {
|
||||||
|
return data(i, MessageEventModel::AuthorRole) != data(index, MessageEventModel::AuthorRole)
|
||||||
|
|| data(i, MessageEventModel::DelegateTypeRole) == DelegateType::State
|
||||||
|
|| data(i, MessageEventModel::TimeRole).toDateTime().msecsTo(data(index, MessageEventModel::TimeRole).toDateTime()) > 600000
|
||||||
|
|| data(i, MessageEventModel::TimeRole).toDateTime().toLocalTime().date().day()
|
||||||
|
!= data(index, MessageEventModel::TimeRole).toDateTime().toLocalTime().date().day();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QString MessageFilterModel::aggregateEventToString(int sourceRow) const
|
QString MessageFilterModel::aggregateEventToString(int sourceRow) const
|
||||||
{
|
{
|
||||||
QStringList parts;
|
QStringList parts;
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public:
|
|||||||
StateEventsRole, /**< List of state events in the aggregated state. */
|
StateEventsRole, /**< List of state events in the aggregated state. */
|
||||||
AuthorListRole, /**< List of the first 5 unique authors of the aggregated state event. */
|
AuthorListRole, /**< List of the first 5 unique authors of the aggregated state event. */
|
||||||
ExcessAuthorsRole, /**< The number of unique authors beyond the first 5. */
|
ExcessAuthorsRole, /**< The number of unique authors beyond the first 5. */
|
||||||
ShowAuthorRole, /**< Whether the author (name and avatar) should be shown at this message. */
|
|
||||||
LastRole, // Keep this last
|
LastRole, // Keep this last
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,6 +61,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool eventIsVisible(int sourceRow, const QModelIndex &sourceParent) const;
|
bool eventIsVisible(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
|
||||||
|
bool showAuthor(QModelIndex index) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Aggregation of the text of consecutive state events starting at row.
|
* @brief Aggregation of the text of consecutive state events starting at row.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -82,8 +82,6 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
|
|||||||
EventHandler eventHandler(m_room, &event);
|
EventHandler eventHandler(m_room, &event);
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case ShowAuthorRole:
|
|
||||||
return true;
|
|
||||||
case AuthorRole:
|
case AuthorRole:
|
||||||
return QVariant::fromValue(eventHandler.getAuthor());
|
return QVariant::fromValue(eventHandler.getAuthor());
|
||||||
case ShowSectionRole:
|
case ShowSectionRole:
|
||||||
@@ -93,10 +91,6 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
|
|||||||
return event.originTimestamp().date() != m_result->results[row - 1].result->originTimestamp().date();
|
return event.originTimestamp().date() != m_result->results[row - 1].result->originTimestamp().date();
|
||||||
case SectionRole:
|
case SectionRole:
|
||||||
return eventHandler.getTimeString(true);
|
return eventHandler.getTimeString(true);
|
||||||
case TimeRole:
|
|
||||||
return eventHandler.getTime();
|
|
||||||
case TimeStringRole:
|
|
||||||
return eventHandler.getTimeString(false);
|
|
||||||
case ShowReactionsRole:
|
case ShowReactionsRole:
|
||||||
return false;
|
return false;
|
||||||
case ShowReadMarkersRole:
|
case ShowReadMarkersRole:
|
||||||
@@ -145,9 +139,6 @@ QHash<int, QByteArray> SearchModel::roleNames() const
|
|||||||
{AuthorRole, "author"},
|
{AuthorRole, "author"},
|
||||||
{ShowSectionRole, "showSection"},
|
{ShowSectionRole, "showSection"},
|
||||||
{SectionRole, "section"},
|
{SectionRole, "section"},
|
||||||
{TimeRole, "time"},
|
|
||||||
{TimeStringRole, "timeString"},
|
|
||||||
{ShowAuthorRole, "showAuthor"},
|
|
||||||
{EventIdRole, "eventId"},
|
{EventIdRole, "eventId"},
|
||||||
{ExcessReadMarkersRole, "excessReadMarkers"},
|
{ExcessReadMarkersRole, "excessReadMarkers"},
|
||||||
{HighlightRole, "isHighlighted"},
|
{HighlightRole, "isHighlighted"},
|
||||||
|
|||||||
@@ -52,12 +52,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
enum Roles {
|
enum Roles {
|
||||||
DelegateTypeRole = Qt::DisplayRole + 1,
|
DelegateTypeRole = Qt::DisplayRole + 1,
|
||||||
ShowAuthorRole,
|
|
||||||
AuthorRole,
|
AuthorRole,
|
||||||
ShowSectionRole,
|
ShowSectionRole,
|
||||||
SectionRole,
|
SectionRole,
|
||||||
TimeRole,
|
|
||||||
TimeStringRole,
|
|
||||||
EventIdRole,
|
EventIdRole,
|
||||||
ExcessReadMarkersRole,
|
ExcessReadMarkersRole,
|
||||||
HighlightRole,
|
HighlightRole,
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ QQC2.ScrollView {
|
|||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MediaMessageFilterModel.Image
|
roleValue: MediaMessageFilterModel.Image
|
||||||
delegate: MessageDelegate {
|
delegate: MessageDelegate {
|
||||||
alwaysShowAuthor: true
|
|
||||||
alwaysFillWidth: true
|
alwaysFillWidth: true
|
||||||
cardBackground: false
|
cardBackground: false
|
||||||
room: root.currentRoom
|
room: root.currentRoom
|
||||||
@@ -60,7 +59,6 @@ QQC2.ScrollView {
|
|||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MediaMessageFilterModel.Video
|
roleValue: MediaMessageFilterModel.Video
|
||||||
delegate: MessageDelegate {
|
delegate: MessageDelegate {
|
||||||
alwaysShowAuthor: true
|
|
||||||
alwaysFillWidth: true
|
alwaysFillWidth: true
|
||||||
cardBackground: false
|
cardBackground: false
|
||||||
room: root.currentRoom
|
room: root.currentRoom
|
||||||
|
|||||||
79
src/timeline/AuthorComponent.qml
Normal file
79
src/timeline/AuthorComponent.qml
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls as QQC2
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
|
import org.kde.neochat
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The message author.
|
||||||
|
*
|
||||||
|
* This should consist of the following:
|
||||||
|
* - id - The matrix ID of the author.
|
||||||
|
* - isLocalUser - Whether the author is the local user.
|
||||||
|
* - avatarSource - The mxc URL for the author's avatar in the current room.
|
||||||
|
* - avatarMediaId - The media ID of the author's avatar.
|
||||||
|
* - avatarUrl - The mxc URL for the author's avatar.
|
||||||
|
* - displayName - The display name of the author.
|
||||||
|
* - display - The name of the author.
|
||||||
|
* - color - The color for the author.
|
||||||
|
* - object - The Quotient::User object for the author.
|
||||||
|
*
|
||||||
|
* @sa Quotient::User
|
||||||
|
*/
|
||||||
|
required property var author
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The timestamp of the message.
|
||||||
|
*/
|
||||||
|
required property var time
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The timestamp of the message as a string.
|
||||||
|
*/
|
||||||
|
required property string timeString
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The maximum width that the bubble's content can be.
|
||||||
|
*/
|
||||||
|
property real maxContentWidth: -1
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: root.maxContentWidth
|
||||||
|
|
||||||
|
implicitHeight: Math.max(nameButton.implicitHeight, timeLabel.implicitHeight)
|
||||||
|
|
||||||
|
QQC2.AbstractButton {
|
||||||
|
id: nameButton
|
||||||
|
Layout.fillWidth: true
|
||||||
|
contentItem: QQC2.Label {
|
||||||
|
text: root.author.disambiguatedName
|
||||||
|
color: root.author.color
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
font.weight: Font.Bold
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
Accessible.name: contentItem.text
|
||||||
|
onClicked: RoomManager.resolveResource(root.author.uri)
|
||||||
|
}
|
||||||
|
QQC2.Label {
|
||||||
|
id: timeLabel
|
||||||
|
text: root.timeString
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
color: Kirigami.Theme.disabledTextColor
|
||||||
|
QQC2.ToolTip.visible: timeHoverHandler.hovered
|
||||||
|
QQC2.ToolTip.text: root.time.toLocaleString(Qt.locale(), Locale.LongFormat)
|
||||||
|
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
id: timeHoverHandler
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,21 +41,6 @@ QQC2.Control {
|
|||||||
*/
|
*/
|
||||||
property var author
|
property var author
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Whether the author should be shown.
|
|
||||||
*/
|
|
||||||
required property bool showAuthor
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timestamp of the message.
|
|
||||||
*/
|
|
||||||
property var time
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timestamp of the message as a string.
|
|
||||||
*/
|
|
||||||
property string timeString
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Whether the message should be highlighted.
|
* @brief Whether the message should be highlighted.
|
||||||
*/
|
*/
|
||||||
@@ -107,45 +92,12 @@ QQC2.Control {
|
|||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
id: contentColumn
|
id: contentColumn
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
RowLayout {
|
|
||||||
id: headerRow
|
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
|
||||||
implicitHeight: Math.max(nameButton.implicitHeight, timeLabel.implicitHeight)
|
|
||||||
visible: root.showAuthor
|
|
||||||
QQC2.AbstractButton {
|
|
||||||
id: nameButton
|
|
||||||
Layout.fillWidth: true
|
|
||||||
contentItem: QQC2.Label {
|
|
||||||
text: root.author.disambiguatedName
|
|
||||||
color: root.author.color
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
font.weight: Font.Bold
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
Accessible.name: contentItem.text
|
|
||||||
onClicked: RoomManager.resolveResource(root.author.uri)
|
|
||||||
}
|
|
||||||
QQC2.Label {
|
|
||||||
id: timeLabel
|
|
||||||
text: root.timeString
|
|
||||||
horizontalAlignment: Text.AlignRight
|
|
||||||
color: Kirigami.Theme.disabledTextColor
|
|
||||||
QQC2.ToolTip.visible: timeHoverHandler.hovered
|
|
||||||
QQC2.ToolTip.text: root.time.toLocaleString(Qt.locale(), Locale.LongFormat)
|
|
||||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
|
||||||
|
|
||||||
HoverHandler {
|
|
||||||
id: timeHoverHandler
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: contentRepeater
|
id: contentRepeater
|
||||||
model: root.contentModel
|
model: root.contentModel
|
||||||
delegate: MessageComponentChooser {
|
delegate: MessageComponentChooser {
|
||||||
room: root.room
|
room: root.room
|
||||||
index: root.index
|
index: root.index
|
||||||
time: root.time
|
|
||||||
actionsHandler: root.actionsHandler
|
actionsHandler: root.actionsHandler
|
||||||
timeline: root.timeline
|
timeline: root.timeline
|
||||||
maxContentWidth: root.maxContentWidth
|
maxContentWidth: root.maxContentWidth
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ qt_add_qml_module(timeline
|
|||||||
SectionDelegate.qml
|
SectionDelegate.qml
|
||||||
MessageComponentChooser.qml
|
MessageComponentChooser.qml
|
||||||
ReplyMessageComponentChooser.qml
|
ReplyMessageComponentChooser.qml
|
||||||
|
AuthorComponent.qml
|
||||||
AudioComponent.qml
|
AudioComponent.qml
|
||||||
CodeComponent.qml
|
CodeComponent.qml
|
||||||
EncryptedComponent.qml
|
EncryptedComponent.qml
|
||||||
@@ -42,6 +43,7 @@ qt_add_qml_module(timeline
|
|||||||
PdfPreviewComponent.qml
|
PdfPreviewComponent.qml
|
||||||
PollComponent.qml
|
PollComponent.qml
|
||||||
QuoteComponent.qml
|
QuoteComponent.qml
|
||||||
|
ReplyAuthorComponent.qml
|
||||||
ReplyComponent.qml
|
ReplyComponent.qml
|
||||||
StateComponent.qml
|
StateComponent.qml
|
||||||
TextComponent.qml
|
TextComponent.qml
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ QQC2.Control {
|
|||||||
/**
|
/**
|
||||||
* @brief The timestamp of the message.
|
* @brief The timestamp of the message.
|
||||||
*/
|
*/
|
||||||
property date time
|
required property var time
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The display text of the message.
|
* @brief The display text of the message.
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ DelegateChooser {
|
|||||||
*/
|
*/
|
||||||
required property var index
|
required property var index
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timestamp of the message.
|
|
||||||
*/
|
|
||||||
required property var time
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ActionsHandler object to use.
|
* @brief The ActionsHandler object to use.
|
||||||
*
|
*
|
||||||
@@ -64,6 +59,13 @@ DelegateChooser {
|
|||||||
|
|
||||||
role: "componentType"
|
role: "componentType"
|
||||||
|
|
||||||
|
DelegateChoice {
|
||||||
|
roleValue: MessageComponentType.Author
|
||||||
|
delegate: AuthorComponent {
|
||||||
|
maxContentWidth: root.maxContentWidth
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Text
|
roleValue: MessageComponentType.Text
|
||||||
delegate: TextComponent {
|
delegate: TextComponent {
|
||||||
@@ -96,7 +98,6 @@ DelegateChooser {
|
|||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Code
|
roleValue: MessageComponentType.Code
|
||||||
delegate: CodeComponent {
|
delegate: CodeComponent {
|
||||||
time: root.time
|
|
||||||
maxContentWidth: root.maxContentWidth
|
maxContentWidth: root.maxContentWidth
|
||||||
onSelectedTextChanged: selectedText => {
|
onSelectedTextChanged: selectedText => {
|
||||||
root.selectedTextChanged(selectedText);
|
root.selectedTextChanged(selectedText);
|
||||||
|
|||||||
@@ -43,16 +43,6 @@ TimelineDelegate {
|
|||||||
*/
|
*/
|
||||||
required property string eventId
|
required property string eventId
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timestamp of the message.
|
|
||||||
*/
|
|
||||||
required property var time
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timestamp of the message as a string.
|
|
||||||
*/
|
|
||||||
required property string timeString
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The message author.
|
* @brief The message author.
|
||||||
*
|
*
|
||||||
@@ -62,21 +52,6 @@ TimelineDelegate {
|
|||||||
*/
|
*/
|
||||||
required property var author
|
required property var author
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Whether the author should be shown.
|
|
||||||
*/
|
|
||||||
required property bool showAuthor
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Whether the author should always be shown.
|
|
||||||
*
|
|
||||||
* This is primarily used when these delegates are used in a filtered list of
|
|
||||||
* events rather than a sequential timeline, e.g. the media model view.
|
|
||||||
*
|
|
||||||
* @note This setting still respects the avatar configuration settings.
|
|
||||||
*/
|
|
||||||
property bool alwaysShowAuthor: false
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The model to visualise the content of the message.
|
* @brief The model to visualise the content of the message.
|
||||||
*/
|
*/
|
||||||
@@ -246,11 +221,11 @@ TimelineDelegate {
|
|||||||
id: mainContainer
|
id: mainContainer
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: root.showAuthor || root.alwaysShowAuthor ? Kirigami.Units.largeSpacing : (Config.compactLayout ? 1 : Kirigami.Units.smallSpacing)
|
Layout.topMargin: root.contentModel.showAuthor ? Kirigami.Units.largeSpacing : (Config.compactLayout ? 1 : Kirigami.Units.smallSpacing)
|
||||||
Layout.leftMargin: Kirigami.Units.smallSpacing
|
Layout.leftMargin: Kirigami.Units.smallSpacing
|
||||||
Layout.rightMargin: Kirigami.Units.smallSpacing
|
Layout.rightMargin: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
implicitHeight: Math.max(root.showAuthor || root.alwaysShowAuthor ? avatar.implicitHeight : 0, bubble.height)
|
implicitHeight: Math.max(root.contentModel.showAuthor ? avatar.implicitHeight : 0, bubble.height)
|
||||||
|
|
||||||
// show hover actions
|
// show hover actions
|
||||||
onHoveredChanged: {
|
onHoveredChanged: {
|
||||||
@@ -270,7 +245,7 @@ TimelineDelegate {
|
|||||||
topMargin: Kirigami.Units.smallSpacing
|
topMargin: Kirigami.Units.smallSpacing
|
||||||
}
|
}
|
||||||
|
|
||||||
visible: (root.showAuthor || root.alwaysShowAuthor) && Config.showAvatarInTimeline && (Config.compactLayout || !_private.showUserMessageOnRight)
|
visible: root.contentModel.showAuthor && Config.showAvatarInTimeline && (Config.compactLayout || !_private.showUserMessageOnRight)
|
||||||
name: root.author.displayName
|
name: root.author.displayName
|
||||||
source: root.author.avatarUrl
|
source: root.author.avatarUrl
|
||||||
color: root.author.color
|
color: root.author.color
|
||||||
@@ -316,9 +291,6 @@ TimelineDelegate {
|
|||||||
index: root.index
|
index: root.index
|
||||||
|
|
||||||
author: root.author
|
author: root.author
|
||||||
showAuthor: root.showAuthor || root.alwaysShowAuthor
|
|
||||||
time: root.time
|
|
||||||
timeString: root.timeString
|
|
||||||
|
|
||||||
contentModel: root.contentModel
|
contentModel: root.contentModel
|
||||||
actionsHandler: root.ListView.view?.actionsHandler ?? null
|
actionsHandler: root.ListView.view?.actionsHandler ?? null
|
||||||
|
|||||||
61
src/timeline/ReplyAuthorComponent.qml
Normal file
61
src/timeline/ReplyAuthorComponent.qml
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls as QQC2
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import org.kde.kirigami as Kirigami
|
||||||
|
import org.kde.kirigamiaddons.labs.components as KirigamiComponents
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The message author.
|
||||||
|
*
|
||||||
|
* This should consist of the following:
|
||||||
|
* - id - The matrix ID of the author.
|
||||||
|
* - isLocalUser - Whether the author is the local user.
|
||||||
|
* - avatarSource - The mxc URL for the author's avatar in the current room.
|
||||||
|
* - avatarMediaId - The media ID of the author's avatar.
|
||||||
|
* - avatarUrl - The mxc URL for the author's avatar.
|
||||||
|
* - displayName - The display name of the author.
|
||||||
|
* - display - The name of the author.
|
||||||
|
* - color - The color for the author.
|
||||||
|
* - object - The Quotient::User object for the author.
|
||||||
|
*
|
||||||
|
* @sa Quotient::User
|
||||||
|
*/
|
||||||
|
required property var author
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The maximum width that the bubble's content can be.
|
||||||
|
*/
|
||||||
|
property real maxContentWidth: -1
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: root.maxContentWidth
|
||||||
|
|
||||||
|
implicitHeight: Math.max(replyAvatar.implicitHeight, replyName.implicitHeight)
|
||||||
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
KirigamiComponents.Avatar {
|
||||||
|
id: replyAvatar
|
||||||
|
|
||||||
|
implicitWidth: Kirigami.Units.iconSizes.small
|
||||||
|
implicitHeight: Kirigami.Units.iconSizes.small
|
||||||
|
|
||||||
|
source: root.author.avatarUrl
|
||||||
|
name: root.author.displayName
|
||||||
|
color: root.author.color
|
||||||
|
}
|
||||||
|
QQC2.Label {
|
||||||
|
id: replyName
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
color: root.author.color
|
||||||
|
text: root.author.disambiguatedName
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,31 +66,6 @@ RowLayout {
|
|||||||
id: contentColumn
|
id: contentColumn
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: headerRow
|
|
||||||
implicitHeight: Math.max(replyAvatar.implicitHeight, replyName.implicitHeight)
|
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
|
||||||
spacing: Kirigami.Units.largeSpacing
|
|
||||||
|
|
||||||
KirigamiComponents.Avatar {
|
|
||||||
id: replyAvatar
|
|
||||||
|
|
||||||
implicitWidth: Kirigami.Units.iconSizes.small
|
|
||||||
implicitHeight: Kirigami.Units.iconSizes.small
|
|
||||||
|
|
||||||
source: root.replyAuthor.avatarUrl
|
|
||||||
name: root.replyAuthor.displayName
|
|
||||||
color: root.replyAuthor.color
|
|
||||||
}
|
|
||||||
QQC2.Label {
|
|
||||||
id: replyName
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
color: root.replyAuthor.color
|
|
||||||
text: root.replyAuthor.displayName
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: contentRepeater
|
id: contentRepeater
|
||||||
model: root.replyContentModel
|
model: root.replyContentModel
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ DelegateChooser {
|
|||||||
|
|
||||||
role: "componentType"
|
role: "componentType"
|
||||||
|
|
||||||
|
DelegateChoice {
|
||||||
|
roleValue: MessageComponentType.Author
|
||||||
|
delegate: ReplyAuthorComponent {
|
||||||
|
maxContentWidth: root.maxContentWidth
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Text
|
roleValue: MessageComponentType.Text
|
||||||
delegate: TextComponent {
|
delegate: TextComponent {
|
||||||
|
|||||||
Reference in New Issue
Block a user