#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_) {
+
}
ChatItem::~ChatItem() {
}
-void ChatItem::setWidth(int w) {
- _width = w;
- layout();
+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) {
+ _boundingRect.setWidth(w);
+ _boundingRect.setHeight(20); // FIXME
+ return 20;
}
+/*
+
void ChatItem::setTextOption(const QTextOption &option) {
_textOption = option;
layout();
void ChatItem::setText(const UiStyle::StyledText &text) {
_layout.setText(text.text);
- _layout.setAdditionalFormats(text.formats);
+ _layout.setAdditionalFormats(text.formatList);
layout();
}
_layout.draw(painter, QPointF(0, 0));
}
+*/
/*
void ChatItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) {