X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=c518c5fef35c7716d6f02caaa515aaad1075decd;hp=08d9f11d55fa567147354130aaf3c1146d83c880;hb=da2b5b2e4e2b0ea1847a0a5f0cb4a3752fc655c9;hpb=70706ff642683d03ff091cab25d984ec7d9612de diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 08d9f11d..c518c5fe 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -27,22 +27,44 @@ #include "chatitem.h" -ChatItem::ChatItem(QGraphicsItem *parent) : QGraphicsItem(parent) { - _width = 0; - //if(_wrapMode == WordWrap) { - // setFlags(QGraphicsItem::ItemClipsToShape, true); - //} +ChatItem::ChatItem(const QPersistentModelIndex &index_, QGraphicsItem *parent) : QGraphicsItem(parent), _index(index_) { + _width = _height = 0; } ChatItem::~ChatItem() { } -void ChatItem::setWidth(int w) { +QVariant ChatItem::data(int role) const { + if(!_index.isValid()) { + qWarning() << "ChatItem::data(): Model index is invalid!" << _index; + return QVariant(); + } + return _index.data(role); +} + +QRectF ChatItem::boundingRect() const { + return QRectF(0, 0, _width, _height); +} + +void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + Q_UNUSED(option); Q_UNUSED(widget); + + painter->drawText(boundingRect(), data(MessageModel::DisplayRole).toString()); + painter->setPen(Qt::DotLine); + painter->drawRect(boundingRect()); +} + + + +int ChatItem::setWidth(int w) { _width = w; - layout(); + _height = 20; // FIXME + return _height; } +/* + void ChatItem::setTextOption(const QTextOption &option) { _textOption = option; layout(); @@ -58,7 +80,7 @@ QString ChatItem::text() const { void ChatItem::setText(const UiStyle::StyledText &text) { _layout.setText(text.text); - _layout.setAdditionalFormats(text.formats); + _layout.setAdditionalFormats(text.formatList); layout(); } @@ -91,7 +113,9 @@ void ChatItem::layout() { } _layout.endLayout(); update(); -} +} QDateTime _timestamp; + MsgId _msgId; + QRectF ChatItem::boundingRect() const { return _layout.boundingRect(); @@ -102,6 +126,7 @@ void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, _layout.draw(painter, QPointF(0, 0)); } +*/ /* void ChatItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) {