added spicy new segfaults
This commit is contained in:
+45
-3
@@ -1,6 +1,10 @@
|
||||
#include "chatwidgetview.h"
|
||||
#include "QScroller"
|
||||
#include "QPainter"
|
||||
#include "word.h"
|
||||
#include "wordpart.h"
|
||||
#include "message.h"
|
||||
|
||||
#include <QScroller>
|
||||
#include <QPainter>
|
||||
|
||||
ChatWidgetView::ChatWidgetView()
|
||||
: QWidget(),
|
||||
@@ -18,6 +22,17 @@ void ChatWidgetView::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
scrollbar.resize(scrollbar.width(), height());
|
||||
scrollbar.move(width() - scrollbar.width(), 0);
|
||||
|
||||
auto c = channel();
|
||||
|
||||
if (c == NULL) return;
|
||||
|
||||
auto messages = c->getMessagesClone();
|
||||
|
||||
for (std::shared_ptr<Message>& message : messages)
|
||||
{
|
||||
message.get()->layout(width(), true);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatWidgetView::paintEvent(QPaintEvent *)
|
||||
@@ -28,7 +43,34 @@ void ChatWidgetView::paintEvent(QPaintEvent *)
|
||||
|
||||
if (c == NULL) return;
|
||||
|
||||
auto M = c->getMessagesClone();
|
||||
auto messages = c->getMessagesClone();
|
||||
|
||||
int y = 0;
|
||||
|
||||
for (std::shared_ptr<Message> const& message : messages)
|
||||
{
|
||||
for (WordPart const& wordPart : message.get()->wordParts())
|
||||
{
|
||||
// image
|
||||
if (wordPart.word().isImage())
|
||||
{
|
||||
LazyLoadedImage& lli = wordPart.word().getImage();
|
||||
|
||||
const QImage* image = lli.image();
|
||||
|
||||
if (image != NULL)
|
||||
{
|
||||
painter.drawImage(QRect(wordPart.x(), wordPart.y() + y, wordPart.width(), wordPart.height()), *image);
|
||||
}
|
||||
}
|
||||
|
||||
// text
|
||||
else
|
||||
{
|
||||
painter.drawText(wordPart.x(), wordPart.y() + y, wordPart.getText());
|
||||
}
|
||||
}
|
||||
|
||||
y += message.get()->height();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user