From 138d3bd0407d8047e6c7c660aac512cdf2ab9376 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 19 Feb 2018 19:23:35 +0000 Subject: [PATCH] Fix painter clipping when resizing tree-branch column quite small --- qrenderdoc/Widgets/Extended/RDTreeView.cpp | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/qrenderdoc/Widgets/Extended/RDTreeView.cpp b/qrenderdoc/Widgets/Extended/RDTreeView.cpp index fc2200932..f165f7c5d 100644 --- a/qrenderdoc/Widgets/Extended/RDTreeView.cpp +++ b/qrenderdoc/Widgets/Extended/RDTreeView.cpp @@ -263,26 +263,29 @@ void RDTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &options, for(int i = 0, count = model()->columnCount(); i < count; i++) { QRect r = visualRect(model()->index(index.row(), i, index.parent())); + + if(r.width() <= 0) + r.moveLeft(r.left() + r.width()); + if(r.height() <= 0) + r.moveTop(r.top() + r.height()); + r = r.intersected(intersectrect); - // draw bottom and right of the rect - if(r.width() > 0 && r.height() > 0) + if(treePosition() == i) { - if(treePosition() == i) + int depth = 1; + QModelIndex idx = index; + while(idx.parent().isValid()) { - int depth = 1; - QModelIndex idx = index; - while(idx.parent().isValid()) - { - depth++; - idx = idx.parent(); - } - r.setLeft(r.left() - indentation() * depth); + depth++; + idx = idx.parent(); } - - painter->drawLine(r.bottomLeft(), r.bottomRight()); - painter->drawLine(r.topRight(), r.bottomRight()); + r.setLeft(r.left() - indentation() * depth); } + + // draw bottom and right of the rect + painter->drawLine(r.bottomLeft(), r.bottomRight()); + painter->drawLine(r.topRight(), r.bottomRight()); } painter->setPen(p); @@ -331,7 +334,7 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel else { // draw only the expand item, not the branches - QRect primitive(0, rect.top(), indentation(), rect.height()); + QRect primitive(0, rect.top(), qMin(rect.width(), indentation()), rect.height()); // if root isn't decorated, skip if(!rootIsDecorated() && !index.parent().isValid())