X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=b52fe3f0bc09848d53d9759588292e1bd36c859d;hb=8f9c35aefb50a0e1626907e19da87bdb107123b4;hp=2297983be2af8217c3e9d72f07c49495515003cf;hpb=c6a6c0e4317986792320826956fd5ead2b3e9e67;p=quassel.git diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 2297983b..b52fe3f0 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -387,19 +387,22 @@ ContentsChatItemPrivate *ContentsChatItem::privateData() const { } qreal ContentsChatItem::setGeometryByWidth(qreal w) { - if(w != width()) { + // We use this for reloading layout info as well, so we can't bail out if the width doesn't change + + // compute height + int lines = 1; + WrapColumnFinder finder(this); + while(finder.nextWrapColumn(w) > 0) + lines++; + qreal h = lines * fontMetrics()->lineSpacing(); + delete _data; + _data = 0; + + if(w != width() || h != height()) { prepareGeometryChange(); - setWidth(w); - // compute height - int lines = 1; - WrapColumnFinder finder(this); - while(finder.nextWrapColumn() > 0) - lines++; - setHeight(lines * fontMetrics()->lineSpacing()); - delete _data; - _data = 0; + setGeometry(w, h); } - return height(); + return h; } void ContentsChatItem::doLayout(QTextLayout *layout) const { @@ -414,7 +417,7 @@ void ContentsChatItem::doLayout(QTextLayout *layout) const { if(!line.isValid()) break; - int col = finder.nextWrapColumn(); + int col = finder.nextWrapColumn(width()); line.setNumColumns(col >= 0 ? col - line.textStart() : layout->text().length()); line.setPosition(QPointF(0, h)); h += fontMetrics()->lineSpacing(); @@ -696,12 +699,12 @@ ContentsChatItem::WrapColumnFinder::WrapColumnFinder(const ChatItem *_item) ContentsChatItem::WrapColumnFinder::~WrapColumnFinder() { } -qint16 ContentsChatItem::WrapColumnFinder::nextWrapColumn() { +qint16 ContentsChatItem::WrapColumnFinder::nextWrapColumn(qreal width) { if(wordidx >= wrapList.count()) return -1; lineCount++; - qreal targetWidth = lineCount * item->width() + choppedTrailing; + qreal targetWidth = lineCount * width + choppedTrailing; qint16 start = wordidx; qint16 end = wrapList.count() - 1;