From: Manuel Nickschas Date: Tue, 16 Feb 2010 21:08:45 +0000 (+0100) Subject: Properly clip ChatItem drawing X-Git-Tag: 0.6-beta1~3 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=442f91e70e3b4422948758e696b5e3c4b323bdc1 Properly clip ChatItem drawing Don't let them spill over their area. Also update the ChatScene properly after moving the column handles. --- diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 2ca66aa1..d1ec8116 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -116,6 +116,8 @@ void ChatItem::paintBackground(QPainter *painter) { // 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; @@ -150,6 +152,8 @@ void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, // } // 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 { @@ -344,6 +348,8 @@ void ChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos) { 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; @@ -385,6 +391,7 @@ void SenderChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op } else { layout.draw(painter, pos(), additionalFormats(), boundingRect()); } + painter->restore(); } void SenderChatItem::handleClick(const QPointF &pos, ChatScene::ClickMode clickMode) { diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index ed90582c..3f0b18de 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -501,6 +501,7 @@ void ChatScene::secondHandlePositionChanged(qreal xpos) { void ChatScene::setHandleXLimits() { _firstColHandle->setXLimits(0, _secondColHandle->sceneLeft()); _secondColHandle->setXLimits(_firstColHandle->sceneRight(), width() - minContentsWidth); + update(); } void ChatScene::setSelectingItem(ChatItem *item) {