X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=17189f949bd75bdc32d3654edbf2056357dd935d;hp=6efe8c2a56187fad0dc81368800b764cfd7a906a;hb=3197b8b309f09ac1f4db54fa8fa819e33b87383e;hpb=b9e68646b3404fd99adb94773821467da98b0c7b diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 6efe8c2a..17189f94 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -60,19 +60,21 @@ int ChatItem::heightForWidth(int width) { if(data(ChatLineModel::ColumnTypeRole).toUInt() != ChatLineModel::ContentsColumn) return _lineHeight; // only contents can be multi-line - QVariantList wrapList = data(ChatLineModel::WrapListRole).toList(); + ChatLineModel::WrapList wrapList = data(ChatLineModel::WrapListRole).value(); int lines = 1; - int offset = 0; - for(int i = 0; i < wrapList.count(); i+=2) { - if(wrapList.at(i+1).toUInt() - offset < width) continue; + qreal w = 0; + for(int i = 0; i < wrapList.count(); i++) { + w += wrapList.at(i).width; + if(w <= width) { + w += wrapList.at(i).trailing; + continue; + } lines++; - if(i > 0) { - if(offset < wrapList.at(i-1).toUInt()) offset = wrapList.at(i-1).toUInt(); - else offset += width; - } else { - offset += width; + w = wrapList.at(i).width; + while(w >= width) { + lines++; + w -= width; } - i-=2; } return lines * _lineHeight; } @@ -126,6 +128,12 @@ void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, layout(); _layout->draw(painter, QPointF(0,0), QVector(), boundingRect()); painter->drawRect(boundingRect()); + int width = 0; + QVariantList wrapList = data(ChatLineModel::WrapListRole).toList(); + for(int i = 2; i < wrapList.count(); i+=2) { + QRect r(wrapList[i-1].toUInt(), 0, wrapList[i+1].toUInt() - wrapList[i-1].toUInt(), _lineHeight); + painter->drawRect(r); + } } /*