X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=7c0cc9a6a375e7345260c524f012a4126fd4a573;hp=08d9f11d55fa567147354130aaf3c1146d83c880;hb=0b9f74984780aacbe85ca04c44ec6304c86557c2;hpb=70706ff642683d03ff091cab25d984ec7d9612de diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 08d9f11d..7c0cc9a6 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,17 +27,38 @@ #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); //} + } 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(); @@ -58,7 +79,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 +112,9 @@ void ChatItem::layout() { } _layout.endLayout(); update(); -} +} QDateTime _timestamp; + MsgId _msgId; + QRectF ChatItem::boundingRect() const { return _layout.boundingRect(); @@ -102,6 +125,7 @@ void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, _layout.draw(painter, QPointF(0, 0)); } +*/ /* void ChatItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) {