fixed message expanding not working

This commit is contained in:
fourtf 2018-05-25 12:45:18 +02:00
parent d775123ed0
commit f72e1b5d82
3 changed files with 24 additions and 19 deletions

View file

@ -80,6 +80,10 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
layoutRequired |= timestampFormatChanged;
// check if layout was requested manually
layoutRequired |= bool(this->flags & RequiresLayout);
this->flags &= ~RequiresLayout;
// check if dpi changed
bool scaleChanged = this->scale != scale;
layoutRequired |= scaleChanged;
@ -122,7 +126,7 @@ void MessageLayout::actuallyLayout(int width, MessageElement::Flags _flags)
if (this->flags & MessageLayout::Expanded ||
(_flags & MessageElement::ModeratorTools &&
!(this->message->flags & Message::MessageFlags::Disabled))) {
messageFlags = (Message::MessageFlags)(messageFlags & ~Message::MessageFlags::Collapsed);
messageFlags = Message::MessageFlags(messageFlags & ~Message::MessageFlags::Collapsed);
}
this->container.begin(width, this->scale, messageFlags);
@ -209,7 +213,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
this->bufferValid = true;
}
void MessageLayout::updateBuffer(QPixmap *buffer, int messageIndex, Selection &selection)
void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/, Selection & /*selection*/)
{
auto app = getApp();

View file

@ -11,9 +11,10 @@
#define MARK(x) \
qDebug() << BOOST_CURRENT_FUNCTION << __LINE__ \
<< static_cast<float>(x.nsecsElapsed()) / 100000.0 << "ms";
<< static_cast<float>(x.nsecsElapsed()) / 1000000.0 << "ms";
class BenchmarkGuard : boost::noncopyable {
class BenchmarkGuard : boost::noncopyable
{
QElapsedTimer timer;
QString name;
@ -24,11 +25,13 @@ public:
timer.start();
}
~BenchmarkGuard() {
qDebug() << this->name << float(timer.nsecsElapsed()) / 100000.0 << "ms";
~BenchmarkGuard()
{
qDebug() << this->name << float(timer.nsecsElapsed()) / 1000000.0f << "ms";
}
qreal getElapsedMs() {
return qreal(timer.nsecsElapsed()) / 100000.0;
qreal getElapsedMs()
{
return qreal(timer.nsecsElapsed()) / 1000000.0;
}
};

View file

@ -175,9 +175,10 @@ void ChannelView::layoutMessages()
void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
{
BenchmarkGuard benchmark("layout messages");
auto app = getApp();
BENCH(timer)
auto messagesSnapshot = this->getMessagesSnapshot();
if (messagesSnapshot.getLength() == 0) {
@ -264,8 +265,6 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
this->messageWasAdded = false;
}
MARK(timer);
if (redrawRequired) {
this->queueUpdate();
}
@ -580,7 +579,7 @@ bool ChannelView::isPaused()
void ChannelView::paintEvent(QPaintEvent * /*event*/)
{
BENCH(timer);
BenchmarkGuard benchmark("paint event");
QPainter painter(this);
@ -588,8 +587,6 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
// draw messages
this->drawMessages(painter);
MARK(timer);
}
// if overlays is false then it draws the message, if true then it draws things such as the grey
@ -600,14 +597,14 @@ void ChannelView::drawMessages(QPainter &painter)
auto messagesSnapshot = this->getMessagesSnapshot();
size_t start = this->scrollBar.getCurrentValue();
size_t start = size_t(this->scrollBar.getCurrentValue());
if (start >= messagesSnapshot.getLength()) {
return;
}
int y = -(messagesSnapshot[start].get()->getHeight() *
(fmod(this->scrollBar.getCurrentValue(), 1)));
int y = int(-(messagesSnapshot[start].get()->getHeight() *
(fmod(this->scrollBar.getCurrentValue(), 1))));
messages::MessageLayout *end = nullptr;
bool windowFocused = this->window() == QApplication::activeWindow();
@ -925,6 +922,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
// message under cursor is collapsed
if (layout->flags & MessageLayout::Collapsed) {
layout->flags |= MessageLayout::Expanded;
layout->flags |= MessageLayout::RequiresLayout;
this->layoutMessages();
return;