1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/**************************************************************************
* *
* SPDX-FileCopyrightText: 2015 Felix Rohrbach <kde@fxrh.de> *
* *
* SPDX-License-Identifier: GPL-3.0-or-later
* *
**************************************************************************/
#pragma once
#include "../quaternionroom.h"
#include <QtCore/QAbstractListModel>
class MessageEventModel: public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QuaternionRoom* room READ room NOTIFY roomChanged)
Q_PROPERTY(int readMarkerVisualIndex READ readMarkerVisualIndex NOTIFY readMarkerUpdated)
public:
enum EventRoles {
EventTypeRole = Qt::UserRole + 1,
EventIdRole,
DateTimeRole,
DateRole,
EventGroupingRole,
AuthorRole,
AuthorHasAvatarRole,
ContentRole,
ContentTypeRole,
RepliedToRole,
HighlightRole,
SpecialMarksRole,
LongOperationRole,
AnnotationRole,
RefRole,
ReactionsRole,
EventClassNameRole,
VerificationStateRole,
};
explicit MessageEventModel(QObject* parent = nullptr);
QuaternionRoom* room() const;
void changeRoom(QuaternionRoom* room);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
int findRow(const QString& id, bool includePending = false) const;
Q_INVOKABLE QColor fadedBackColor(QColor unfadedColor, qreal fadeRatio = 0.5) const;
signals:
void roomChanged();
/// This is different from Room::readMarkerMoved() in that it is also
/// emitted when the room or the last read event is first shown
void readMarkerUpdated();
private slots:
int refreshEvent(const QString& eventId);
void refreshRow(int row);
void incomingEvents(Quotient::RoomEventsRange events, int atIndex);
private:
QuaternionRoom* m_currentRoom = nullptr;
int readMarkerVisualIndex() const;
bool movingEvent = false;
int timelineBaseIndex() const;
QDateTime makeMessageTimestamp(const QuaternionRoom::rev_iter_t& baseIt) const;
static QString renderDate(const QDateTime& timestamp);
bool isUserActivityNotable(const QuaternionRoom::rev_iter_t& baseIt) const;
void refreshLastUserEvents(int baseTimelineRow);
void refreshEventRoles(int row, const QVector<int>& roles = {});
QString visualiseEvent(const Quotient::RoomEvent& evt, bool abbreviate = false) const;
};
struct EventForQml {
Quotient::EventId eventId;
Quotient::RoomMember sender;
QString content;
Q_GADGET
Q_PROPERTY(Quotient::EventId eventId MEMBER eventId FINAL)
Q_PROPERTY(Quotient::RoomMember sender MEMBER sender FINAL)
Q_PROPERTY(QString content MEMBER content FINAL)
};
namespace EventGrouping {
Q_NAMESPACE
enum Values {
KeepPreviousGroup = 0,
ShowAuthor = 1,
ShowDateAndAuthor = 2
};
Q_ENUM_NS(Values)
}
namespace VerificationState {
Q_NAMESPACE
enum Values {
Unverified = 0,
Verified = 1,
NotRelevant = 2, //!< Unencrypted messages
};
Q_ENUM_NS(Values)
}
|