+ _boundingRect.setHeight(h);
+ return h;
+}
+
+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();
+ int lines = 1;
+ int offset = 0;
+ for(int i = 0; i < wrapList.count(); i+=2) {
+ if(wrapList.at(i+1).toUInt() - offset < width) continue;
+ lines++;
+ if(i > 0) {
+ if(offset != wrapList.at(i-1).toUInt()) offset = wrapList.at(i-1).toUInt();
+ else offset += width;
+ } else {
+ offset += width;
+ }
+ i-=2;
+ }
+ return lines * _lineHeight;