// This is a deliberate trade-off. (-> selectFmt creation, data() call)
void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
Q_UNUSED(option); Q_UNUSED(widget);
+ painter->save();
+ painter->setClipRect(boundingRect());
paintBackground(painter);
QTextLayout layout;
// }
// 3) draw bounding rect
// painter->drawRect(_boundingRect.adjusted(0, 0, -1, -1));
+
+ painter->restore();
}
void ChatItem::overlayFormat(UiStyle::FormatList &fmtList, int start, int end, quint32 overlayFmt) const {
void SenderChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
Q_UNUSED(option); Q_UNUSED(widget);
+ painter->save();
+ painter->setClipRect(boundingRect());
paintBackground(painter);
QTextLayout layout;
} else {
layout.draw(painter, pos(), additionalFormats(), boundingRect());
}
+ painter->restore();
+}
+
+void SenderChatItem::handleClick(const QPointF &pos, ChatScene::ClickMode clickMode) {
+ if(clickMode == ChatScene::DoubleClick) {
+ BufferInfo curBufInfo = Client::networkModel()->bufferInfo(data(MessageModel::BufferIdRole).value<BufferId>());
+ QString nick = data(MessageModel::EditRole).toString();
+ // check if the nick is a valid ircUser
+ if(!nick.isEmpty() && Client::network(curBufInfo.networkId())->ircUser(nick))
+ Client::bufferModel()->switchToOrStartQuery(curBufInfo.networkId(), nick);
+ }
+ else
+ ChatItem::handleClick(pos, clickMode);
}
// ************************************************************