X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=cf3c3fa3e75202e3b96dca1cd4af2f7d3697ecad;hp=c3e08b9e2cd00b5e5281443db53cd0d0dad6dc19;hb=da2b5b2e4e2b0ea1847a0a5f0cb4a3752fc655c9;hpb=32b5e6447458a8e6e8074c40988b2d06f327094f diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index c3e08b9e..cf3c3fa3 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -18,22 +18,81 @@ * 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 Message &msg) : MessageItem(msg) { - _msg = msg; +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); + _width = _height = 0; +} +ChatLine::~ChatLine() { + delete _timestampItem; + delete _senderItem; + delete _contentsItem; } +QRectF ChatLine::boundingRect () const { + //return childrenBoundingRect(); + return QRectF(0, 0, _width, _height); +} + +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); -QVariant Chatline::data(int column, int role) const { - switch(role) { - case MessageModel::DisplayRole: return _msg.text(); - default: return MessageItem::data(column, role); + _width = ts + sender + contents; + return _height; +} + +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::setData(int column, const QVariant &value, int role) { + +bool ChatLine::sceneEvent ( QEvent * event ) { + qDebug() <<(void*)this<< "receiving event"; + event->ignore(); return false; } +*/ + +