-ChatLine::ChatLine(int row, QAbstractItemModel *model,
- const qreal &width,
- const qreal ×tampWidth, const qreal &senderWidth, const qreal &contentsWidth,
- const QPointF &senderPos, const QPointF &contentsPos,
- QGraphicsItem *parent)
- : QGraphicsItem(parent),
- _row(row), // needs to be set before the items
- _model(model),
- _contentsItem(contentsWidth, contentsPos, this),
- _senderItem(senderWidth, _contentsItem.height(), senderPos, this),
- _timestampItem(timestampWidth, _contentsItem.height(), this),
- _width(width),
- _height(_contentsItem.height()),
- _selection(0)
-{
- Q_ASSERT(model);
- QModelIndex index = model->index(row, ChatLineModel::ContentsColumn);
- setZValue(0);
- setHighlighted(model->data(index, MessageModel::FlagsRole).toInt() & Message::Highlight);
-}
-
-ChatItem &ChatLine::item(ChatLineModel::ColumnType column) {
- switch(column) {
+ChatLine::ChatLine(int row,
+ QAbstractItemModel* model,
+ const qreal& width,
+ const qreal& timestampWidth,
+ const qreal& senderWidth,
+ const qreal& contentsWidth,
+ const QPointF& senderPos,
+ const QPointF& contentsPos,
+ QGraphicsItem* parent)
+ : QGraphicsItem(parent)
+ , _row(row) // needs to be set before the items
+ , _model(model)
+ , _contentsItem(contentsPos, contentsWidth, this)
+ , _senderItem(QRectF(senderPos, QSizeF(senderWidth, _contentsItem.height())), this)
+ , _timestampItem(QRectF(0, 0, timestampWidth, _contentsItem.height()), this)
+ , _width(width)
+ , _height(_contentsItem.height())
+ , _selection(0)
+ , _mouseGrabberItem(nullptr)
+ , _hoverItem(nullptr)
+{
+ Q_ASSERT(model);
+ QModelIndex index = model->index(row, ChatLineModel::ContentsColumn);
+ setZValue(0);
+ setAcceptHoverEvents(true);
+ setHighlighted(index.data(MessageModel::FlagsRole).toInt() & Message::Highlight);
+}
+
+ChatLine::~ChatLine()
+{
+ if (chatView())
+ chatView()->setHasCache(this, false);
+}
+
+ChatItem* ChatLine::item(ChatLineModel::ColumnType column)
+{
+ switch (column) {