diff --git a/src/gui/layertree/qgslayertreeviewitemdelegate.cpp b/src/gui/layertree/qgslayertreeviewitemdelegate.cpp index 3645f1f696d..f9d91750b40 100644 --- a/src/gui/layertree/qgslayertreeviewitemdelegate.cpp +++ b/src/gui/layertree/qgslayertreeviewitemdelegate.cpp @@ -33,7 +33,7 @@ QgsLayerTreeViewProxyStyle::QgsLayerTreeViewProxyStyle( QgsLayerTreeView *treeVi QRect QgsLayerTreeViewProxyStyle::subElementRect( QStyle::SubElement element, const QStyleOption *option, const QWidget *widget ) const { - if ( element == SE_ItemViewItemText || element == SE_LayerTreeItemIndicator ) + if ( element == SE_LayerTreeItemIndicator ) { if ( const QStyleOptionViewItem *vopt = qstyleoption_cast( option ) ) { @@ -42,17 +42,11 @@ QRect QgsLayerTreeViewProxyStyle::subElementRect( QStyle::SubElement element, co int count = mLayerTreeView->indicators( node ).count(); if ( count ) { + QRect vpr = mLayerTreeView->viewport()->rect(); QRect r = QProxyStyle::subElementRect( SE_ItemViewItemText, option, widget ); int indiWidth = r.height() * count; - int textWidth = r.width() - indiWidth; - if ( element == SE_LayerTreeItemIndicator ) - { - return QRect( r.left() + textWidth, r.top(), indiWidth, r.height() ); - } - else if ( element == SE_ItemViewItemText ) - { - return QRect( r.left(), r.top(), textWidth, r.height() ); - } + int vpIndiWidth = vpr.width() - indiWidth; + return QRect( vpIndiWidth, r.top(), indiWidth, r.height() ); } } } diff --git a/src/gui/layertree/qgslayertreeviewitemdelegate.h b/src/gui/layertree/qgslayertreeviewitemdelegate.h index 2bc8cc7bd5c..3af310dfc1d 100644 --- a/src/gui/layertree/qgslayertreeviewitemdelegate.h +++ b/src/gui/layertree/qgslayertreeviewitemdelegate.h @@ -37,7 +37,7 @@ class QgsLayerTreeView; #include /** - * Proxy style to make the item text rect shorter so that indicators fit in without colliding with text + * Proxy style for layer items with indicators */ class QgsLayerTreeViewProxyStyle : public QgsProxyStyle {