Properly clip ChatItem drawing
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 16 Feb 2010 21:08:45 +0000 (22:08 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 16 Feb 2010 21:08:45 +0000 (22:08 +0100)
Don't let them spill over their area. Also update the ChatScene properly
after moving the column handles.

src/qtui/chatitem.cpp
src/qtui/chatscene.cpp

index 2ca66aa..d1ec811 100644 (file)
@@ -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) {
index ed90582..3f0b18d 100644 (file)
@@ -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) {