X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=921258b16030328cef741c8231908136dd5d2fde;hb=9e0b5872dcf290e375c46c016f951c6ea780fcc0;hp=e0f6d6a9f9d523f26d97550e9e1fa9143f3b6007;hpb=dd90a17f0cbafb646e1916d9b8a1f048331f3111;p=quassel.git diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index e0f6d6a9..921258b1 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -27,18 +27,36 @@ #include "chatline.h" #include "qtui.h" -ChatLine::ChatLine(const QPersistentModelIndex &index_, QGraphicsItem *parent) : QGraphicsItem(parent), _index(index_) { +ChatLine::ChatLine(const QModelIndex &index, QGraphicsItem *parent) : QGraphicsItem(parent) { + _timestampItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::TimestampColumn)), this); + _senderItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::SenderColumn)), this); + _contentsItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::ContentsColumn)), this); + _timestampItem->setPos(0,0); } ChatLine::~ChatLine() { - + delete _timestampItem; + delete _senderItem; + delete _contentsItem; } +// FIXME make more efficient by caching width/height QRectF ChatLine::boundingRect () const { return childrenBoundingRect(); } +int ChatLine::setColumnWidths(int ts, int sender, int contents) { + _timestampItem->setWidth(ts); + _senderItem->setWidth(sender); + int h = _contentsItem->setWidth(contents); + + _senderItem->setPos(ts, 0); + _contentsItem->setPos(ts + sender, 0); + + return h; +} + void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { }