X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=237fad68fbae63aaca7570a1caebeae046f14676;hp=921258b16030328cef741c8231908136dd5d2fde;hb=39e2a78383295f86c5aa2dadbeac6f02b53eb7a4;hpb=9e0b5872dcf290e375c46c016f951c6ea780fcc0 diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index 921258b1..237fad68 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -33,6 +33,7 @@ ChatLine::ChatLine(const QModelIndex &index, QGraphicsItem *parent) : QGraphicsI _contentsItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::ContentsColumn)), this); _timestampItem->setPos(0,0); + _width = _height = 0; } ChatLine::~ChatLine() { @@ -41,56 +42,27 @@ ChatLine::~ChatLine() { delete _contentsItem; } -// FIXME make more efficient by caching width/height QRectF ChatLine::boundingRect () const { - return childrenBoundingRect(); + //return childrenBoundingRect(); + return QRectF(0, 0, _width, _height); } -int ChatLine::setColumnWidths(int ts, int sender, int contents) { - _timestampItem->setWidth(ts); - _senderItem->setWidth(sender); - int h = _contentsItem->setWidth(contents); +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; - _senderItem->setPos(ts, 0); - _contentsItem->setPos(ts + sender, 0); + _timestampItem->setWidth(firstHandlePos - firstsep); + _senderItem->setWidth(secondHandlePos - firstHandlePos - (firstsep+secondsep)); + _height = _contentsItem->setWidth(width - secondHandlePos - secondsep); - return h; -} - -void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - -} + _senderItem->setPos(firstHandlePos + firstsep, 0); + _contentsItem->setPos(secondHandlePos + secondsep, 0); -/* -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)); + _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; } -*/ - -