X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=cf3c3fa3e75202e3b96dca1cd4af2f7d3697ecad;hp=1abfcfb2eb8b39dc227ef0e9fd4cd011ff31f2bb;hb=da2b5b2e4e2b0ea1847a0a5f0cb4a3752fc655c9;hpb=0b9f74984780aacbe85ca04c44ec6304c86557c2 diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index 1abfcfb2..cf3c3fa3 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -27,24 +27,39 @@ #include "chatline.h" #include "qtui.h" -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); +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); - _senderItem->setPos(80, 0); - _contentsItem->setPos(160, 0); + _timestampItem->setPos(0,0); + _width = _height = 0; } -Chatline::~Chatline() { +ChatLine::~ChatLine() { + delete _timestampItem; + delete _senderItem; + delete _contentsItem; +} +QRectF ChatLine::boundingRect () const { + //return childrenBoundingRect(); + return QRectF(0, 0, _width, _height); } -QRectF Chatline::boundingRect () const { - return childrenBoundingRect(); +int ChatLine::setColumnWidths(int ts, int sender, int contents) { + _timestampItem->setWidth(ts); + _senderItem->setWidth(sender); + _height = _contentsItem->setWidth(contents); + + _senderItem->setPos(ts, 0); + _contentsItem->setPos(ts + sender, 0); + + _width = ts + sender + contents; + return _height; } -void Chatline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { +void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { }