X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=237fad68fbae63aaca7570a1caebeae046f14676;hp=e0f6d6a9f9d523f26d97550e9e1fa9143f3b6007;hb=39e2a78383295f86c5aa2dadbeac6f02b53eb7a4;hpb=dd90a17f0cbafb646e1916d9b8a1f048331f3111 diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index e0f6d6a9..237fad68 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -27,52 +27,42 @@ #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); + _width = _height = 0; } ChatLine::~ChatLine() { - + delete _timestampItem; + delete _senderItem; + delete _contentsItem; } QRectF ChatLine::boundingRect () const { - return childrenBoundingRect(); + //return childrenBoundingRect(); + return QRectF(0, 0, _width, _height); } -void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { +qreal ChatLine::setGeometry(qreal width, qreal firstHandlePos, qreal secondHandlePos) { + if(width != _width) prepareGeometryChange(); + qreal firstsep = QtUi::style()->firstColumnSeparator()/2; + qreal secondsep = QtUi::style()->secondColumnSeparator()/2; -} + _timestampItem->setWidth(firstHandlePos - firstsep); + _senderItem->setWidth(secondHandlePos - firstHandlePos - (firstsep+secondsep)); + _height = _contentsItem->setWidth(width - secondHandlePos - secondsep); -/* -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(); -} + _senderItem->setPos(firstHandlePos + firstsep, 0); + _contentsItem->setPos(secondHandlePos + secondsep, 0); -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)); + _width = width; + return _height; } +void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { -bool ChatLine::sceneEvent ( QEvent * event ) { - qDebug() <<(void*)this<< "receiving event"; - event->ignore(); - return false; } -*/ - -