forked from blue/squawk
merge conflicts, text copying from context menu in message line
This commit is contained in:
commit
c3a45ec58c
38 changed files with 1221 additions and 798 deletions
|
@ -664,9 +664,32 @@ int MessageDelegate::paintBody(const Models::FeedItem& data, QPainter* painter,
|
|||
if (data.text.size() > 0) {
|
||||
bodyRenderer->setHtml(Shared::processMessageBody(data.text));
|
||||
bodyRenderer->setTextWidth(option.rect.size().width());
|
||||
painter->setBackgroundMode(Qt::BGMode::OpaqueMode);
|
||||
painter->save();
|
||||
// QTextCursor cursor(bodyRenderer);
|
||||
// cursor.setPosition(2, QTextCursor::KeepAnchor);
|
||||
painter->translate(option.rect.topLeft());
|
||||
// QTextFrameFormat format = bodyRenderer->rootFrame()->frameFormat();
|
||||
// format.setBackground(option.palette.brush(QPalette::Active, QPalette::Highlight));
|
||||
// bodyRenderer->rootFrame()->setFrameFormat(format);
|
||||
bodyRenderer->drawContents(painter);
|
||||
// QColor c = option.palette.color(QPalette::Active, QPalette::Highlight);
|
||||
// QTextBlock b = bodyRenderer->begin();
|
||||
// QTextBlockFormat format = b.blockFormat();
|
||||
// format.setBackground(option.palette.brush(QPalette::Active, QPalette::Highlight));
|
||||
// format.setProperty(QTextFormat::BackgroundBrush, option.palette.brush(QPalette::Active, QPalette::Highlight));
|
||||
// QTextCursor cursor(bodyRenderer);
|
||||
// cursor.setBlockFormat(format);
|
||||
// b = bodyRenderer->begin();
|
||||
// while (b.isValid() > 0) {
|
||||
// QTextLayout* lay = b.layout();
|
||||
// QTextLayout::FormatRange range;
|
||||
// range.format = b.charFormat();
|
||||
// range.start = 0;
|
||||
// range.length = 2;
|
||||
// lay->draw(painter, option.rect.topLeft(), {range});
|
||||
// b = b.next();
|
||||
// }
|
||||
painter->restore();
|
||||
QSize bodySize(std::ceil(bodyRenderer->idealWidth()), std::ceil(bodyRenderer->size().height()));
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QProgressBar>
|
||||
#include <QLabel>
|
||||
#include <QTextDocument>
|
||||
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
|
|
|
@ -163,6 +163,12 @@ void Models::MessageFeed::changeMessage(const QString& id, const QMap<QString, Q
|
|||
}
|
||||
|
||||
emit dataChanged(index, index, cr);
|
||||
|
||||
if (observersAmount == 0 && !msg->getForwarded() && changeRoles.count(MessageRoles::Text) > 0) {
|
||||
unreadMessages->insert(id);
|
||||
emit unreadMessagesCountChanged();
|
||||
emit unnoticedMessage(*msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,12 +318,7 @@ QVariant Models::MessageFeed::data(const QModelIndex& index, int role) const
|
|||
case Bulk: {
|
||||
FeedItem item;
|
||||
item.id = msg->getId();
|
||||
|
||||
std::set<QString>::const_iterator umi = unreadMessages->find(item.id);
|
||||
if (umi != unreadMessages->end()) {
|
||||
unreadMessages->erase(umi);
|
||||
emit unreadMessagesCountChanged();
|
||||
}
|
||||
markMessageAsRead(item.id);
|
||||
|
||||
item.sentByMe = sentByMe(*msg);
|
||||
item.date = msg->getTime();
|
||||
|
@ -367,6 +368,17 @@ int Models::MessageFeed::rowCount(const QModelIndex& parent) const
|
|||
return storage.size();
|
||||
}
|
||||
|
||||
bool Models::MessageFeed::markMessageAsRead(const QString& id) const
|
||||
{
|
||||
std::set<QString>::const_iterator umi = unreadMessages->find(id);
|
||||
if (umi != unreadMessages->end()) {
|
||||
unreadMessages->erase(umi);
|
||||
emit unreadMessagesCountChanged();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int Models::MessageFeed::unreadMessagesCount() const
|
||||
{
|
||||
return unreadMessages->size();
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
void reportLocalPathInvalid(const QString& messageId);
|
||||
|
||||
unsigned int unreadMessagesCount() const;
|
||||
bool markMessageAsRead(const QString& id) const;
|
||||
void fileProgress(const QString& messageId, qreal value, bool up);
|
||||
void fileError(const QString& messageId, const QString& error, bool up);
|
||||
void fileComplete(const QString& messageId, bool up);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue