X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=1e086059fd95c84d0c5d8c54e0062309b919d2d2;hb=aefcf3c3799a9deb286723eccc124760ce4d898d;hp=e6f602e14160f363a85c5394dd241fbd9e3a6577;hpb=d298e7275374e2da41b0ed9ef1080464a77c8cf1;p=quassel.git diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index e6f602e1..1e086059 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -27,8 +27,7 @@ #include "chatitem.h" -ChatItem::ChatItem(QGraphicsItem *parent) : QGraphicsItem(parent) { - _width = 0; +ChatItem::ChatItem(const QPersistentModelIndex &index_, QGraphicsItem *parent) : QGraphicsItem(parent), _index(index_) { //if(_wrapMode == WordWrap) { // setFlags(QGraphicsItem::ItemClipsToShape, true); //} @@ -38,6 +37,27 @@ ChatItem::~ChatItem() { } +QVariant ChatItem::data(int role) const { + if(!_index.isValid()) { + qWarning() << "ChatItem::data(): Model index is invalid!"; + return QVariant(); + } + return _index.data(role); +} + +QRectF ChatItem::boundingRect() const { + return QRectF(0, 0, 500,20); +} + +void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + Q_UNUSED(option); Q_UNUSED(widget); + + painter->drawRect(boundingRect()); + painter->drawText(boundingRect(), data(MessageModel::DisplayRole).toString()); +} + + +/* void ChatItem::setWidth(int w) { _width = w; layout(); @@ -104,6 +124,7 @@ void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, _layout.draw(painter, QPointF(0, 0)); } +*/ /* void ChatItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) {