X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=cf3c3fa3e75202e3b96dca1cd4af2f7d3697ecad;hb=487625a3efd8659de77c54a2c1a70e08d22b00e7;hp=ef59fc48622c7b63a2addfed1f1fdf64bd591aa3;hpb=22f141be889377b07472bb967d92186dad23be3e;p=quassel.git diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index ef59fc48..cf3c3fa3 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -18,18 +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 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); +} -Chatline::Chatline(const Message &msg) : MessageItem(msg) { +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) { -QVariant Chatline::data(int column, int role) const { - return MessageItem::data(column, role); } -bool Chatline::setData(int column, const QVariant &value, int role) { +/* +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; } +*/ + +