X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=921258b16030328cef741c8231908136dd5d2fde;hp=edb89f14e9f2411e688abaf4f0a90660de637821;hb=9e0b5872dcf290e375c46c016f951c6ea780fcc0;hpb=f3fc0324c8860dff6af722dafbeb05fcb69a0c41 diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index edb89f14..921258b1 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -18,11 +18,79 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include +#include +#include + +#include "bufferinfo.h" +#include "chatitem.h" #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); + + _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); -Chatline::Chatline(const QMessage &msg) : MessageItem(msg) { + _senderItem->setPos(ts, 0); + _contentsItem->setPos(ts + sender, 0); + + return h; +} + +void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + +} + +/* +void ChatLine::setColumnWidths(int tsColWidth, int senderColWidth, int textColWidth) { + if(tsColWidth >= 0) { + _tsColWidth = tsColWidth; + _tsItem->setWidth(tsColWidth); + } + if(senderColWidth >= 0) { + _senderColWidth = senderColWidth; + _senderItem->setWidth(senderColWidth); + } + if(textColWidth >= 0) { + _textColWidth = textColWidth; + _textItem->setWidth(textColWidth); + } + layout(); +} + +void ChatLine::layout() { + prepareGeometryChange(); + _tsItem->setPos(QPointF(0, 0)); + _senderItem->setPos(QPointF(_tsColWidth + QtUi::style()->sepTsSender(), 0)); + _textItem->setPos(QPointF(_tsColWidth + QtUi::style()->sepTsSender() + _senderColWidth + QtUi::style()->sepSenderText(), 0)); +} +bool ChatLine::sceneEvent ( QEvent * event ) { + qDebug() <<(void*)this<< "receiving event"; + event->ignore(); + return false; } +*/