seems like i have found solution how to properly render buttons

This commit is contained in:
Blue 2021-02-02 01:55:15 +03:00
parent 00ffbac6b0
commit b3c6860e25
7 changed files with 196 additions and 41 deletions

View file

@ -31,6 +31,7 @@ const QHash<int, QByteArray> Models::MessageFeed::roles = {
{SentByMe,"sentByMe"},
{Avatar, "avatar"},
{Attach, "attach"},
{Id, "id"},
{Bulk, "bulk"}
};
@ -94,8 +95,12 @@ QVariant Models::MessageFeed::data(const QModelIndex& index, int role) const
switch (role) {
case Qt::DisplayRole:
case Text:
answer = msg->getBody();
case Text: {
QString body = msg->getBody();
if (body != msg->getOutOfBandUrl()) {
answer = body;
}
}
break;
case Sender:
if (sentByMe(*msg)) {
@ -143,13 +148,22 @@ QVariant Models::MessageFeed::data(const QModelIndex& index, int role) const
case Attach:
answer.setValue(fillAttach(*msg));
break;
case Id:
answer.setValue(msg->getId());
break;
case Bulk: {
FeedItem item;
item.id = msg->getId();
item.sentByMe = sentByMe(*msg);
item.date = msg->getTime();
item.state = msg->getState();
item.correction = msg->getEdited();
item.text = msg->getBody();
QString body = msg->getBody();
if (body != msg->getOutOfBandUrl()) {
item.text = body;
}
item.avatar.clear();
if (item.sentByMe) {
item.sender = rosterItem->getAccountName();

View file

@ -76,6 +76,7 @@ public:
SentByMe,
Avatar,
Attach,
Id,
Bulk
};
@ -146,6 +147,7 @@ struct Attachment {
};
struct FeedItem {
QString id;
QString text;
QString sender;
QString avatar;